on xenial help sign in
Added preview info hints.
commit8ecf3e04335b4297e5e9d97060393589ccad941b authorPawel Stolowski <pawel.stolowski@canonical.com> dateThu 27 Jun 2013, 13:28 (13 years ago) parentde9b8b7
5 files changed+132
plugins/Unity/CMakeLists.txt+1 plugins/Unity/preview.cpp+18 plugins/Unity/preview.h+3 plugins/Unity/previewinfohint.cpp+52 plugins/Unity/previewinfohint.h+58
plugins/Unity/CMakeLists.txt+1
@@ -26,6 +26,7 @@ set(QMLPLUGIN_SRC
2626 musicpreview.cpp
2727 preview.cpp
2828 previewaction.cpp
29+ previewinfohint.cpp
2930 variantutils.cpp
3031 )
3132
plugins/Unity/preview.cpp+18
@@ -20,6 +20,7 @@
2020// local
2121#include "preview.h"
2222#include "previewaction.h"
23+#include "previewinfohint.h"
2324#include "genericpreview.h"
2425#include "applicationpreview.h"
2526#include "moviepreview.h"
@@ -95,6 +96,22 @@ QVariant Preview::actions()
9596 return QVariant::fromValue(alist);
9697}
9798
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+
98115QString Preview::image() const
99116{
100117 if (m_unityPreview) {
@@ -150,6 +167,7 @@ void Preview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
150167 Q_EMIT subtitleChanged();
151168 Q_EMIT descriptionChanged();
152169 Q_EMIT actionsChanged();
170+ Q_EMIT infoHintsChanged();
153171 Q_EMIT imageChanged();
154172 Q_EMIT imageSourceUriChanged();
155173}
plugins/Unity/preview.h+3
@@ -40,6 +40,7 @@ class Preview : public QObject
4040 Q_PROPERTY(QString subtitle READ subtitle NOTIFY subtitleChanged)
4141 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
4242 Q_PROPERTY(QVariant actions READ actions NOTIFY actionsChanged)
43+ Q_PROPERTY(QVariant infoHints READ infoHints NOTIFY infoHintsChanged)
4344 Q_PROPERTY(QString image READ image NOTIFY imageChanged)
4445 Q_PROPERTY(QString imageSourceUri READ imageSourceUri NOTIFY imageSourceUriChanged)
4546
@@ -52,6 +53,7 @@ public:
5253 QString subtitle() const;
5354 QString description() const;
5455 QVariant actions();
56+ QVariant infoHints();
5557 QString image() const;
5658 QString imageSourceUri() const;
5759
@@ -63,6 +65,7 @@ Q_SIGNALS:
6365 void subtitleChanged();
6466 void descriptionChanged();
6567 void actionsChanged();
68+ void infoHintsChanged();
6669 void imageChanged();
6770 void imageSourceUriChanged();
6871
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