diff options
| author | Javier S. Pedro <maemo@javispedro.com> | 2011-09-26 02:36:09 +0200 | 
|---|---|---|
| committer | Javier S. Pedro <maemo@javispedro.com> | 2011-09-26 02:36:09 +0200 | 
| commit | 0822b88738e00625efd27ccca9119885272924d2 (patch) | |
| tree | f379817602cc23dd829c0aa4751b6b5edc348923 /libsowatch | |
| parent | cf5d24b94d96b722c6d76c2225293a56a50d3c2b (diff) | |
| download | sowatch-0822b88738e00625efd27ccca9119885272924d2.tar.gz sowatch-0822b88738e00625efd27ccca9119885272924d2.zip | |
fixing bugs found during use ;)
Diffstat (limited to 'libsowatch')
| -rw-r--r-- | libsowatch/declarativewatchlet.cpp | 9 | ||||
| -rw-r--r-- | libsowatch/graphicswatchlet.cpp | 18 | ||||
| -rw-r--r-- | libsowatch/graphicswatchlet.h | 9 | ||||
| -rw-r--r-- | libsowatch/libsowatch.pro | 4 | ||||
| -rw-r--r-- | libsowatch/testdeclarativewatchlet.cpp | 9 | ||||
| -rw-r--r-- | libsowatch/testdeclarativewatchlet.h | 19 | ||||
| -rw-r--r-- | libsowatch/watchpaintengine.cpp | 31 | ||||
| -rw-r--r-- | libsowatch/watchpaintengine.h | 12 | ||||
| -rw-r--r-- | libsowatch/watchserver.cpp | 12 | 
9 files changed, 65 insertions, 58 deletions
| diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp index 60538f8..ca60fb0 100644 --- a/libsowatch/declarativewatchlet.cpp +++ b/libsowatch/declarativewatchlet.cpp @@ -66,15 +66,14 @@ QDeclarativeContext* DeclarativeWatchlet::rootContext()  void DeclarativeWatchlet::activate()  { -	Watchlet::activate(); +	GraphicsWatchlet::activate();  	_wrapper->activate(); -	_scene->update();  }  void DeclarativeWatchlet::deactivate()  { -	Watchlet::deactivate();  	_wrapper->deactivate(); +	GraphicsWatchlet::deactivate();  }  void DeclarativeWatchlet::handleComponentStatus(QDeclarativeComponent::Status status) @@ -90,7 +89,7 @@ void DeclarativeWatchlet::handleComponentStatus(QDeclarativeComponent::Status st  	case QDeclarativeComponent::Ready:  		obj = _component->create();  		if (_component->isError()) { -			qWarning() << "QML has instantation errors:"; +			qWarning() << "QML has errors found while creating:";  			qWarning() <<  _component->errors();  			return;  		} @@ -99,7 +98,7 @@ void DeclarativeWatchlet::handleComponentStatus(QDeclarativeComponent::Status st  		scene()->addItem(_item);  		break;  	case QDeclarativeComponent::Error: -		qWarning() << "QML has errors:"; +		qWarning() << "QML has errors found while loading:";  		qWarning() <<  _component->errors();  		break;  	} diff --git a/libsowatch/graphicswatchlet.cpp b/libsowatch/graphicswatchlet.cpp index 538723a..195d11b 100644 --- a/libsowatch/graphicswatchlet.cpp +++ b/libsowatch/graphicswatchlet.cpp @@ -1,4 +1,5 @@  #include <QtCore/QDebug> +#include <QtCore/QEvent>  #include <QtGui/QPainter>  #include "watch.h" @@ -30,18 +31,25 @@ void GraphicsWatchlet::setScene(QGraphicsScene *scene)  void GraphicsWatchlet::sceneChanged(const QList<QRectF> ®ion)  { -	foreach(const QRectF& r, region) -	{ +	foreach(const QRectF& r, region) {  		_damaged += r.toRect();  	} -  	if (!_damaged.isEmpty() && _active && !watch()->busy()) {  		const QVector<QRect> rects = _damaged.rects();  		QPainter p(watch()); -		foreach(const QRect& r, rects) -		{ + +		foreach(const QRect& r, rects) {  			_scene->render(&p, r, r, Qt::IgnoreAspectRatio);  		}  		_damaged = QRegion();  	}  } + +void GraphicsWatchlet::activate() +{ +	Watchlet::activate(); +	// We have to assume that the watch has completely forgot about everything. +	QRect area(0, 0, watch()->width(), watch()->height()); +	_damaged += area; +	_scene->update(area); +} diff --git a/libsowatch/graphicswatchlet.h b/libsowatch/graphicswatchlet.h index 37752a9..3202631 100644 --- a/libsowatch/graphicswatchlet.h +++ b/libsowatch/graphicswatchlet.h @@ -18,13 +18,14 @@ public:  	QGraphicsScene* scene();  	void setScene(QGraphicsScene* scene); -protected: -	QGraphicsScene* _scene; -	QRegion _damaged; -  protected slots:  	void sceneChanged(const QList<QRectF>& region); +protected: +	void activate(); + +	QGraphicsScene* _scene; +	QRegion _damaged;  };  } diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro index 44458c2..5ab1f3b 100644 --- a/libsowatch/libsowatch.pro +++ b/libsowatch/libsowatch.pro @@ -20,7 +20,6 @@ SOURCES += \      watchlet.cpp \      watch.cpp \      testwatchlet.cpp \ -    testdeclarativewatchlet.cpp \      graphicswatchlet.cpp \      declarativewatchwrapper.cpp \      declarativewatchlet.cpp \ @@ -37,7 +36,6 @@ HEADERS +=\      watchlet.h \      watch.h \      testwatchlet.h \ -    testdeclarativewatchlet.h \      sowatch.h \      graphicswatchlet.h \      declarativewatchwrapper.h \ @@ -93,3 +91,5 @@ unix:!symbian { + + diff --git a/libsowatch/testdeclarativewatchlet.cpp b/libsowatch/testdeclarativewatchlet.cpp deleted file mode 100644 index 432d525..0000000 --- a/libsowatch/testdeclarativewatchlet.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "testdeclarativewatchlet.h" - -using namespace sowatch; - -TestDeclarativeWatchlet::TestDeclarativeWatchlet(WatchServer* server) : -	DeclarativeWatchlet(server, "com.javispedro.sowatch.testdeclarativewatchlet") -{ -	setSource(QUrl("qrc:/testdeclarativewatchlet.qml")); -} diff --git a/libsowatch/testdeclarativewatchlet.h b/libsowatch/testdeclarativewatchlet.h deleted file mode 100644 index a200663..0000000 --- a/libsowatch/testdeclarativewatchlet.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef SOWATCH_TESTDECLARATIVEWATCHLET_H -#define SOWATCH_TESTDECLARATIVEWATCHLET_H - -#include "declarativewatchlet.h" - -namespace sowatch -{ - -class TestDeclarativeWatchlet : public DeclarativeWatchlet -{ -    Q_OBJECT -public: -	explicit TestDeclarativeWatchlet(WatchServer* server); - -}; - -} - -#endif // SOWATCH_TESTDECLARATIVEWATCHLET_H diff --git a/libsowatch/watchpaintengine.cpp b/libsowatch/watchpaintengine.cpp index 6c509cb..90ad8bf 100644 --- a/libsowatch/watchpaintengine.cpp +++ b/libsowatch/watchpaintengine.cpp @@ -1,19 +1,40 @@  #include <QtCore/QDebug>  #include <math.h> -#include "watch.h"  #include "watchpaintengine.h"  using namespace sowatch; -WatchPaintEngine::WatchPaintEngine(Watch* watch) +WatchPaintEngine::WatchPaintEngine()  	: QPaintEngine(QPaintEngine::AllFeatures), -	  _watch(watch), _painter(), -	  _hasPen(false), _hasBrush(false), _clipEnabled(false) +	  _painter()  {  } +WatchPaintEngine::~WatchPaintEngine() +{ + +} + +bool WatchPaintEngine::begin(QPaintDevice *pdev) +{ +	_damaged = QRegion(); +	_area = QRect(0, 0, pdev->width(), pdev->height()); +	_hasPen = false; +	_penWidth = 0.0; +	_hasBrush = false; +	_clipEnabled = false; +	_clipRegion = _area; + +	return _painter.begin(pdev); +} + +bool WatchPaintEngine::end() +{ +	return _painter.end(); +} +  void WatchPaintEngine::damageMappedRect(const QRect &r)  {  	if (_clipEnabled) { @@ -57,7 +78,7 @@ void WatchPaintEngine::updateClipRegion(const QRegion& region, Qt::ClipOperation  	switch(op) {  		case Qt::NoClip:  			_clipEnabled = false; -			_clipRegion = QRegion(0, 0, _watch->width(), _watch->height()); +			_clipRegion = _area;  			break;  		case Qt::ReplaceClip:  			_clipEnabled = true; diff --git a/libsowatch/watchpaintengine.h b/libsowatch/watchpaintengine.h index 74d4e09..7a97ad7 100644 --- a/libsowatch/watchpaintengine.h +++ b/libsowatch/watchpaintengine.h @@ -6,12 +6,14 @@  namespace sowatch  { -class Watch; -  class WatchPaintEngine : public QPaintEngine  {  public: -	WatchPaintEngine(Watch* watch); +	~WatchPaintEngine(); + +	/* You are supposed to override these two functions. */ +	bool begin(QPaintDevice *pdev); +	bool end();  	void drawEllipse(const QRectF &r);  	void drawEllipse(const QRect &r); @@ -33,15 +35,17 @@ public:  	void updateState(const QPaintEngineState &state);  protected: +	WatchPaintEngine(); +  	void damageMappedRect(const QRect& r);  	void damageRect(const QRect& r);  	void damageRect(const QRectF& r);  	void damagePenStroke(const QLineF& line);  	void updateClipRegion(const QRegion& region, Qt::ClipOperation op); -	Watch* _watch;  	QPainter _painter;  	QRegion _damaged; +	QRect _area;  	bool _hasPen;  	qreal _penWidth; diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 07e4609..c81d937 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -68,6 +68,7 @@ void WatchServer::runWatchlet(const QString& id)  void WatchServer::closeWatchlet()  {  	if (_currentWatchlet) { +		qDebug() << "deactivating watchlet" << _currentWatchlet->id();  		_currentWatchlet->deactivate();  		_currentWatchlet = 0;  		if (_watch->isConnected() && _pendingNotifications.empty()) { @@ -183,13 +184,13 @@ void WatchServer::notificationReceived(Notification *notification)  	connect(notification, SIGNAL(changed()), SLOT(notificationChanged()));  	connect(notification, SIGNAL(cleared()), SLOT(notificationCleared())); -	qDebug() << "notification received" << notification->title() << notification->count(); +	qDebug() << "notification received" << notification->title() << "(" << notification->count() << ")";  	_watch->updateNotificationCount(type, getNotificationCount(type));  	QDateTime oldThreshold = QDateTime::currentDateTime().addSecs(-_oldNotificationThreshold);  	if (notification->dateTime() < oldThreshold) { -		return; // Do not care about that old notifications... +		return; // Do not care about notifications that old...  	}  	if (_pendingNotifications.isEmpty()) { @@ -211,7 +212,7 @@ void WatchServer::notificationChanged()  		Notification* n = static_cast<Notification*>(obj);  		const Notification::Type type = n->type(); -		qDebug() << "notification changed" << n->title() << n->count(); +		qDebug() << "notification changed" << n->title() << "(" << n->count() << ")";  		_watch->updateNotificationCount(type, getNotificationCount(type));  		if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) { @@ -228,11 +229,12 @@ void WatchServer::notificationCleared()  		const Notification::Type type = n->type();  		_notifications[type].removeOne(n); -		qDebug() << "notification deleted" << n->title() << n->count(); +		qDebug() << "notification deleted" << n->title() << "(" << n->count() << ")";  		_watch->updateNotificationCount(type, getNotificationCount(type)); -		if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {qDebug() << "removing top notification"; +		if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) { +			qDebug() << "removing top notification";  			_pendingNotifications.removeAll(n);  			nextNotification();  		} else { | 
