on xenial help sign in
Added property notification for base preview attributes.
commit36c4013a5d5010f898507c04ec66a871cc40af9d authorPawel Stolowski <pawel.stolowski@canonical.com> dateWed 26 Jun 2013, 13:20 (13 years ago) parent62263d2
4 files changed+20−9
plugins/Unity/plugin.cpp+1 plugins/Unity/preview.cpp+7−3 plugins/Unity/preview.h+10−4 plugins/Unity/previewaction.h+2−2
plugins/Unity/plugin.cpp+1
@@ -42,6 +42,7 @@ void UnityPlugin::registerTypes(const char *uri)
4242{
4343 Q_ASSERT(uri == QLatin1String("Unity"));
4444 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.");
4546 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
4647 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
4748 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
plugins/Unity/preview.cpp+7−3
@@ -102,15 +102,19 @@ Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
102102 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
103103 preview = new GenericPreview();
104104 }
105− preview->m_unityPreview = unityPreview;
105+ preview->Preview::setUnityPreview(unityPreview);
106106 preview->setUnityPreview(unityPreview);
107107
108108 return preview;
109109}
110110
111−void Preview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
111+void Preview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
112112{
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();
114118}
115119
116120void Preview::execute(const QString& actionId, const QHash<QString, QVariant>& hints)
plugins/Unity/preview.h+10−4
@@ -35,10 +35,10 @@ class Preview : public QObject
3535{
3636 Q_OBJECT
3737
38− Q_PROPERTY(QString rendererName READ rendererName)
39− Q_PROPERTY(QString title READ title)
40− Q_PROPERTY(QString subtitle READ subtitle)
41− Q_PROPERTY(PreviewActionList actions READ actions)
38+ Q_PROPERTY(QString rendererName READ rendererName NOTIFY rendererNameChanged)
39+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
40+ Q_PROPERTY(QString subtitle READ subtitle NOTIFY subtitleChanged)
41+ Q_PROPERTY(PreviewActionList actions READ actions NOTIFY actionsChanged)
4242
4343public:
4444 explicit Preview(QObject *parent = 0);
@@ -52,6 +52,12 @@ public:
5252public Q_SLOTS:
5353 void execute(const QString& actionId, const QHash<QString, QVariant>& hints);
5454
55+Q_SIGNALS:
56+ void rendererNameChanged();
57+ void titleChanged();
58+ void subtitleChanged();
59+ void actionsChanged();
60+
5561protected:
5662 virtual void setUnityPreview(unity::dash::Preview::Ptr unityPreview);
5763
plugins/Unity/previewaction.h+2−2
@@ -66,8 +66,8 @@ private:
6666};
6767
6868typedef QList<PreviewAction *> PreviewActionList;
69−Q_DECLARE_METATYPE(PreviewAction*)
70−Q_DECLARE_METATYPE(PreviewActionList)
69+Q_DECLARE_METATYPE(PreviewAction *)
70+Q_DECLARE_METATYPE(PreviewActionList *)
7171Q_DECLARE_METATYPE(LayoutHint)
7272
7373#endif