summaryrefslogtreecommitdiff
path: root/sysinfowatchlet/sysinfowatchlet.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-01-04 03:46:45 +0100
committerJavier S. Pedro <maemo@javispedro.com>2012-01-04 03:46:45 +0100
commit1b0c6d90209460dd81628f4d9c028f91f596e46c (patch)
tree25b818c1b8c609142c298255eb9db30693910830 /sysinfowatchlet/sysinfowatchlet.cpp
parent2399bbe45bfa5a330bef2d4bb63de3af25fe4ad9 (diff)
downloadsowatch-1b0c6d90209460dd81628f4d9c028f91f596e46c.tar.gz
sowatch-1b0c6d90209460dd81628f4d9c028f91f596e46c.zip
make sysinfowatchlet selfupdate
Diffstat (limited to 'sysinfowatchlet/sysinfowatchlet.cpp')
-rw-r--r--sysinfowatchlet/sysinfowatchlet.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/sysinfowatchlet/sysinfowatchlet.cpp b/sysinfowatchlet/sysinfowatchlet.cpp
index 46d45e7..e159fc7 100644
--- a/sysinfowatchlet/sysinfowatchlet.cpp
+++ b/sysinfowatchlet/sysinfowatchlet.cpp
@@ -1,3 +1,5 @@
+#include <QtDebug>
+
#include "sysinfowatchlet.h"
using namespace sowatch;
@@ -12,12 +14,28 @@ SysInfoWatchlet::SysInfoWatchlet(WatchServer* server) :
rootContext()->setContextProperty("networkName", "");
setSource(QUrl(SOWATCH_QML_DIR "/sysinfowatchlet/" + server->watch()->model() + ".qml"));
connect(this, SIGNAL(activated()), SLOT(handleActivated()));
+ connect(this, SIGNAL(deactivated()), SLOT(handleDeactivated()));
}
void SysInfoWatchlet::handleActivated()
{
+ updateInformation();
+ connect(_devInfo, SIGNAL(batteryLevelChanged(int)), this, SLOT(updateInformation()));
+ connect(_netMgr, SIGNAL(onlineStateChanged(bool)), this, SLOT(updateInformation()));
+}
+
+void SysInfoWatchlet::handleDeactivated()
+{
+ disconnect(_devInfo, SIGNAL(batteryLevelChanged(int)), this, SLOT(updateInformation()));
+ disconnect(_netMgr, SIGNAL(onlineStateChanged(bool)), this, SLOT(updateInformation()));
+}
+
+void SysInfoWatchlet::updateInformation()
+{
QList<QNetworkConfiguration> cfgs = _netMgr->allConfigurations(QNetworkConfiguration::Active);
- rootContext()->setContextProperty("batteryLevel", _devInfo->batteryLevel());
+ int batteryLevel = _devInfo->batteryLevel();
+ qDebug() << "Updating system information (batteryLevel =" << batteryLevel << "%)";
+ rootContext()->setContextProperty("batteryLevel", batteryLevel);
if (cfgs.size() > 0) {
rootContext()->setContextProperty("networkName", cfgs[0].name());
} else {