summaryrefslogtreecommitdiff
path: root/libsowatch/declarativewatchlet.h
blob: 93e9a8e287a70b962fa01a88d1816fa30256a696 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef SOWATCH_DECLARATIVEWATCHLET_H
#define SOWATCH_DECLARATIVEWATCHLET_H

#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeComponent>
#include <QtDeclarative/QDeclarativeItem>
#include "graphicswatchlet.h"
#include "sowatch_global.h"

namespace sowatch
{

class DeclarativeWatchWrapper;

class SOWATCH_EXPORT DeclarativeWatchlet : public GraphicsWatchlet
{
    Q_OBJECT
public:
	DeclarativeWatchlet(Watch* watch, const QString& id);
	~DeclarativeWatchlet();

	void setSource(const QUrl& url);

	QDeclarativeContext* context();
	QDeclarativeItem* rootObject();

	void activate();
	void deactivate();

	void setWatchletsModel(WatchletsModel *model);
	void setNotificationsModel(NotificationsModel *model);

	bool handlesNotification(Notification *notification) const;
	void openNotification(Notification *notification);

private:
	void setRootObject(QDeclarativeItem* item);

	static bool _registered;
	QDeclarativeEngine* _engine;
	QDeclarativeContext *_context;
	QDeclarativeComponent* _component;
	QDeclarativeItem* _item;
	DeclarativeWatchWrapper* _wrapper;

private slots:
	void handleComponentStatus(QDeclarativeComponent::Status status);
};

}

Q_DECLARE_METATYPE(QDeclarativeEngine*)

#endif // SOWATCH_DECLARATIVEWATCHLET_H