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 --- ckitcallnotification/ckitcallnotification.pro | 11 +- harmaccuweather/harmaccuweather.pro | 13 +- libsowatch/libsowatch.pro | 12 +- libsowatch/sowatch_global.h | 13 +- .../meegohandsetnotification.pro | 15 +- metawatch/metawatch.pro | 5 +- notificationswatchlet/notificationswatchlet.pro | 33 +--- qmafwwatchlet/qmafwwatchlet.pro | 11 +- qmapwatchlet/qmapwatchlet.pro | 21 +-- qtc_packaging/debian_harmattan/manifest.aegis | 2 +- sowatch.pro | 4 + ...ispedro.sowatch.service.sowatch-service.service | 3 + sowatchd/daemon.h | 2 +- sowatchd/global.h | 11 ++ sowatchd/main.cpp | 69 ++++++- sowatchd/service.cpp | 15 ++ sowatchd/service.h | 26 +++ sowatchd/service.xml | 14 ++ sowatchd/sowatchd.pro | 23 ++- sowatchui/main.cpp | 14 ++ sowatchui/qml/MainPage.qml | 9 + sowatchui/qml/ServiceLoader.qml | 7 + sowatchui/qml/main.qml | 43 +++++ sowatchui/qml/sowatch.js | 29 +++ .../qmlapplicationviewer/qmlapplicationviewer.cpp | 200 +++++++++++++++++++++ .../qmlapplicationviewer/qmlapplicationviewer.h | 47 +++++ .../qmlapplicationviewer/qmlapplicationviewer.pri | 146 +++++++++++++++ sowatchui/sowatch.desktop | 11 ++ sowatchui/sowatch.svg | 93 ++++++++++ sowatchui/sowatch64.png | Bin 0 -> 3400 bytes sowatchui/sowatch80.png | Bin 0 -> 4945 bytes sowatchui/sowatch_harmattan.desktop | 11 ++ sowatchui/sowatchui.pro | 48 +++++ sysinfowatchlet/sysinfowatchlet.pro | 5 +- 34 files changed, 851 insertions(+), 115 deletions(-) create mode 100644 sowatchd/com.javispedro.sowatch.service.sowatch-service.service create mode 100644 sowatchd/global.h create mode 100644 sowatchd/service.cpp create mode 100644 sowatchd/service.h create mode 100644 sowatchd/service.xml create mode 100644 sowatchui/main.cpp 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 create mode 100644 sowatchui/qmlapplicationviewer/qmlapplicationviewer.cpp create mode 100644 sowatchui/qmlapplicationviewer/qmlapplicationviewer.h create mode 100644 sowatchui/qmlapplicationviewer/qmlapplicationviewer.pri create mode 100644 sowatchui/sowatch.desktop create mode 100644 sowatchui/sowatch.svg create mode 100644 sowatchui/sowatch64.png create mode 100644 sowatchui/sowatch80.png create mode 100644 sowatchui/sowatch_harmattan.desktop create mode 100644 sowatchui/sowatchui.pro diff --git a/ckitcallnotification/ckitcallnotification.pro b/ckitcallnotification/ckitcallnotification.pro index 2cee7f8..05b37eb 100644 --- a/ckitcallnotification/ckitcallnotification.pro +++ b/ckitcallnotification/ckitcallnotification.pro @@ -26,16 +26,11 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/notifications + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/notifications } else { target.path = /usr/lib/sowatch/notifications } INSTALLS += target } - - - - - - diff --git a/harmaccuweather/harmaccuweather.pro b/harmaccuweather/harmaccuweather.pro index 7c9bfe5..5a1facd 100644 --- a/harmaccuweather/harmaccuweather.pro +++ b/harmaccuweather/harmaccuweather.pro @@ -16,18 +16,11 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/notifications + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/notifications } else { target.path = /usr/lib/sowatch/notifications } INSTALLS += target } - - - - - - - - diff --git a/libsowatch/libsowatch.pro b/libsowatch/libsowatch.pro index cb77a17..6f657c8 100644 --- a/libsowatch/libsowatch.pro +++ b/libsowatch/libsowatch.pro @@ -29,7 +29,7 @@ SOURCES += \ watchletplugininterface.cpp \ registry.cpp -HEADERS +=\ +HEADERS += \ watchsimulator.h \ watchserver.h \ watchpaintengine.h \ @@ -62,10 +62,10 @@ symbian { unix:!symbian { install_headers.path = /usr/include/sowatch - maemo5 { - target.path = /opt/maemo/usr/lib - } else { - target.path = /usr/lib - } + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + target.path = /opt/sowatch/lib + } else { + target.path = /usr/lib + } INSTALLS += install_headers target } diff --git a/libsowatch/sowatch_global.h b/libsowatch/sowatch_global.h index 1afa590..c317ba4 100644 --- a/libsowatch/sowatch_global.h +++ b/libsowatch/sowatch_global.h @@ -2,17 +2,20 @@ #define SOWATCH_GLOBAL_H #include +#include #if defined(SOWATCH_LIBRARY) -# define SOWATCH_EXPORT Q_DECL_EXPORT +# define SOWATCH_EXPORT Q_DECL_EXPORT #else -# define SOWATCH_EXPORT Q_DECL_IMPORT +# define SOWATCH_EXPORT Q_DECL_IMPORT #endif -#if defined(Q_WS_MAEMO_5) -# define SOWATCH_PLUGINS_DIR "/opt/sowatch" +#if defined(MEEGO_VERSION_MAJOR) || defined(Q_WS_MAEMO_5) +# define SOWATCH_PLUGINS_DIR "/opt/sowatch/lib" #elif defined(Q_OS_LINUX) -# define SOWATCH_PLUGINS_DIR "/usr/lib/sowatch" +# define SOWATCH_PLUGINS_DIR "/usr/lib/sowatch" +#else +# error Please define a path for your platform #endif #define SOWATCH_DRIVERS_DIR SOWATCH_PLUGINS_DIR "/drivers" diff --git a/meegohandsetnotification/meegohandsetnotification.pro b/meegohandsetnotification/meegohandsetnotification.pro index 4921d03..ea87c2c 100644 --- a/meegohandsetnotification/meegohandsetnotification.pro +++ b/meegohandsetnotification/meegohandsetnotification.pro @@ -23,20 +23,11 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/notifications + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/notifications } else { target.path = /usr/lib/sowatch/notifications } INSTALLS += target } - - - - - - - - - - diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro index 3435bb5..f48cfe0 100644 --- a/metawatch/metawatch.pro +++ b/metawatch/metawatch.pro @@ -66,8 +66,9 @@ symbian { } unix:!symbian { - maemo5 { - target.path = /opt/sowatch/drivers + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/drivers } else { target.path = /usr/lib/sowatch/drivers } diff --git a/notificationswatchlet/notificationswatchlet.pro b/notificationswatchlet/notificationswatchlet.pro index f5e4ce8..e64a8d6 100644 --- a/notificationswatchlet/notificationswatchlet.pro +++ b/notificationswatchlet/notificationswatchlet.pro @@ -17,8 +17,9 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/watchlets + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/watchlets } else { target.path = /usr/lib/sowatch/watchlets } @@ -30,31 +31,3 @@ OTHER_FILES += \ RESOURCES += \ notificationswatchlet.qrc - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/qmafwwatchlet/qmafwwatchlet.pro b/qmafwwatchlet/qmafwwatchlet.pro index 2f8db66..2e22b4b 100644 --- a/qmafwwatchlet/qmafwwatchlet.pro +++ b/qmafwwatchlet/qmafwwatchlet.pro @@ -18,8 +18,9 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/watchlets + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/watchlets } else { target.path = /usr/lib/sowatch/watchlets } @@ -31,9 +32,3 @@ OTHER_FILES += \ RESOURCES += \ qmafwwatchlet.qrc - - - - - - diff --git a/qmapwatchlet/qmapwatchlet.pro b/qmapwatchlet/qmapwatchlet.pro index da5cf6f..5e5fb81 100644 --- a/qmapwatchlet/qmapwatchlet.pro +++ b/qmapwatchlet/qmapwatchlet.pro @@ -17,8 +17,9 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/watchlets + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/watchlets } else { target.path = /usr/lib/sowatch/watchlets } @@ -30,19 +31,3 @@ OTHER_FILES += \ RESOURCES += \ qmapwatchlet.qrc - - - - - - - - - - - - - - - - diff --git a/qtc_packaging/debian_harmattan/manifest.aegis b/qtc_packaging/debian_harmattan/manifest.aegis index 480b230..180419e 100644 --- a/qtc_packaging/debian_harmattan/manifest.aegis +++ b/qtc_packaging/debian_harmattan/manifest.aegis @@ -4,6 +4,6 @@ - + diff --git a/sowatch.pro b/sowatch.pro index 367bd36..6c03912 100644 --- a/sowatch.pro +++ b/sowatch.pro @@ -2,6 +2,7 @@ TEMPLATE = subdirs SUBDIRS = libsowatch \ metawatch \ sowatchd \ + sowatchui \ notificationswatchlet \ sysinfowatchlet @@ -46,3 +47,6 @@ OTHER_FILES += \ + + + diff --git a/sowatchd/com.javispedro.sowatch.service.sowatch-service.service b/sowatchd/com.javispedro.sowatch.service.sowatch-service.service new file mode 100644 index 0000000..714d1c4 --- /dev/null +++ b/sowatchd/com.javispedro.sowatch.service.sowatch-service.service @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.nokia.qtmobility.sfw.sowatch-service +Exec=/opt/sowatch/bin/sowatchd diff --git a/sowatchd/daemon.h b/sowatchd/daemon.h index 48125fb..249f525 100644 --- a/sowatchd/daemon.h +++ b/sowatchd/daemon.h @@ -13,7 +13,7 @@ namespace sowatch class Daemon : public QObject { - Q_OBJECT + Q_OBJECT public: explicit Daemon(QObject *parent = 0); diff --git a/sowatchd/global.h b/sowatchd/global.h new file mode 100644 index 0000000..45c2b13 --- /dev/null +++ b/sowatchd/global.h @@ -0,0 +1,11 @@ +#ifndef GLOBAL_H +#define GLOBAL_H + +#include "daemon.h" + +namespace sowatch +{ +extern sowatch::Daemon* daemon; +} + +#endif // GLOBAL_H diff --git a/sowatchd/main.cpp b/sowatchd/main.cpp index 0d7abb9..22e63a2 100644 --- a/sowatchd/main.cpp +++ b/sowatchd/main.cpp @@ -1,20 +1,79 @@ #include +#include +#include #include -#include "daemon.h" +#include "global.h" +#include "service.h" + +namespace sowatch +{ + Daemon* daemon; +} using namespace sowatch; +QTM_USE_NAMESPACE + + +static QString adjustPath(const QString &path) +{ +#ifdef Q_OS_UNIX +#ifdef Q_OS_MAC + if (!QDir::isAbsolutePath(path)) + return QCoreApplication::applicationDirPath() + + QLatin1String("/../Resources/") + path; +#else + QString pathInInstallDir; + const QString applicationDirPath = QCoreApplication::applicationDirPath(); + pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); + + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; +#endif +#endif + return path; +} + +static void unregisterService() +{ + QServiceManager m; + m.removeService("sowatch-service"); +} -static Daemon* d; +static void registerService() +{ + unregisterService(); + QServiceManager m; + QString path = adjustPath("xml/service.xml"); + if (!m.addService(path)) { + qWarning() << "Cannot register sowatch-service" << m.error() << "from" << path; + } +} int main(int argc, char *argv[]) { - QApplication a(argc, argv); + QApplication a(argc, argv); // Some plugins might require a UI. QApplication::setOrganizationDomain("com.javispedro.sowatch"); QApplication::setOrganizationName("sowatch"); QApplication::setApplicationName("sowatchd"); - d = new Daemon(); + sowatch::daemon = new Daemon(); + + registerService(); + + QRemoteServiceRegister *serviceRegister = new QRemoteServiceRegister(); + QRemoteServiceRegister::Entry entry = + serviceRegister->createEntry("sowatch-service", + "com.javispedro.sowatch.service", "1.0"); + entry.setInstantiationType(QRemoteServiceRegister::PrivateInstance); + + serviceRegister->setQuitOnLastInstanceClosed(false); + serviceRegister->publishEntries("sowatchd"); + + int res = a.exec(); + + delete serviceRegister; + delete sowatch::daemon; - return a.exec(); + return res; } diff --git a/sowatchd/service.cpp b/sowatchd/service.cpp new file mode 100644 index 0000000..0b3777c --- /dev/null +++ b/sowatchd/service.cpp @@ -0,0 +1,15 @@ +#include "global.h" +#include "service.h" + +using namespace sowatch; + +Service::Service(QObject *parent) : + QObject(parent) +{ + +} + +void Service::terminate() +{ + QCoreApplication::exit(0); +} diff --git a/sowatchd/service.h b/sowatchd/service.h new file mode 100644 index 0000000..797dc3d --- /dev/null +++ b/sowatchd/service.h @@ -0,0 +1,26 @@ +#ifndef SERVICE_H +#define SERVICE_H + +#include +#include +#include + +#include + +namespace sowatch +{ + +class Service : public QObject +{ + Q_OBJECT +public: + explicit Service(QObject *parent = 0); + +public slots: + void terminate(); + +}; + +} + +#endif // SERVICE_H diff --git a/sowatchd/service.xml b/sowatchd/service.xml new file mode 100644 index 0000000..b2ebc06 --- /dev/null +++ b/sowatchd/service.xml @@ -0,0 +1,14 @@ + + + + sowatch-service + sowatchd + Sowatch Service + + com.javispedro.sowatch.service + 1.0 + + + + + diff --git a/sowatchd/sowatchd.pro b/sowatchd/sowatchd.pro index 1e02404..af13c9e 100644 --- a/sowatchd/sowatchd.pro +++ b/sowatchd/sowatchd.pro @@ -9,11 +9,13 @@ TEMPLATE = app TARGET = sowatchd QT += core gui -CONFIG += console +CONFIG += mobility CONFIG -= app_bundle +MOBILITY += serviceframework SOURCES += main.cpp \ - daemon.cpp + daemon.cpp \ + service.cpp win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/release/ -lsowatch else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/debug/ -lsowatch @@ -24,8 +26,9 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix { - maemo5 { - target.path = /opt/sowatch + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/bin } else { target.path = /usr/bin } @@ -33,6 +36,12 @@ unix { } HEADERS += \ - daemon.h - - + daemon.h \ + service.h \ + global.h + +xml.path = /opt/sowatch/xml +xml.files = service.xml +dbus.path = /usr/share/dbus-1/services +dbus.files = com.javispedro.sowatch.service.sowatch-service.service +INSTALLS += xml dbus diff --git a/sowatchui/main.cpp b/sowatchui/main.cpp new file mode 100644 index 0000000..54a65fa --- /dev/null +++ b/sowatchui/main.cpp @@ -0,0 +1,14 @@ +#include +#include "qmlapplicationviewer.h" + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QScopedPointer app(createApplication(argc, argv)); + QScopedPointer viewer(QmlApplicationViewer::create()); + + viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); + viewer->setMainQmlFile(QLatin1String("qml/main.qml")); + viewer->showExpanded(); + + return app->exec(); +} 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(); +} diff --git a/sowatchui/qmlapplicationviewer/qmlapplicationviewer.cpp b/sowatchui/qmlapplicationviewer/qmlapplicationviewer.cpp new file mode 100644 index 0000000..8ba6e88 --- /dev/null +++ b/sowatchui/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -0,0 +1,200 @@ +// checksum 0x78c version 0x60010 +/* + This file was generated by the Qt Quick Application wizard of Qt Creator. + QmlApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#include "qmlapplicationviewer.h" + +#include +#include +#include +#include +#include +#include + +#include // MEEGO_EDITION_HARMATTAN + +#ifdef HARMATTAN_BOOSTER +#include +#endif + +#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 + +#include + +#if !defined(NO_JSDEBUGGER) +#include +#endif +#if !defined(NO_QMLOBSERVER) +#include +#endif + +// Enable debugging before any QDeclarativeEngine is created +struct QmlJsDebuggingEnabler +{ + QmlJsDebuggingEnabler() + { + QDeclarativeDebugHelper::enableDebugging(); + } +}; + +// Execute code in constructor before first QDeclarativeEngine is instantiated +static QmlJsDebuggingEnabler enableDebuggingHelper; + +#endif // QMLJSDEBUGGER + +class QmlApplicationViewerPrivate +{ + QmlApplicationViewerPrivate(QDeclarativeView *view_) : view(view_) {} + + QString mainQmlFile; + QDeclarativeView *view; + friend class QmlApplicationViewer; + QString adjustPath(const QString &path); +}; + +QString QmlApplicationViewerPrivate::adjustPath(const QString &path) +{ +#ifdef Q_OS_UNIX +#ifdef Q_OS_MAC + if (!QDir::isAbsolutePath(path)) + return QCoreApplication::applicationDirPath() + + QLatin1String("/../Resources/") + path; +#else + QString pathInInstallDir; + const QString applicationDirPath = QCoreApplication::applicationDirPath(); + pathInInstallDir = QString::fromAscii("%1/../%2").arg(applicationDirPath, path); + + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; +#endif +#endif + return path; +} + +QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) + : QDeclarativeView(parent) + , d(new QmlApplicationViewerPrivate(this)) +{ + connect(engine(), SIGNAL(quit()), SLOT(close())); + setResizeMode(QDeclarativeView::SizeRootObjectToView); + // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in +#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 +#if !defined(NO_JSDEBUGGER) + new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); +#endif +#if !defined(NO_QMLOBSERVER) + new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); +#endif +#endif +} + +QmlApplicationViewer::QmlApplicationViewer(QDeclarativeView *view, QWidget *parent) + : QDeclarativeView(parent) + , d(new QmlApplicationViewerPrivate(view)) +{ + connect(view->engine(), SIGNAL(quit()), view, SLOT(close())); + view->setResizeMode(QDeclarativeView::SizeRootObjectToView); + // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in +#if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 +#if !defined(NO_JSDEBUGGER) + new QmlJSDebugger::JSDebuggerAgent(d->view->engine()); +#endif +#if !defined(NO_QMLOBSERVER) + new QmlJSDebugger::QDeclarativeViewObserver(d->view, d->view); +#endif +#endif +} + +QmlApplicationViewer::~QmlApplicationViewer() +{ + delete d; +} + +QmlApplicationViewer *QmlApplicationViewer::create() +{ +#ifdef HARMATTAN_BOOSTER + return new QmlApplicationViewer(MDeclarativeCache::qDeclarativeView(), 0); +#else + return new QmlApplicationViewer(); +#endif +} + +void QmlApplicationViewer::setMainQmlFile(const QString &file) +{ + d->mainQmlFile = d->adjustPath(file); + d->view->setSource(QUrl::fromLocalFile(d->mainQmlFile)); +} + +void QmlApplicationViewer::addImportPath(const QString &path) +{ + d->view->engine()->addImportPath(d->adjustPath(path)); +} + +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#if defined(Q_OS_SYMBIAN) + // If the version of Qt on the device is < 4.7.2, that attribute won't work + if (orientation != ScreenOrientationAuto) { + const QStringList v = QString::fromAscii(qVersion()).split(QLatin1Char('.')); + if (v.count() == 3 && (v.at(0).toInt() << 16 | v.at(1).toInt() << 8 | v.at(2).toInt()) < 0x040702) { + qWarning("Screen orientation locking only supported with Qt 4.7.2 and above"); + return; + } + } +#endif // Q_OS_SYMBIAN + + Qt::WidgetAttribute attribute; + switch (orientation) { +#if QT_VERSION < 0x040702 + // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes + case ScreenOrientationLockPortrait: + attribute = static_cast(128); + break; + case ScreenOrientationLockLandscape: + attribute = static_cast(129); + break; + default: + case ScreenOrientationAuto: + attribute = static_cast(130); + break; +#else // QT_VERSION < 0x040702 + case ScreenOrientationLockPortrait: + attribute = Qt::WA_LockPortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_LockLandscapeOrientation; + break; + default: + case ScreenOrientationAuto: + attribute = Qt::WA_AutoOrientation; + break; +#endif // QT_VERSION < 0x040702 + }; + setAttribute(attribute, true); +} + +void QmlApplicationViewer::showExpanded() +{ +#if defined(Q_OS_SYMBIAN) || defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) + d->view->showFullScreen(); +#elif defined(Q_WS_MAEMO_5) + d->view->showMaximized(); +#else + d->view->show(); +#endif +} + +QApplication *createApplication(int &argc, char **argv) +{ +#ifdef HARMATTAN_BOOSTER + return MDeclarativeCache::qApplication(argc, argv); +#else + return new QApplication(argc, argv); +#endif +} diff --git a/sowatchui/qmlapplicationviewer/qmlapplicationviewer.h b/sowatchui/qmlapplicationviewer/qmlapplicationviewer.h new file mode 100644 index 0000000..f8008f5 --- /dev/null +++ b/sowatchui/qmlapplicationviewer/qmlapplicationviewer.h @@ -0,0 +1,47 @@ +// checksum 0x82ed version 0x60010 +/* + This file was generated by the Qt Quick Application wizard of Qt Creator. + QmlApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#ifndef QMLAPPLICATIONVIEWER_H +#define QMLAPPLICATIONVIEWER_H + +#include + +class QmlApplicationViewer : public QDeclarativeView +{ + Q_OBJECT + +public: + enum ScreenOrientation { + ScreenOrientationLockPortrait, + ScreenOrientationLockLandscape, + ScreenOrientationAuto + }; + + explicit QmlApplicationViewer(QWidget *parent = 0); + virtual ~QmlApplicationViewer(); + + static QmlApplicationViewer *create(); + + void setMainQmlFile(const QString &file); + void addImportPath(const QString &path); + + // Note that this will only have an effect on Symbian and Fremantle. + void setOrientation(ScreenOrientation orientation); + + void showExpanded(); + +private: + explicit QmlApplicationViewer(QDeclarativeView *view, QWidget *parent); + class QmlApplicationViewerPrivate *d; +}; + +QApplication *createApplication(int &argc, char **argv); + +#endif // QMLAPPLICATIONVIEWER_H diff --git a/sowatchui/qmlapplicationviewer/qmlapplicationviewer.pri b/sowatchui/qmlapplicationviewer/qmlapplicationviewer.pri new file mode 100644 index 0000000..57842a7 --- /dev/null +++ b/sowatchui/qmlapplicationviewer/qmlapplicationviewer.pri @@ -0,0 +1,146 @@ +# checksum 0x368d version 0x60010 +# This file was generated by the Qt Quick Application wizard of Qt Creator. +# The code below adds the QmlApplicationViewer to the project and handles the +# activation of QML debugging. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +QT += declarative + +SOURCES += $$PWD/qmlapplicationviewer.cpp +HEADERS += $$PWD/qmlapplicationviewer.h +INCLUDEPATH += $$PWD + +# Include JS debugger library if QMLJSDEBUGGER_PATH is set +!isEmpty(QMLJSDEBUGGER_PATH) { + include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) +} else { + DEFINES -= QMLJSDEBUGGER +} + +contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { + DEFINES += HARMATTAN_BOOSTER +} +# This file was generated by an application wizard of Qt Creator. +# The code below handles deployment to Symbian and Maemo, aswell as copying +# of the application data to shadow build directories on desktop. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +defineTest(qtcAddDeployment) { +for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemsources = $${item}.sources + $$itemsources = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath= $$eval($${deploymentfolder}.target) + export($$itemsources) + export($$itempath) + DEPLOYMENT += $$item +} + +MAINPROFILEPWD = $$PWD + +symbian { + isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg + isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} else:win32 { + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, /, \\) + sourcePathSegments = $$split(source, \\) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) + target = $$replace(target, /, \\) + !isEqual(source,$$target) { + !isEmpty(copyCommand):copyCommand += && + isEqual(QMAKE_DIR_SEP, \\) { + copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" + } else { + source = $$replace(source, \\\\, /) + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + target = $$replace(target, \\\\, /) + copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" + } + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } +} else:unix { + maemo5 { + desktopfile.files = $${TARGET}.desktop + desktopfile.path = /usr/share/applications/hildon + icon.files = $${TARGET}64.png + icon.path = /usr/share/icons/hicolor/64x64/apps + } else:!isEmpty(MEEGO_VERSION_MAJOR) { + desktopfile.files = $${TARGET}_harmattan.desktop + desktopfile.path = /usr/share/applications + icon.files = $${TARGET}80.png + icon.path = /usr/share/icons/hicolor/80x80/apps + } else { # Assumed to be a Desktop Unix + copyCommand = + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) + source = $$replace(source, \\\\, /) + macx { + target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) + } else { + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + } + target = $$replace(target, \\\\, /) + sourcePathSegments = $$split(source, /) + targetFullPath = $$target/$$last(sourcePathSegments) + !isEqual(source,$$targetFullPath) { + !isEmpty(copyCommand):copyCommand += && + copyCommand += $(MKDIR) \"$$target\" + copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" + } + } + !isEmpty(copyCommand) { + copyCommand = @echo Copying application data... && $$copyCommand + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } + } + installPrefix = /opt/$${TARGET} + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + + !isEmpty(desktopfile.path) { + export(icon.files) + export(icon.path) + export(desktopfile.files) + export(desktopfile.path) + INSTALLS += icon desktopfile + } + + target.path = $${installPrefix}/bin + export(target.path) + INSTALLS += target +} + +export (ICON) +export (INSTALLS) +export (DEPLOYMENT) +export (TARGET.EPOCHEAPSIZE) +export (TARGET.CAPABILITY) +export (LIBS) +export (QMAKE_EXTRA_TARGETS) +} diff --git a/sowatchui/sowatch.desktop b/sowatchui/sowatch.desktop new file mode 100644 index 0000000..d1e799d --- /dev/null +++ b/sowatchui/sowatch.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Sowatch +Exec=/opt/sowatch/bin/sowatch +Icon=sowatch64 +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/sowatchui/sowatch.svg b/sowatchui/sowatch.svg new file mode 100644 index 0000000..566acfa --- /dev/null +++ b/sowatchui/sowatch.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/sowatchui/sowatch64.png b/sowatchui/sowatch64.png new file mode 100644 index 0000000..707d5c4 Binary files /dev/null and b/sowatchui/sowatch64.png differ diff --git a/sowatchui/sowatch80.png b/sowatchui/sowatch80.png new file mode 100644 index 0000000..6ad8096 Binary files /dev/null and b/sowatchui/sowatch80.png differ diff --git a/sowatchui/sowatch_harmattan.desktop b/sowatchui/sowatch_harmattan.desktop new file mode 100644 index 0000000..64383b1 --- /dev/null +++ b/sowatchui/sowatch_harmattan.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=Sowatch +Exec=/usr/bin/invoker --type=d -s /opt/sowatch/bin/sowatch +Icon=/usr/share/icons/hicolor/80x80/apps/sowatch80.png +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/sowatchui/sowatchui.pro b/sowatchui/sowatchui.pro new file mode 100644 index 0000000..297e394 --- /dev/null +++ b/sowatchui/sowatchui.pro @@ -0,0 +1,48 @@ +TARGET=sowatch + +# Add more folders to ship with the application, here +qml_folder.source = qml +qml_folder.target = . +DEPLOYMENTFOLDERS = qml_folder + +# Additional import path used to resolve QML modules in Creator's code model +QML_IMPORT_PATH = + +symbian:TARGET.UID3 = 0xE5EBE65C + +# Smart Installer package's UID +# This UID is from the protected range and therefore the package will +# fail to install if self-signed. By default qmake uses the unprotected +# range value if unprotected UID is defined for the application and +# 0x2002CCCF value if protected UID is given to the application +#symbian:DEPLOYMENT.installer_header = 0x2002CCCF + +# Allow network access on Symbian +symbian:TARGET.CAPABILITY += NetworkServices + +# If your application uses the Qt Mobility libraries, uncomment the following +# lines and add the respective components to the MOBILITY variable. +CONFIG += mobility +MOBILITY += serviceframework + +# Speed up launching on MeeGo/Harmattan when using applauncherd daemon +CONFIG += qdeclarative-boostable + +# Add dependency to Symbian components +# CONFIG += qt-components + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() + +OTHER_FILES += \ + qml/MainPage.qml \ + qml/main.qml \ + sowatch_harmattan.desktop \ + sowatch.desktop + + + diff --git a/sysinfowatchlet/sysinfowatchlet.pro b/sysinfowatchlet/sysinfowatchlet.pro index ebbaf9c..129bbc9 100644 --- a/sysinfowatchlet/sysinfowatchlet.pro +++ b/sysinfowatchlet/sysinfowatchlet.pro @@ -24,8 +24,9 @@ INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch unix:!symbian { - maemo5 { - target.path = /opt/sowatch/watchlets + !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { + QMAKE_RPATHDIR += /opt/sowatch/lib + target.path = /opt/sowatch/lib/watchlets } else { target.path = /usr/lib/sowatch/watchlets } -- cgit v1.2.3