diff options
-rw-r--r-- | harmaccuweather/harmaccuprovider.cpp | 1 | ||||
-rw-r--r-- | harmaccuweather/harmaccuweather.cpp | 6 | ||||
-rw-r--r-- | libsowatch/watchserver.cpp | 40 | ||||
-rw-r--r-- | libsowatch/watchserver.h | 1 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml | 2 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml | 6 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml | 1 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/qmldir | 2 | ||||
-rw-r--r-- | notificationswatchlet/metawatch-digital.qml | 19 | ||||
-rw-r--r-- | qmafwwatchlet/metawatch-digital.qml | 2 | ||||
-rw-r--r-- | qmsgwatchlet/qmsgwatchlet.cpp | 6 | ||||
-rw-r--r-- | qmsgwatchlet/qmsgwatchlet.h | 4 | ||||
-rw-r--r-- | sowatch.pro | 2 | ||||
-rw-r--r-- | sowatchd/watchhandler.cpp | 10 | ||||
-rw-r--r-- | sysinfowatchlet/metawatch-digital.qml | 54 |
15 files changed, 111 insertions, 45 deletions
diff --git a/harmaccuweather/harmaccuprovider.cpp b/harmaccuweather/harmaccuprovider.cpp index 0eedf04..2c26b67 100644 --- a/harmaccuweather/harmaccuprovider.cpp +++ b/harmaccuweather/harmaccuprovider.cpp @@ -14,7 +14,6 @@ HarmAccuProvider::HarmAccuProvider(QObject *parent) : HarmAccuProvider::~HarmAccuProvider() { - } void HarmAccuProvider::generateNotification() diff --git a/harmaccuweather/harmaccuweather.cpp b/harmaccuweather/harmaccuweather.cpp index 38fc9bc..c4daeb9 100644 --- a/harmaccuweather/harmaccuweather.cpp +++ b/harmaccuweather/harmaccuweather.cpp @@ -2,6 +2,8 @@ using namespace sowatch; +#define ACCUWEATHER_FILE_PATH "/home/user/.config/AccuWeather, Inc./awxapp.conf" + HarmAccuWeather::HarmAccuWeather(QObject *parent) : WeatherNotification(parent), _watcher(new QFileSystemWatcher(this)), @@ -10,7 +12,7 @@ HarmAccuWeather::HarmAccuWeather(QObject *parent) : { // This only works on Harmattan either way, so I guess // hardcoding the path is OK. - _watcher->addPath("/home/user/.config/AccuWeather, Inc./awxapp.conf"); + _watcher->addPath(ACCUWEATHER_FILE_PATH); connect(_watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString))); _timer->setInterval(5000); @@ -23,7 +25,7 @@ HarmAccuWeather::HarmAccuWeather(QObject *parent) : QSettings* HarmAccuWeather::getAccuweatherData() { - return new QSettings("AccuWeather, Inc.", "awxapp"); + return new QSettings(ACCUWEATHER_FILE_PATH, QSettings::IniFormat); } Notification::Type HarmAccuWeather::type() const diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp index 2cadc98..35d2429 100644 --- a/libsowatch/watchserver.cpp +++ b/libsowatch/watchserver.cpp @@ -245,6 +245,7 @@ void WatchServer::postNotification(Notification *notification) connect(notification, SIGNAL(changed()), SLOT(handleNotificationChanged())); connect(notification, SIGNAL(dismissed()), SLOT(handleNotificationDismissed())); + connect(notification, SIGNAL(destroyed()), SLOT(handleNotificationDestroyed())); qDebug() << "notification received" << notification->title() << "(" << notification->count() << ")"; @@ -360,5 +361,44 @@ void WatchServer::handleNotificationDismissed() _weather = 0; } } + + // No longer interested in this notification + disconnect(n, 0, this, 0); + } +} + +void WatchServer::handleNotificationDestroyed() +{ + QObject *obj = sender(); + if (obj) { + Notification* n = static_cast<Notification*>(obj); + // Cannot call any methods of n; it is a dangling pointer now. + if (_notificationCounts.contains(n)) { + qWarning() << "Notification destroyed without being dismissed!"; + _notificationCounts.remove(n); + + for (int i = 0; i < Notification::TypeCount; i++) { + Notification::Type type = static_cast<Notification::Type>(i); + if (_notifications[type].contains(n)) { + _notifications[type].removeAll(n); + _watch->updateNotificationCount(type, getNotificationCount(type)); + + if (type == Notification::WeatherNotification) { + WeatherNotification* w = static_cast<WeatherNotification*>(n); + if (_weather == w) { + _weather = 0; + } + } + } + } + + if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) { + qDebug() << "removing top notification"; + _pendingNotifications.removeAll(n); + nextNotification(); + } else { + _pendingNotifications.removeAll(n); + } + } } } diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h index c1e6ef0..edb4e1a 100644 --- a/libsowatch/watchserver.h +++ b/libsowatch/watchserver.h @@ -104,6 +104,7 @@ private slots: void handleNotificationChanged(); void handleNotificationDismissed(); + void handleNotificationDestroyed(); }; } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml index 5ade4a8..d1fe507 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWLabel.qml @@ -1,6 +1,6 @@ import Qt 4.7 Text { - font.family: "MetaWatch Large" + font.family: "MetaWatch Large 16pt" font.pixelSize: 16 } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml new file mode 100644 index 0000000..d26e058 --- /dev/null +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWSmallLabel.qml @@ -0,0 +1,6 @@ +import Qt 4.7 + +Text { + font.family: "MetaWatch Large caps 8pt" + font.pixelSize: 8 +} diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml index c2cccab..017d6a1 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml @@ -18,6 +18,5 @@ Rectangle { anchors.left: image.right anchors.leftMargin: 2 anchors.verticalCenter: parent.verticalCenter - font.bold: true } } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir index 91ee6dc..c6b0714 100644 --- a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir @@ -1,3 +1,5 @@ MWPage 1.0 MWPage.qml +MWLabel 1.0 MWLabel.qml +MWSmallLabel 1.0 MWSmallLabel.qml MWTitle 1.0 MWTitle.qml MWListView 1.0 MWListView.qml diff --git a/notificationswatchlet/metawatch-digital.qml b/notificationswatchlet/metawatch-digital.qml index 1e97052..9129226 100644 --- a/notificationswatchlet/metawatch-digital.qml +++ b/notificationswatchlet/metawatch-digital.qml @@ -24,15 +24,24 @@ Rectangle { anchors.bottom: parent.bottom model: watch.notifications delegate: Rectangle { + id: notifDelegate property bool selected: ListView.isCurrentItem width: notifs.width height: childrenRect.height color: ListView.isCurrentItem ? "black" : "white" - MWLabel { - width: 96 - text: "<b>" + model.modelData.title + "</b><br>" + model.modelData.body - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - color: parent.selected ? "white" : "black" + Column { + MWLabel { + width: notifs.width + text: model.modelData.title + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + color: notifDelegate.selected ? "white" : "black" + } + MWSmallLabel { + width: notifs.width + text: model.modelData.body + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + color: notifDelegate.selected ? "white" : "black" + } } } visible: count > 0; diff --git a/qmafwwatchlet/metawatch-digital.qml b/qmafwwatchlet/metawatch-digital.qml index 16dc85e..d9370a6 100644 --- a/qmafwwatchlet/metawatch-digital.qml +++ b/qmafwwatchlet/metawatch-digital.qml @@ -31,7 +31,7 @@ Rectangle { anchors.bottom: parent.bottom color: "white" - Text { + MWLabel { anchors.fill: parent text: player.title.length > 0 ? player.title : qsTr("No media"); color: "black" diff --git a/qmsgwatchlet/qmsgwatchlet.cpp b/qmsgwatchlet/qmsgwatchlet.cpp index 5a95937..35a99d8 100644 --- a/qmsgwatchlet/qmsgwatchlet.cpp +++ b/qmsgwatchlet/qmsgwatchlet.cpp @@ -1,11 +1,11 @@ #include "qmsgwatchlet.h" +QTM_USE_NAMESPACE using namespace sowatch; QMsgWatchlet::QMsgWatchlet(WatchServer* server) : - DeclarativeWatchlet(server, "com.javispedro.sowatch.qmsg") + DeclarativeWatchlet(server, "com.javispedro.sowatch.qmsg"), + _qms(new QMessageService(this)) { - setSource(QUrl(SOWATCH_QML_DIR "/qmsgwatchlet/" + server->watch()->model() + ".qml")); } - diff --git a/qmsgwatchlet/qmsgwatchlet.h b/qmsgwatchlet/qmsgwatchlet.h index b731637..c2de7ec 100644 --- a/qmsgwatchlet/qmsgwatchlet.h +++ b/qmsgwatchlet/qmsgwatchlet.h @@ -1,6 +1,7 @@ #ifndef QMSGWATCHLET_H #define QMSGWATCHLET_H +#include <QtMessaging/QMessageService> #include <sowatch.h> namespace sowatch @@ -11,6 +12,9 @@ class QMsgWatchlet : public DeclarativeWatchlet Q_OBJECT public: explicit QMsgWatchlet(WatchServer* server); + +private: + QTM_PREPEND_NAMESPACE(QMessageService) _qms; }; } diff --git a/sowatch.pro b/sowatch.pro index 00f475b..18c22b8 100644 --- a/sowatch.pro +++ b/sowatch.pro @@ -9,7 +9,7 @@ metawatch.depends = libsowatch # Some watchlets SUBDIRS += notificationswatchlet sysinfowatchlet -#SUBDIRS += qmsgwatchlet +SUBDIRS += qmsgwatchlet SUBDIRS += qmapwatchlet notificationswatchlet.depends = libsowatch sysinfowatchlet.depends = libsowatch diff --git a/sowatchd/watchhandler.cpp b/sowatchd/watchhandler.cpp index 4bebb9c..b04c90b 100644 --- a/sowatchd/watchhandler.cpp +++ b/sowatchd/watchhandler.cpp @@ -108,7 +108,7 @@ void WatchHandler::updateWatchlets() delete subconfig; } - qDebug() << "Watchlets reloaded"; + qDebug() << "Watchlets reloaded: " << _watchlets.keys(); } void WatchHandler::updateProviders() @@ -122,9 +122,13 @@ void WatchHandler::updateProviders() QSet<QString> removed = curProviders - newProviders; QSet<QString> added = newProviders - curProviders; + qDebug() << "Providers to remove: " << removed; + qDebug() << "Providers to add: " << added; + foreach (const QString& s, removed) { NotificationProvider *provider = _providers[s]; _server->removeProvider(provider); + _providers.remove(s); delete provider; } @@ -140,13 +144,17 @@ void WatchHandler::updateProviders() _providers[s] = provider; delete subconfig; } + + qDebug() << "Providers reloaded: " << _providers.keys(); } void WatchHandler::handleConfigSubkeyChanged(const QString &subkey) { if (subkey == "watchlets") { + qDebug() << "Watchlets list changed"; updateWatchlets(); } else if (subkey == "providers") { + qDebug() << "Providers list changed"; updateProviders(); } else if (subkey == "next-watchlet-button" && _server) { _server->setNextWatchletButton(_config->value("next-watchlet-button").toString()); diff --git a/sysinfowatchlet/metawatch-digital.qml b/sysinfowatchlet/metawatch-digital.qml index 1e6acfb..e94ad27 100644 --- a/sysinfowatchlet/metawatch-digital.qml +++ b/sysinfowatchlet/metawatch-digital.qml @@ -9,6 +9,7 @@ Rectangle { Column { anchors.fill: parent + spacing: 4 MWTitle { id: title @@ -16,42 +17,37 @@ Rectangle { icon.source: "icon.png" } - Column { - spacing: 4 - width: 96 + MWSmallLabel { + text: "Battery: " + batteryLevel + "%" + } - Text { - text: "Battery: " + batteryLevel + "%" - } + Rectangle { + id: battery + x: 12 + width: 72 + height: 16 - Rectangle { - id: battery - x: 12 - width: 72 - height: 16 + border.color: "black" + border.width: 1 - border.color: "black" - border.width: 1 - - Rectangle { - width: (batteryLevel / 100) * parent.width - height: parent.height + Rectangle { + width: (batteryLevel / 100) * parent.width + height: parent.height - color: "black" - } + color: "black" } + } - Text { - width: parent.width - text: "Connected to:" - } + MWSmallLabel { + width: parent.width + text: "Connected to:" + } - Text { - width: parent.width - text: networkName - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.Wrap - } + MWLabel { + width: parent.width + text: networkName + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.Wrap } } } |