on xenial help sign in
Added property notification for base preview attributes.
36c4013Pawel Stolowski
plugins/Unity/plugin.cpp+1
@@ -42,6 +42,7 @@ void UnityPlugin::registerTypes(const char *uri)
42{
42{
43 Q_ASSERT(uri == QLatin1String("Unity"));
43 Q_ASSERT(uri == QLatin1String("Unity"));
44 qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
44 qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
45+ qmlRegisterUncreatableType<PreviewAction>(uri, 0, 1, "PreviewAction", "Can't create PreviewAction object in QML.");
45 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
46 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
46 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
47 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
47 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
48 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
plugins/Unity/preview.cpp+7−3
@@ -102,15 +102,19 @@ Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
102 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
102 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
103 preview = new GenericPreview();
103 preview = new GenericPreview();
104 }
104 }
105− preview->m_unityPreview = unityPreview;
105+ preview->Preview::setUnityPreview(unityPreview);
106 preview->setUnityPreview(unityPreview);
106 preview->setUnityPreview(unityPreview);
107
107
108 return preview;
108 return preview;
109}
109}
110
110
111−void Preview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
111+void Preview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
112{
112{
113− // default implementation does nothing
113+ m_unityPreview = unityPreview;
114+ Q_EMIT rendererNameChanged();
115+ Q_EMIT titleChanged();
116+ Q_EMIT subtitleChanged();
117+ Q_EMIT actionsChanged();
114}
118}
115
119
116void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
120void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
plugins/Unity/preview.h+10−4
@@ -35,10 +35,10 @@ class Preview : public QObject
35{
35{
36 Q_OBJECT
36 Q_OBJECT
37
37
38− Q_PROPERTY(QString rendererName READ rendererName)
38+ Q_PROPERTY(QString rendererName READ rendererName NOTIFY rendererNameChanged)
39− Q_PROPERTY(QString title READ title)
39+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
40− Q_PROPERTY(QString subtitle READ subtitle)
40+ Q_PROPERTY(QString subtitle READ subtitle NOTIFY subtitleChanged)
41− Q_PROPERTY(PreviewActionList actions READ actions)
41+ Q_PROPERTY(PreviewActionList actions READ actions NOTIFY actionsChanged)
42
42
43public:
43public:
44 explicit Preview(QObject *parent = 0);
44 explicit Preview(QObject *parent = 0);
@@ -52,6 +52,12 @@ public:
52public Q_SLOTS:
52public Q_SLOTS:
53 void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
53 void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
54
54
55+Q_SIGNALS:
56+ void rendererNameChanged();
57+ void titleChanged();
58+ void subtitleChanged();
59+ void actionsChanged();
60+
55protected:
61protected:
56 virtual void setUnityPreview(unity::dash::Preview::Ptr unityPreview);
62 virtual void setUnityPreview(unity::dash::Preview::Ptr unityPreview);
57
63
plugins/Unity/previewaction.h+2−2
@@ -66,8 +66,8 @@ private:
66};
66};
67
67
68typedef QList<PreviewAction *> PreviewActionList;
68typedef QList<PreviewAction *> PreviewActionList;
69−Q_DECLARE_METATYPE(PreviewAction*)
69+Q_DECLARE_METATYPE(PreviewAction *)
70−Q_DECLARE_METATYPE(PreviewActionList)
70+Q_DECLARE_METATYPE(PreviewActionList *)
71Q_DECLARE_METATYPE(LayoutHint)
71Q_DECLARE_METATYPE(LayoutHint)
72
72
73#endif
73#endif