summaryrefslogtreecommitdiff
path: root/sysinfowatchlet/sysinfowatchlet.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-25 04:53:46 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-25 04:53:46 +0200
commitcf5d24b94d96b722c6d76c2225293a56a50d3c2b (patch)
treefece0c539fe4c40e1faae109f53c46ddc5b0d222 /sysinfowatchlet/sysinfowatchlet.cpp
parent2b4e878938215ac743bdc36deace4c2a4cb0c7a2 (diff)
downloadsowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.tar.gz
sowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.zip
watchlets working!
Diffstat (limited to 'sysinfowatchlet/sysinfowatchlet.cpp')
-rw-r--r--sysinfowatchlet/sysinfowatchlet.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/sysinfowatchlet/sysinfowatchlet.cpp b/sysinfowatchlet/sysinfowatchlet.cpp
new file mode 100644
index 0000000..c9f44c2
--- /dev/null
+++ b/sysinfowatchlet/sysinfowatchlet.cpp
@@ -0,0 +1,26 @@
+#include "sysinfowatchlet.h"
+
+using namespace sowatch;
+QTM_USE_NAMESPACE
+
+SysInfoWatchlet::SysInfoWatchlet(WatchServer* server) :
+ DeclarativeWatchlet(server, "com.javispedro.sowatch.sysinfo"),
+ _devInfo(new QSystemDeviceInfo(this)),
+ _netMgr(new QNetworkConfigurationManager(this))
+{
+ rootContext()->setContextProperty("batteryLevel", 0);
+ rootContext()->setContextProperty("networkName", "");
+ setSource(QUrl("qrc:/sysinfowatchlet/" + server->watch()->model() + ".qml"));
+ connect(this, SIGNAL(activated()), SLOT(handleActivated()));
+}
+
+void SysInfoWatchlet::handleActivated()
+{
+ QList<QNetworkConfiguration> cfgs = _netMgr->allConfigurations(QNetworkConfiguration::Active);
+ rootContext()->setContextProperty("batteryLevel", _devInfo->batteryLevel());
+ if (cfgs.size() > 0) {
+ rootContext()->setContextProperty("networkName", cfgs[0].name());
+ } else {
+ rootContext()->setContextProperty("networkName", "");
+ }
+}