summaryrefslogtreecommitdiff
path: root/libsowatch/declarativewatchwrapper.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-12-03 00:00:07 +0100
committerJavier S. Pedro <maemo@javispedro.com>2011-12-03 00:00:07 +0100
commitcbf8e3ad49917dc71e8c5f6413c55f266c1c4ad3 (patch)
tree0c377c57192afdde1f5bf9ea7af5ce9f3fe25a03 /libsowatch/declarativewatchwrapper.cpp
parentd5b5cfc83e1247ebc18ef2024f07bdd37d41164b (diff)
downloadsowatch-cbf8e3ad49917dc71e8c5f6413c55f266c1c4ad3.tar.gz
sowatch-cbf8e3ad49917dc71e8c5f6413c55f266c1c4ad3.zip
change the way buttons work in declarativewatchlets
Diffstat (limited to 'libsowatch/declarativewatchwrapper.cpp')
-rw-r--r--libsowatch/declarativewatchwrapper.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/libsowatch/declarativewatchwrapper.cpp b/libsowatch/declarativewatchwrapper.cpp
index d972d86..122545f 100644
--- a/libsowatch/declarativewatchwrapper.cpp
+++ b/libsowatch/declarativewatchwrapper.cpp
@@ -25,17 +25,27 @@ bool DeclarativeWatchWrapper::active() const
QList<QObject*> DeclarativeWatchWrapper::notifications() const
{
- // TODO: Figure a better way for this; QAbstractListModel, etc.
+ // TODO: Figure out a better way for this; QAbstractListModel, etc.
QList<Notification*> nl = _server->liveNotifications();
QList<QObject*> ol;
foreach (Notification* n, nl) {
QObject * o = n;
ol.append(o);
}
- qDebug() << "notifications declarative: " << ol;
+ qDebug() << "notifications to declarative: " << ol;
return ol;
}
+void DeclarativeWatchWrapper::useButton(int button)
+{
+ if (!_usedButtons.contains(button)) {
+ _usedButtons.insert(button);
+ if (_active) {
+ _watch->grabButton(button);
+ }
+ }
+}
+
void DeclarativeWatchWrapper::vibrate(int msecs)
{
if (_active) {
@@ -46,12 +56,22 @@ void DeclarativeWatchWrapper::vibrate(int msecs)
void DeclarativeWatchWrapper::activate()
{
if (!_active) {
+ _active = true;
+
+ // Grab all of the buttons used by this watchlet
+ foreach (int button, _usedButtons) {
+ _watch->grabButton(button);
+ }
+
+ // Forward the button signals
connect(_watch, SIGNAL(buttonPressed(int)), this, SIGNAL(buttonPressed(int)));
connect(_watch, SIGNAL(buttonReleased(int)), this, SIGNAL(buttonReleased(int)));
- _active = true;
+
+ // Emit the active signal
emit activeChanged();
+
// Since a notification currently causes the active watchlet to be deactivated,
- // we can assume notifications only change when we are deactivated.
+ // we can assume the notifications list only changes when we are deactivated.
emit notificationsChanged();
}
}
@@ -59,8 +79,17 @@ void DeclarativeWatchWrapper::activate()
void DeclarativeWatchWrapper::deactivate()
{
if (_active) {
- disconnect(_watch, 0, this, 0);
_active = false;
+
+ // Stop forwarding button presses
+ disconnect(_watch, 0, this, 0);
+
+ // Ungrab all the buttons used by this watchlet
+ foreach (int button, _usedButtons) {
+ _watch->ungrabButton(button);
+ }
+
+ // Emit the deactivated signal
emit activeChanged();
}
}