summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r--libsowatch/watchserver.cpp50
1 files changed, 16 insertions, 34 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index c82c3ee..06a8189 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -11,7 +11,6 @@ using namespace sowatch;
WatchServer::WatchServer(Watch* watch, QObject* parent) :
QObject(parent), _watch(watch),
- _nextWatchletButton(-1),
_oldNotificationThreshold(300),
_idleWatchlet(0), _notificationWatchlet(0),
_watchlets(new WatchletsModel(this)),
@@ -22,9 +21,10 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) :
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(_watch, SIGNAL(nextWatchletRequested()), SLOT(handleNextWatchletRequested()));
connect(_watch, SIGNAL(watchletRequested(QString)),
SLOT(handleWatchletRequested(QString)));
+ connect(_watch, SIGNAL(closeWatchledRequested()), SLOT(handleCloseWatchletRequested()));
connect(_syncTimeTimer, SIGNAL(timeout()), SLOT(syncTime()));
_syncTimeTimer->setSingleShot(true);
@@ -43,27 +43,6 @@ const Watch* WatchServer::watch() const
return _watch;
}
-QString WatchServer::nextWatchletButton() const
-{
- if (_nextWatchletButton >= 0) {
- return _watch->buttons().at(_nextWatchletButton);
- } else {
- return QString();
- }
-}
-
-void WatchServer::setNextWatchletButton(const QString& value)
-{
- if (value.isEmpty()) {
- _nextWatchletButton = -1;
- return;
- }
- _nextWatchletButton = _watch->buttons().indexOf(value);
- if (_nextWatchletButton < 0) {
- qWarning() << "Invalid watch button" << value;
- }
-}
-
Watchlet * WatchServer::idleWatchlet()
{
return _idleWatchlet;
@@ -392,18 +371,16 @@ void WatchServer::handleWatchIdling()
}
}
-void WatchServer::handleWatchButtonPress(int button)
+void WatchServer::handleNextWatchletRequested()
{
- if (button == _nextWatchletButton) {
- qDebug() << "next watchlet button pressed";
- if (_pendingNotifications.empty()) {
- // No notifications: either app or idle mode.
- nextWatchlet();
- } else {
- // Skip to next notification if any
- _pendingNotifications.dequeue();
- nextNotification();
- }
+ qDebug() << "next watchlet button pressed";
+ if (_pendingNotifications.empty()) {
+ // No notifications: either app or idle mode.
+ nextWatchlet();
+ } else {
+ // Skip to next notification if any
+ _pendingNotifications.dequeue();
+ nextNotification();
}
}
@@ -412,6 +389,11 @@ void WatchServer::handleWatchletRequested(const QString &id)
openWatchlet(id);
}
+void WatchServer::handleCloseWatchletRequested()
+{
+ closeWatchlet();
+}
+
void WatchServer::handleNotificationChanged()
{
QObject *obj = sender();