summaryrefslogtreecommitdiff
path: root/libsowatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-11 20:15:36 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-11 20:15:36 +0200
commitac182bd9bf076b4d03d4812e85b989edae32d756 (patch)
tree7d05a80a2e6e44e3fe0dbd3384bf6c18321fa2b8 /libsowatch
parent505f7b1cf62c6934f5246c5e62eccb0a26cb1ce2 (diff)
downloadsowatch-ac182bd9bf076b4d03d4812e85b989edae32d756.tar.gz
sowatch-ac182bd9bf076b4d03d4812e85b989edae32d756.zip
able to navigate watchlets in liveview
Diffstat (limited to 'libsowatch')
-rw-r--r--libsowatch/watch.h6
-rw-r--r--libsowatch/watchserver.cpp50
-rw-r--r--libsowatch/watchserver.h5
3 files changed, 23 insertions, 38 deletions
diff --git a/libsowatch/watch.h b/libsowatch/watch.h
index 27e3d04..6a24d3e 100644
--- a/libsowatch/watch.h
+++ b/libsowatch/watch.h
@@ -91,8 +91,12 @@ signals:
void buttonPressed(int button);
/** A button has been pressed and then released. */
void buttonReleased(int button);
- /** Emitted when e.g. either via the watch menu, or similar, a watchlet is requested. */
+ /** Emitted when e.g. either via the watch menu, or similar, advancing watchlet carrousel is requested. */
+ void nextWatchletRequested();
+ /** Emitted when e.g. either via the watch menu, or similar, a given watchlet is requested. */
void watchletRequested(const QString& id);
+ /** Emitted when closing the current watchlet is requested. */
+ void closeWatchledRequested();
};
}
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();
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index a1cda45..06f4e4b 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -79,8 +79,6 @@ signals:
private:
Watch* _watch;
- /** The watch button that causes next watchlet to be run. */
- int _nextWatchletButton;
/** The amount of seconds that have to pass for a notification to be considered "outdated" and not shown. */
int _oldNotificationThreshold;
@@ -125,8 +123,9 @@ private slots:
void handleWatchConnected();
void handleWatchDisconnected();
void handleWatchIdling();
- void handleWatchButtonPress(int button);
+ void handleNextWatchletRequested();
void handleWatchletRequested(const QString& id);
+ void handleCloseWatchletRequested();
void handleNotificationChanged();
void handleNotificationDismissed();