From 6003bf81107dd9be51589c074b74c5af82bfc8ab Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Tue, 7 May 2013 01:37:21 +0200 Subject: testing qml notifications --- .../metawatch-digital-notification.qml | 81 ++++++++++++++++++++++ metawatchwatchlets/metawatch-digital-watchface.qml | 20 +----- .../metawatchnotificationwatchlet.cpp | 11 +++ metawatchwatchlets/metawatchnotificationwatchlet.h | 20 ++++++ metawatchwatchlets/metawatchwatchlets.pro | 8 ++- metawatchwatchlets/metawatchwatchletsplugin.cpp | 8 ++- 6 files changed, 126 insertions(+), 22 deletions(-) create mode 100644 metawatchwatchlets/metawatch-digital-notification.qml create mode 100644 metawatchwatchlets/metawatchnotificationwatchlet.cpp create mode 100644 metawatchwatchlets/metawatchnotificationwatchlet.h (limited to 'metawatchwatchlets') diff --git a/metawatchwatchlets/metawatch-digital-notification.qml b/metawatchwatchlets/metawatch-digital-notification.qml new file mode 100644 index 0000000..72f7bc9 --- /dev/null +++ b/metawatchwatchlets/metawatch-digital-notification.qml @@ -0,0 +1,81 @@ +import QtQuick 1.0 +import com.javispedro.sowatch 1.0 +import com.javispedro.sowatch.metawatch 1.0 + +MWPage { + id: page + + property QtObject curNotification: null; + + MWTitle { + id: title + } + + Item { + id: container + anchors.top: title.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + + Item { + id: emailContainer + visible: curNotification.type === Notification.EmailNotification + anchors.fill: parent + + MWLabel { + anchors.centerIn: parent + text: "Email" + } + } + + Item { + id: chatContainer + visible: curNotification.type === Notification.ImNotification + anchors.fill: parent + + MWLabel { + id: chatTitle + text: curNotification.title + } + + Image { + x: 20 + y: chatBubble.y - 8 + source: "bubble_tip.png" + z: 1 + } + + BorderImage { + id: chatBubble + anchors { + top: chatTitle.bottom; left: parent.left; right: parent.right; + leftMargin: 2; topMargin: 8; rightMargin: 2; bottomMargin: 2; + } + border { left: 16; top: 16; right: 16; bottom: 16; } + height: childrenRect.height + 16 + source: "bubble.png" + + MWLabel { + anchors { + top: parent.top; left: parent.left; right: parent.right; + margins: 16 / 2 + } + text: curNotification.body + width: parent.width + wrapMode: Text.Wrap + } + } + } + } + + + + function handlesNotification(notification) { + return false; + } + + function openNotification(notification) { + curNotification = notification; + } +} diff --git a/metawatchwatchlets/metawatch-digital-watchface.qml b/metawatchwatchlets/metawatch-digital-watchface.qml index 23236a6..a030bdb 100644 --- a/metawatchwatchlets/metawatch-digital-watchface.qml +++ b/metawatchwatchlets/metawatch-digital-watchface.qml @@ -5,13 +5,6 @@ import com.javispedro.sowatch.metawatch 1.0 MWPage { id: page - Connections { - target: watch - onActiveChanged: { - console.log("watchface is now " + (watch.active ? "active" : "inactive")) - } - } - Column { Item { id: systemArea @@ -30,6 +23,7 @@ MWPage { Item { width: page.width height: 30 + // TODO Weather stuff. } Image { @@ -107,7 +101,7 @@ MWPage { function updateWeather() { var weather = notifications.getMostRecentByType(Notification.WeatherNotification); if (typeof weather !== "undefined") { - // TODO + // TODO Weather stuff } } @@ -116,16 +110,6 @@ MWPage { updateWeather(); } - Connections { - target: watch - onActiveChanged: { - if (watch.active) { - console.log("watchface active"); - //updateUnreadCounts(); - } - } - } - Connections { target: notifications onModelChanged: update(); diff --git a/metawatchwatchlets/metawatchnotificationwatchlet.cpp b/metawatchwatchlets/metawatchnotificationwatchlet.cpp new file mode 100644 index 0000000..ef9c3d5 --- /dev/null +++ b/metawatchwatchlets/metawatchnotificationwatchlet.cpp @@ -0,0 +1,11 @@ +#include "metawatchnotificationwatchlet.h" + +using namespace sowatch; + +const QLatin1String MetaWatchNotificationWatchlet::myId("com.javispedro.sowatch.metawatch.notification"); + +MetaWatchNotificationWatchlet::MetaWatchNotificationWatchlet(Watch *watch) : + DeclarativeWatchlet(watch, myId) +{ + setSource(QUrl(SOWATCH_QML_DIR "/metawatchwatchlets/" + watch->model() + "-notification.qml")); +} diff --git a/metawatchwatchlets/metawatchnotificationwatchlet.h b/metawatchwatchlets/metawatchnotificationwatchlet.h new file mode 100644 index 0000000..3290b0c --- /dev/null +++ b/metawatchwatchlets/metawatchnotificationwatchlet.h @@ -0,0 +1,20 @@ +#ifndef METAWATCHNOTIFICATIONWATCHLET_H +#define METAWATCHNOTIFICATIONWATCHLET_H + +#include + +namespace sowatch +{ + +class MetaWatchNotificationWatchlet : public DeclarativeWatchlet +{ + Q_OBJECT +public: + explicit MetaWatchNotificationWatchlet(Watch* watch); + + static const QLatin1String myId; +}; + +} + +#endif // METAWATCHNOTIFICATIONWATCHLET_H diff --git a/metawatchwatchlets/metawatchwatchlets.pro b/metawatchwatchlets/metawatchwatchlets.pro index f4393e4..af6dcdb 100644 --- a/metawatchwatchlets/metawatchwatchlets.pro +++ b/metawatchwatchlets/metawatchwatchlets.pro @@ -2,11 +2,13 @@ TARGET = metawatchwatchlets TEMPLATE = lib CONFIG += plugin -SOURCES += metawatchwatchletsplugin.cpp metawatchfacewatchlet.cpp +SOURCES += metawatchwatchletsplugin.cpp \ + metawatchfacewatchlet.cpp metawatchnotificationwatchlet.cpp -HEADERS += metawatchwatchletsplugin.h metawatchfacewatchlet.h +HEADERS += metawatchwatchletsplugin.h \ + metawatchfacewatchlet.h metawatchnotificationwatchlet.h -qml_files.files = metawatch-digital-watchface.qml +qml_files.files = metawatch-digital-watchface.qml metawatch-digital-notification.qml LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch INCLUDEPATH += $$PWD/../libsowatch diff --git a/metawatchwatchlets/metawatchwatchletsplugin.cpp b/metawatchwatchlets/metawatchwatchletsplugin.cpp index 31b66ab..98c1713 100644 --- a/metawatchwatchlets/metawatchwatchletsplugin.cpp +++ b/metawatchwatchlets/metawatchwatchletsplugin.cpp @@ -1,4 +1,5 @@ #include "metawatchfacewatchlet.h" +#include "metawatchnotificationwatchlet.h" #include "metawatchwatchletsplugin.h" using namespace sowatch; @@ -15,7 +16,7 @@ MetaWatchWatchletsPlugin::~MetaWatchWatchletsPlugin() QStringList MetaWatchWatchletsPlugin::watchlets() { QStringList l; - l << MetaWatchFaceWatchlet::myId; + l << MetaWatchFaceWatchlet::myId << MetaWatchNotificationWatchlet::myId; return l; } @@ -25,6 +26,9 @@ WatchletPluginInterface::WatchletInfo MetaWatchWatchletsPlugin::describeWatchlet if (id == MetaWatchFaceWatchlet::myId) { info.name = "MetaWatch Face Watchlet"; info.hidden = true; + } else if (id == MetaWatchNotificationWatchlet::myId) { + info.name = "MetaWatch Notification Watchlet"; + info.hidden = true; } return info; } @@ -34,6 +38,8 @@ Watchlet* MetaWatchWatchletsPlugin::getWatchlet(const QString& id, ConfigKey *se Q_UNUSED(settings); if (id == MetaWatchFaceWatchlet::myId) { return new MetaWatchFaceWatchlet(watch); + } else if (id == MetaWatchNotificationWatchlet::myId) { + return new MetaWatchNotificationWatchlet(watch); } } -- cgit v1.2.3