summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsowatch/declarativewatchwrapper.cpp39
-rw-r--r--libsowatch/declarativewatchwrapper.h2
-rw-r--r--metawatch/metawatch.cpp11
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml8
-rw-r--r--metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml1
-rw-r--r--notificationswatchlet/metawatch-digital.qml4
6 files changed, 49 insertions, 16 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();
}
}
diff --git a/libsowatch/declarativewatchwrapper.h b/libsowatch/declarativewatchwrapper.h
index 8d4fd7d..5a827ab 100644
--- a/libsowatch/declarativewatchwrapper.h
+++ b/libsowatch/declarativewatchwrapper.h
@@ -28,6 +28,7 @@ public:
QList<QObject*> notifications() const;
public slots:
+ void useButton(int button);
void vibrate(int msecs);
signals:
@@ -41,6 +42,7 @@ private:
WatchServer *_server;
Watch* _watch;
bool _active;
+ QSet<int> _usedButtons;
void activate();
void deactivate();
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index 2106277..3f3b831 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -682,19 +682,10 @@ void MetaWatch::socketConnected()
// Sync watch date & time
setDateTime(QDateTime::currentDateTime());
- // Grab all buttons in both notification and application modes
- grabButton(ApplicationMode, BtnA);
- grabButton(ApplicationMode, BtnB);
- grabButton(ApplicationMode, BtnC);
- grabButton(ApplicationMode, BtnD);
- grabButton(ApplicationMode, BtnE);
- grabButton(ApplicationMode, BtnF);
+ // Grab a few buttons from Notification mode that we handle
grabButton(NotificationMode, BtnA);
grabButton(NotificationMode, BtnB);
grabButton(NotificationMode, BtnC);
- grabButton(NotificationMode, BtnD);
- grabButton(NotificationMode, BtnE);
- grabButton(NotificationMode, BtnF);
// Call the MetaWatch Model-specific setup routines
handleWatchConnected();
diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml
index 3e445fb..0fb0755 100644
--- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml
+++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml
@@ -49,7 +49,13 @@ ListView {
}
if (currentItemTop <= 0) {
// If the previous item now is still not visible, scroll
- contentY -= 96/3;
+ var newContentY = contentY - 96/3;
+
+ if (newContentY < 0) {
+ contentY = 0; // Never overscroll.
+ } else {
+ contentY = newContentY;
+ }
}
}
}
diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
index 8aa494c..2c8b837 100644
--- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
+++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml
@@ -8,6 +8,7 @@ Rectangle {
Row {
anchors.fill: parent
+ anchors.margins: 1
Text {
id: label
font.bold: true
diff --git a/notificationswatchlet/metawatch-digital.qml b/notificationswatchlet/metawatch-digital.qml
index e5764ec..54f02d2 100644
--- a/notificationswatchlet/metawatch-digital.qml
+++ b/notificationswatchlet/metawatch-digital.qml
@@ -45,6 +45,10 @@ Rectangle {
wrapMode: Text.Wrap
}
+ Component.onCompleted: {
+ watch.useButton(1);
+ watch.useButton(2);
+ }
Connections {
target: watch
onButtonPressed : {