summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qmafwwatchlet/metawatch-digital.qml5
-rw-r--r--qmafwwatchlet/qmafwwatchletvolumecontrol.cc41
-rw-r--r--qmafwwatchlet/qmafwwatchletvolumecontrol.h4
-rw-r--r--sowatch.pro6
4 files changed, 39 insertions, 17 deletions
diff --git a/qmafwwatchlet/metawatch-digital.qml b/qmafwwatchlet/metawatch-digital.qml
index 02a5460..18a4ffc 100644
--- a/qmafwwatchlet/metawatch-digital.qml
+++ b/qmafwwatchlet/metawatch-digital.qml
@@ -78,8 +78,9 @@ Rectangle {
anchors.bottom: parent.bottom
anchors.margins: 4
- visible: volumeBar.visible
- height: (volumeControl.volume * (parent.height - anchors.margins*2)) / (volumeControl.max - volumeControl.min)
+ height: volumeBar.visible ?
+ (volumeControl.volume * (parent.height - anchors.margins*2)) / (volumeControl.max - volumeControl.min) :
+ 0; // Avoid unnecessary updates when not visible.
color: "white"
}
diff --git a/qmafwwatchlet/qmafwwatchletvolumecontrol.cc b/qmafwwatchlet/qmafwwatchletvolumecontrol.cc
index f4876a8..f839ce7 100644
--- a/qmafwwatchlet/qmafwwatchletvolumecontrol.cc
+++ b/qmafwwatchlet/qmafwwatchletvolumecontrol.cc
@@ -69,19 +69,34 @@ void QMafwWatchletVolumeControl::setVolume(int vol)
dbus_connection_send(_conn, msg, 0);
dbus_message_unref(msg);
+
+ if (vol != _curStep) {
+ _curStep = vol;
+ emit volumeChanged();
+ }
}
void QMafwWatchletVolumeControl::up()
{
- if (_curStep < _maxStep - 1) {
- setVolume(_curStep + 1);
+ int increment = _maxStep / 10;
+ int newStep = _curStep + increment;
+ if (newStep >= _maxStep) {
+ newStep = _maxStep - 1;
+ }
+ if (newStep != _curStep) {
+ setVolume(newStep);
}
}
void QMafwWatchletVolumeControl::down()
{
- if (_curStep > 0) {
- setVolume(_curStep - 1);
+ int increment = _maxStep / 10;
+ int newStep = _curStep - increment;
+ if (newStep < 0) {
+ newStep = 0;
+ }
+ if (newStep != _curStep) {
+ setVolume(newStep);
}
}
@@ -135,7 +150,7 @@ void QMafwWatchletVolumeControl::_listenForSignal()
void QMafwWatchletVolumeControl::_fetchValues()
{
- DBusMessage *msg, *reply;
+ DBusMessage *msg;
DBusError err;
dbus_error_init(&err);
@@ -205,12 +220,13 @@ void QMafwWatchletVolumeControl::handleFetchReply(DBusPendingCall *pending, void
quint32 value;
dbus_message_iter_get_basic(&iter_variant, &value);
- if (strcmp(prop_name, "StepCount")) {
+ qDebug() << "MainVolume" << prop_name << value;
+
+ if (strcmp(prop_name, "StepCount") == 0) {
self->_maxStep = value;
- } else if (strcmp(prop_name, "CurrentStep")) {
+ } else if (strcmp(prop_name, "CurrentStep") == 0) {
self->_curStep = value;
}
- qDebug() << prop_name << value;
}
dbus_message_iter_next(&iter_dict);
@@ -229,6 +245,7 @@ void QMafwWatchletVolumeControl::handleFetchReply(DBusPendingCall *pending, void
DBusHandlerResult QMafwWatchletVolumeControl::handleDBusSignal(DBusConnection *connection, DBusMessage *message, void *user_data)
{
QMafwWatchletVolumeControl *self = static_cast<QMafwWatchletVolumeControl*>(user_data);
+ Q_UNUSED(connection);
if (dbus_message_is_signal(message, VOLUME_IF, "StepsUpdated")) {
DBusError err;
quint32 curStep, maxStep;
@@ -238,14 +255,18 @@ DBusHandlerResult QMafwWatchletVolumeControl::handleDBusSignal(DBusConnection *c
DBUS_TYPE_UINT32, &maxStep,
DBUS_TYPE_UINT32, &curStep,
DBUS_TYPE_INVALID)) {
- if (self->_maxStep != maxStep) {
+ if (self->_maxStep != static_cast<int>(maxStep)) {
self->_maxStep = maxStep;
emit self->maxChanged();
}
- if (self->_curStep != curStep) {
+ if (self->_curStep != static_cast<int>(curStep)) {
self->_curStep = curStep;
emit self->volumeChanged();
}
}
+
+ return DBUS_HANDLER_RESULT_HANDLED;
}
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
diff --git a/qmafwwatchlet/qmafwwatchletvolumecontrol.h b/qmafwwatchlet/qmafwwatchletvolumecontrol.h
index 1e1261a..75b313a 100644
--- a/qmafwwatchlet/qmafwwatchletvolumecontrol.h
+++ b/qmafwwatchlet/qmafwwatchletvolumecontrol.h
@@ -44,8 +44,8 @@ private:
private:
DBusConnection *_conn;
- uint _curStep;
- uint _maxStep;
+ int _curStep;
+ int _maxStep;
};
}
diff --git a/sowatch.pro b/sowatch.pro
index 3a0e025..7f89e81 100644
--- a/sowatch.pro
+++ b/sowatch.pro
@@ -15,7 +15,7 @@ sysinfowatchlet.depends = libsowatch
qmsgwatchlet.depends = libsowatch
qmapwatchlet.depends = libsowatch
-# Less useful watchlets
+# Toy watchlets
SUBDIRS += nekowatchlet
nekowatchlet.depends = libsowatch
@@ -30,14 +30,14 @@ unix {
contains(MEEGO_EDITION,harmattan) {
# Harmattan specific stuff
SUBDIRS += meegohandsetnotification ckitcallnotification harmaccuweather
- SUBDIRS += qmafwwatchlet
SUBDIRS += meecastweather
+ SUBDIRS += qmafwwatchlet
meegohandsetnotification.depends = libsowatch
ckitcallnotification.depends = libsowatch
harmaccuweather.depends = libsowatch
- qmafwwatchlet.depends = libsowatch
meecastweather.depends = libsowatch
+ qmafwwatchlet.depends = libsowatch
} else:simulator {
# This notification provider builds almost everywhere so it's good enough as testcase
SUBDIRS += harmaccuweather