From e8781ec2d43ec3f7f905e20fc76b1910e83ee0c8 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 17 Oct 2011 20:54:22 +0200 Subject: Major change: sowatchd is now a QtM service --- sowatchui/qml/MainPage.qml | 9 +++++++++ sowatchui/qml/ServiceLoader.qml | 7 +++++++ sowatchui/qml/main.qml | 43 +++++++++++++++++++++++++++++++++++++++++ sowatchui/qml/sowatch.js | 29 +++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 sowatchui/qml/MainPage.qml create mode 100644 sowatchui/qml/ServiceLoader.qml create mode 100644 sowatchui/qml/main.qml create mode 100644 sowatchui/qml/sowatch.js (limited to 'sowatchui/qml') diff --git a/sowatchui/qml/MainPage.qml b/sowatchui/qml/MainPage.qml new file mode 100644 index 0000000..45b72f3 --- /dev/null +++ b/sowatchui/qml/MainPage.qml @@ -0,0 +1,9 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +import "sowatch.js" as Sowatch + +Page { + tools: commonTools + +} diff --git a/sowatchui/qml/ServiceLoader.qml b/sowatchui/qml/ServiceLoader.qml new file mode 100644 index 0000000..8128ca7 --- /dev/null +++ b/sowatchui/qml/ServiceLoader.qml @@ -0,0 +1,7 @@ +import QtQuick 1.1 +import QtMobility.serviceframework 1.1 + +Service { + id: sowatch + interfaceName: "com.javispedro.sowatch.service" +} diff --git a/sowatchui/qml/main.qml b/sowatchui/qml/main.qml new file mode 100644 index 0000000..8697b6d --- /dev/null +++ b/sowatchui/qml/main.qml @@ -0,0 +1,43 @@ +import QtQuick 1.1 +import com.nokia.meego 1.0 + +import "sowatch.js" as Sowatch + +PageStackWindow { + id: appWindow + + initialPage: mainPage + + MainPage { + id: mainPage + } + + ToolBarLayout { + id: commonTools + visible: true + ToolIcon { + platformIconId: "toolbar-view-menu" + anchors.right: (parent === undefined) ? undefined : parent.right + onClicked: (myMenu.status == DialogStatus.Closed) ? myMenu.open() : myMenu.close() + } + } + + Menu { + id: myMenu + visualParent: pageStack + MenuLayout { + MenuItem { + text: qsTr("Start service") + onClicked: { + Sowatch.start(); + } + } + MenuItem { + text: qsTr("Stop service") + onClicked: { + Sowatch.stop(); + } + } + } + } +} diff --git a/sowatchui/qml/sowatch.js b/sowatchui/qml/sowatch.js new file mode 100644 index 0000000..f2d48dd --- /dev/null +++ b/sowatchui/qml/sowatch.js @@ -0,0 +1,29 @@ +var service = null; + +function getService() { + var component = Qt.createComponent("ServiceLoader.qml"); + if (component.status == Component.Ready) { + var loader = component.createObject(null); + service = loader.serviceObject; + } +} + +function checkService() { + if (service === null) { + getService(); + } +} + +function start() { + getService(); +} + +function stop() { + checkService(); + service.terminate(); +} + +function restart() { + stop(); + start(); +} -- cgit v1.2.3