on xenial help sign in
Added preview info hints.
8ecf3e0Pawel Stolowski
plugins/Unity/CMakeLists.txt+1
@@ -26,6 +26,7 @@ set(QMLPLUGIN_SRC
26 musicpreview.cpp
26 musicpreview.cpp
27 preview.cpp
27 preview.cpp
28 previewaction.cpp
28 previewaction.cpp
29+ previewinfohint.cpp
29 variantutils.cpp
30 variantutils.cpp
30 )
31 )
31
32
plugins/Unity/preview.cpp+18
@@ -20,6 +20,7 @@
20// local
20// local
21#include "preview.h"
21#include "preview.h"
22#include "previewaction.h"
22#include "previewaction.h"
23+#include "previewinfohint.h"
23#include "genericpreview.h"
24#include "genericpreview.h"
24#include "applicationpreview.h"
25#include "applicationpreview.h"
25#include "moviepreview.h"
26#include "moviepreview.h"
@@ -95,6 +96,22 @@ QVariant Preview::actions()
95 return QVariant::fromValue(alist);
96 return QVariant::fromValue(alist);
96}
97}
97
98
99+QVariant Preview::infoHints()
100+{
101+ QList<QObject *> hints;
102+ if (m_unityPreview) {
103+ for (auto unityInfoHint: m_unityPreview->GetInfoHints()) {
104+ auto hint = new PreviewInfoHint(this); // preview is the owner of hints
105+ hint->setUnityInfoHint(unityInfoHint);
106+ hints.append(hint);
107+ }
108+ } else {
109+ qWarning() << "Preview not set";
110+ }
111+
112+ return QVariant::fromValue(hints);
113+}
114+
98QString Preview::image() const
115QString Preview::image() const
99{
116{
100 if (m_unityPreview) {
117 if (m_unityPreview) {
@@ -150,6 +167,7 @@ void Preview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
150 Q_EMIT subtitleChanged();
167 Q_EMIT subtitleChanged();
151 Q_EMIT descriptionChanged();
168 Q_EMIT descriptionChanged();
152 Q_EMIT actionsChanged();
169 Q_EMIT actionsChanged();
170+ Q_EMIT infoHintsChanged();
153 Q_EMIT imageChanged();
171 Q_EMIT imageChanged();
154 Q_EMIT imageSourceUriChanged();
172 Q_EMIT imageSourceUriChanged();
155}
173}
plugins/Unity/preview.h+3
@@ -40,6 +40,7 @@ class Preview : public QObject
40 Q_PROPERTY(QString subtitle READ subtitle NOTIFY subtitleChanged)
40 Q_PROPERTY(QString subtitle READ subtitle NOTIFY subtitleChanged)
41 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
41 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
42 Q_PROPERTY(QVariant actions READ actions NOTIFY actionsChanged)
42 Q_PROPERTY(QVariant actions READ actions NOTIFY actionsChanged)
43+ Q_PROPERTY(QVariant infoHints READ infoHints NOTIFY infoHintsChanged)
43 Q_PROPERTY(QString image READ image NOTIFY imageChanged)
44 Q_PROPERTY(QString image READ image NOTIFY imageChanged)
44 Q_PROPERTY(QString imageSourceUri READ imageSourceUri NOTIFY imageSourceUriChanged)
45 Q_PROPERTY(QString imageSourceUri READ imageSourceUri NOTIFY imageSourceUriChanged)
45
46
@@ -52,6 +53,7 @@ public:
52 QString subtitle() const;
53 QString subtitle() const;
53 QString description() const;
54 QString description() const;
54 QVariant actions();
55 QVariant actions();
56+ QVariant infoHints();
55 QString image() const;
57 QString image() const;
56 QString imageSourceUri() const;
58 QString imageSourceUri() const;
57
59
@@ -63,6 +65,7 @@ Q_SIGNALS:
63 void subtitleChanged();
65 void subtitleChanged();
64 void descriptionChanged();
66 void descriptionChanged();
65 void actionsChanged();
67 void actionsChanged();
68+ void infoHintsChanged();
66 void imageChanged();
69 void imageChanged();
67 void imageSourceUriChanged();
70 void imageSourceUriChanged();
68
71
plugins/Unity/previewinfohint.cppnew file+52
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Pawel Stolowski <pawel.stolowski@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+// local
21+#include "previewinfohint.h"
22+
23+PreviewInfoHint::PreviewInfoHint(QObject *parent):
24+ QObject(parent),
25+ m_unityInfoHint(nullptr)
26+{
27+}
28+
29+void PreviewInfoHint::setUnityInfoHint(unity::dash::Preview::InfoHintPtr unityInfoHint)
30+{
31+ m_unityInfoHint = unityInfoHint;
32+
33+ Q_EMIT displayNameChanged();
34+ Q_EMIT iconHintChanged();
35+ Q_EMIT valueChanged();
36+}
37+
38+QString PreviewInfoHint::id() const
39+{
40+}
41+
42+QString PreviewInfoHint::displayName() const
43+{
44+}
45+
46+QString PreviewInfoHint::iconHint() const
47+{
48+}
49+
50+QVariant PreviewInfoHint::value() const
51+{
52+}
plugins/Unity/previewinfohint.hnew file+58
@@ -0,0 +1,58 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Pawel Stolowski <pawel.stolowski@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+#ifndef PREVIEWINFOHINT_H
21+#define PREVIEWINFOHINT_H
22+
23+// Qt
24+#include <QObject>
25+#include <QString>
26+#include <QVariant>
27+
28+// libunity-core
29+#include <UnityCore/Preview.h>
30+
31+class PreviewInfoHint : public QObject
32+{
33+ Q_OBJECT
34+
35+ Q_PROPERTY(QString id READ id)
36+ Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
37+ Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
38+ Q_PROPERTY(QVariant value READ value NOTIFY valueChanged)
39+
40+public:
41+ explicit PreviewInfoHint(QObject *parent = 0);
42+ void setUnityInfoHint(unity::dash::Preview::InfoHintPtr unityInfoHint);
43+
44+ QString id() const;
45+ QString displayName() const;
46+ QString iconHint() const;
47+ QVariant value() const;
48+
49+Q_SIGNALS:
50+ void displayNameChanged();
51+ void iconHintChanged();
52+ void valueChanged();
53+
54+private:
55+ unity::dash::Preview::InfoHintPtr m_unityInfoHint;
56+};
57+
58+#endif