summaryrefslogtreecommitdiff
path: root/sysinfowatchlet
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
parent2b4e878938215ac743bdc36deace4c2a4cb0c7a2 (diff)
downloadsowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.tar.gz
sowatch-cf5d24b94d96b722c6d76c2225293a56a50d3c2b.zip
watchlets working!
Diffstat (limited to 'sysinfowatchlet')
-rw-r--r--sysinfowatchlet/metawatch-digital.qml46
-rw-r--r--sysinfowatchlet/sysinfoplugin.cpp29
-rw-r--r--sysinfowatchlet/sysinfoplugin.h24
-rw-r--r--sysinfowatchlet/sysinfowatchlet.cpp26
-rw-r--r--sysinfowatchlet/sysinfowatchlet.h29
-rw-r--r--sysinfowatchlet/sysinfowatchlet.pro44
-rw-r--r--sysinfowatchlet/sysinfowatchlet.qrc5
7 files changed, 203 insertions, 0 deletions
diff --git a/sysinfowatchlet/metawatch-digital.qml b/sysinfowatchlet/metawatch-digital.qml
new file mode 100644
index 0000000..65e9a7d
--- /dev/null
+++ b/sysinfowatchlet/metawatch-digital.qml
@@ -0,0 +1,46 @@
+import QtQuick 1.0
+
+Rectangle {
+ width: 96
+ height: 96
+
+ color: "white"
+
+ Column {
+ anchors.fill: parent
+ spacing: 4
+
+ Text {
+ text: "Battery: " + batteryLevel + "%"
+ }
+
+ Rectangle {
+ id: battery
+ x: 12
+ width: 72
+ height: 16
+
+ border.color: "black"
+ border.width: 1
+
+ Rectangle {
+ width: (batteryLevel / 100) * parent.width
+ height: parent.height
+
+ color: "black"
+ }
+ }
+
+ Text {
+ width: parent.width
+ text: "Connected to:"
+ }
+
+ Text {
+ width: parent.width
+ text: networkName
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ }
+ }
+}
diff --git a/sysinfowatchlet/sysinfoplugin.cpp b/sysinfowatchlet/sysinfoplugin.cpp
new file mode 100644
index 0000000..fc862c0
--- /dev/null
+++ b/sysinfowatchlet/sysinfoplugin.cpp
@@ -0,0 +1,29 @@
+#include "sysinfowatchlet.h"
+#include "sysinfoplugin.h"
+
+using namespace sowatch;
+
+SysInfoPlugin::SysInfoPlugin(QObject *parent) :
+ QObject(parent)
+{
+}
+
+SysInfoPlugin::~SysInfoPlugin()
+{
+}
+
+QStringList SysInfoPlugin::watchlets()
+{
+ QStringList l;
+ l << "com.javispedro.sowatch.sysinfo";
+ return l;
+}
+
+Watchlet* SysInfoPlugin::getWatchlet(const QString& driver, QSettings& settings, WatchServer *server)
+{
+ Q_UNUSED(driver);
+ Q_UNUSED(settings);
+ return new SysInfoWatchlet(server);
+}
+
+Q_EXPORT_PLUGIN2(sysinfowatchlet, SysInfoPlugin)
diff --git a/sysinfowatchlet/sysinfoplugin.h b/sysinfowatchlet/sysinfoplugin.h
new file mode 100644
index 0000000..4e24b9e
--- /dev/null
+++ b/sysinfowatchlet/sysinfoplugin.h
@@ -0,0 +1,24 @@
+#ifndef CKITCALLPLUGIN_H
+#define CKITCALLPLUGIN_H
+
+#include <sowatch.h>
+
+namespace sowatch
+{
+
+class SysInfoPlugin : public QObject, public WatchletPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(sowatch::WatchletPluginInterface)
+
+public:
+ SysInfoPlugin(QObject *parent = 0);
+ ~SysInfoPlugin();
+
+ QStringList watchlets();
+ Watchlet* getWatchlet(const QString& driver, QSettings& settings, WatchServer* server);
+};
+
+}
+
+#endif // CKITCALLPLUGIN_H
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", "");
+ }
+}
diff --git a/sysinfowatchlet/sysinfowatchlet.h b/sysinfowatchlet/sysinfowatchlet.h
new file mode 100644
index 0000000..25d8f57
--- /dev/null
+++ b/sysinfowatchlet/sysinfowatchlet.h
@@ -0,0 +1,29 @@
+#ifndef SOWATCH_TESTDECLARATIVEWATCHLET_H
+#define SOWATCH_TESTDECLARATIVEWATCHLET_H
+
+#include <QtSystemInfo/QSystemDeviceInfo>
+#include <QtNetwork/QNetworkConfigurationManager>
+#include <sowatch.h>
+
+using QTM_PREPEND_NAMESPACE(QSystemDeviceInfo);
+
+namespace sowatch
+{
+
+class SysInfoWatchlet : public DeclarativeWatchlet
+{
+ Q_OBJECT
+public:
+ explicit SysInfoWatchlet(WatchServer* server);
+
+private slots:
+ void handleActivated();
+
+private:
+ QSystemDeviceInfo *_devInfo;
+ QNetworkConfigurationManager *_netMgr;
+};
+
+}
+
+#endif // SOWATCH_TESTDECLARATIVEWATCHLET_H
diff --git a/sysinfowatchlet/sysinfowatchlet.pro b/sysinfowatchlet/sysinfowatchlet.pro
new file mode 100644
index 0000000..8c87ad8
--- /dev/null
+++ b/sysinfowatchlet/sysinfowatchlet.pro
@@ -0,0 +1,44 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-09-24T00:00:03
+#
+#-------------------------------------------------
+
+TARGET = sysinfowatchlet
+TEMPLATE = lib
+# CONFIG += plugin # Stupid Qt creator doesn't want to deploy plugins
+QT += network
+CONFIG += mobility
+MOBILITY += systeminfo
+
+SOURCES += sysinfoplugin.cpp sysinfowatchlet.cpp
+
+HEADERS += sysinfoplugin.h sysinfowatchlet.h
+
+unix: LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch
+
+INCLUDEPATH += $$PWD/../libsowatch
+DEPENDPATH += $$PWD/../libsowatch
+
+unix:!symbian {
+ maemo5 {
+ target.path = /opt/sowatch/watchlets
+ } else {
+ target.path = /usr/lib/sowatch/watchlets
+ }
+ INSTALLS += target
+}
+
+OTHER_FILES += \
+ metawatch-digital.qml
+
+RESOURCES += \
+ sysinfowatchlet.qrc
+
+
+
+
+
+
+
+
diff --git a/sysinfowatchlet/sysinfowatchlet.qrc b/sysinfowatchlet/sysinfowatchlet.qrc
new file mode 100644
index 0000000..62142b0
--- /dev/null
+++ b/sysinfowatchlet/sysinfowatchlet.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/sysinfowatchlet">
+ <file>metawatch-digital.qml</file>
+ </qresource>
+</RCC>