From 406332eb6b3199d19388f359d04c9f184e6082b5 Mon Sep 17 00:00:00 2001
From: "Javier S. Pedro" <maemo@javispedro.com>
Date: Thu, 9 Aug 2012 04:03:20 +0200
Subject: watch status UI

---
 libsowatch/gconfkey.cpp     |  1 +
 libsowatch/sowatch_global.h |  2 +-
 libsowatch/watchserver.cpp  | 26 ++++++++++++++------------
 libsowatch/watchserver.h    | 16 ++++++++++------
 4 files changed, 26 insertions(+), 19 deletions(-)

(limited to 'libsowatch')

diff --git a/libsowatch/gconfkey.cpp b/libsowatch/gconfkey.cpp
index b47deb5..c6becc4 100644
--- a/libsowatch/gconfkey.cpp
+++ b/libsowatch/gconfkey.cpp
@@ -11,6 +11,7 @@ static GConfClient* g_client = NULL;
 
 static GConfClient* get_client() {
 	if (!g_client) {
+		g_type_init();
 		g_client = gconf_client_get_default();
 	}
 	return g_client;
diff --git a/libsowatch/sowatch_global.h b/libsowatch/sowatch_global.h
index 9c6cf73..b537930 100644
--- a/libsowatch/sowatch_global.h
+++ b/libsowatch/sowatch_global.h
@@ -10,7 +10,7 @@
 #	define SOWATCH_EXPORT Q_DECL_IMPORT
 #endif
 
-#if defined(QT_SIMULATOR) || !defined(QT_NO_DEBUG)
+#if defined(QT_SIMULATOR) || (!defined(MEEGO_VERSION_MAJOR) && !defined(Q_WS_MAEMO_5) && !defined(QT_NO_DEBUG))
 #	define SOWATCH_PLUGINS_DIR		".."
 #	define SOWATCH_RESOURCES_DIR	".."
 #	define SOWATCH_QML_DIR			".."
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index 540eeea..d5db9da 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -14,10 +14,10 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) :
 	_currentWatchlet(0), _currentWatchletActive(false), _currentWatchletIndex(-1),
 	_syncTimeTimer(new QTimer(this))
 {
-	connect(_watch, SIGNAL(connected()), SLOT(watchConnected()));
-	connect(_watch, SIGNAL(disconnected()), SLOT(watchDisconnected()));
-	connect(_watch, SIGNAL(idling()), SLOT(watchIdling()));
-	connect(_watch, SIGNAL(buttonPressed(int)), SLOT(watchButtonPress(int)));
+	connect(_watch, SIGNAL(connected()), SLOT(handleWatchConnected()));
+	connect(_watch, SIGNAL(disconnected()), SLOT(handleWatchDisconnected()));
+	connect(_watch, SIGNAL(idling()), SLOT(handleWatchIdling()));
+	connect(_watch, SIGNAL(buttonPressed(int)), SLOT(handleWatchButtonPress(int)));
 	connect(_syncTimeTimer, SIGNAL(timeout()), SLOT(syncTime()));
 
 	_syncTimeTimer->setSingleShot(true);
@@ -165,7 +165,7 @@ void WatchServer::goToIdle()
 	_watch->displayIdleScreen();
 }
 
-void WatchServer::watchConnected()
+void WatchServer::handleWatchConnected()
 {
 	syncTime();
 	if (!_pendingNotifications.isEmpty()) {
@@ -175,18 +175,20 @@ void WatchServer::watchConnected()
 	} else {
 		goToIdle();
 	}
+	emit watchConnected();
 }
 
-void WatchServer::watchDisconnected()
+void WatchServer::handleWatchDisconnected()
 {
 	_syncTimeTimer->stop();
 	if (_currentWatchlet && _currentWatchletActive) {
 		deactivateCurrentWatchlet();
 	}
 	_pendingNotifications.clear();
+	emit watchDisconnected();
 }
 
-void WatchServer::watchIdling()
+void WatchServer::handleWatchIdling()
 {
 	qDebug() << "watch idling";
 	if (!_pendingNotifications.empty()) {
@@ -195,7 +197,7 @@ void WatchServer::watchIdling()
 	}
 }
 
-void WatchServer::watchButtonPress(int button)
+void WatchServer::handleWatchButtonPress(int button)
 {
 	if (button == _nextWatchletButton) {
 		qDebug() << "next watchlet button pressed";
@@ -216,8 +218,8 @@ void WatchServer::postNotification(Notification *notification)
 	_notifications[type].append(notification);
 	_notificationCounts[notification] = notification->count();
 
-	connect(notification, SIGNAL(changed()), SLOT(notificationChanged()));
-	connect(notification, SIGNAL(dismissed()), SLOT(notificationDismissed()));
+	connect(notification, SIGNAL(changed()), SLOT(handleNotificationChanged()));
+	connect(notification, SIGNAL(dismissed()), SLOT(handleNotificationDismissed()));
 
 	qDebug() << "notification received" << notification->title() << "(" << notification->count() << ")";
 
@@ -264,7 +266,7 @@ void WatchServer::nextNotification()
 	}
 }
 
-void WatchServer::notificationChanged()
+void WatchServer::handleNotificationChanged()
 {
 	QObject *obj = sender();
 	if (obj) {
@@ -307,7 +309,7 @@ void WatchServer::notificationChanged()
 	}
 }
 
-void WatchServer::notificationDismissed()
+void WatchServer::handleNotificationDismissed()
 {
 	QObject *obj = sender();
 	if (obj) {
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index 3995bc6..54d3dc1 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -49,6 +49,10 @@ public slots:
 
 	void syncTime();
 
+signals:
+	void watchConnected();
+	void watchDisconnected();
+
 private:
 	Watch* _watch;
 
@@ -89,13 +93,13 @@ private:
 	void goToIdle();
 
 private slots:
-	void watchConnected();
-	void watchDisconnected();
-	void watchIdling();
-	void watchButtonPress(int button);
+	void handleWatchConnected();
+	void handleWatchDisconnected();
+	void handleWatchIdling();
+	void handleWatchButtonPress(int button);
 
-	void notificationChanged();
-	void notificationDismissed();
+	void handleNotificationChanged();
+	void handleNotificationDismissed();
 };
 
 }
-- 
cgit v1.2.3