summaryrefslogtreecommitdiff
path: root/libsowatch/graphicswatchlet.h
blob: 808d57cd6bdc15dd3ccb79977cb9b98a7c95077a (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
#ifndef SOWATCH_GRAPHICSWATCHLET_H
#define SOWATCH_GRAPHICSWATCHLET_H

#include <QtCore/QTimer>
#include <QtGui/QGraphicsScene>
#include <QtGui/QRegion>
#include "watchlet.h"
#include "sowatch_global.h"

namespace sowatch
{

class SOWATCH_EXPORT GraphicsWatchlet : public Watchlet
{
    Q_OBJECT
	Q_PROPERTY(bool fullUpdateMode READ fullUpdateMode WRITE setFullUpdateMode)

public:
	explicit GraphicsWatchlet(Watch* watch, const QString& id);
	~GraphicsWatchlet();

	QGraphicsScene* scene();
	void setScene(QGraphicsScene* scene);

	bool fullUpdateMode() const;
	void setFullUpdateMode(bool fullUpdateMode);

	QRectF sceneRect() const;
	QRect viewportRect() const;

	void activate();
	void deactivate();

protected:
	static const int frameDelay = 25;
	static const int busyFrameDelay = 50;

	QGraphicsScene* _scene;
	QTimer _frameTimer;

private slots:
	void sceneChanged(const QList<QRectF>& region);
	void frameTimeout();

private:
	bool _fullUpdateMode;
	QRegion _damaged;
};

}

#endif // SOWATCH_GRAPHICSWATCHLET_H