summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsowatch/watchserver.cpp25
-rw-r--r--libsowatch/watchserver.h2
2 files changed, 22 insertions, 5 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index 4675809..9d7859d 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -195,6 +195,7 @@ void WatchServer::postNotification(Notification *notification)
{
const Notification::Type type = notification->type();
_notifications[type].append(notification);
+ _notificationCounts[notification] = notification->count();
connect(notification, SIGNAL(changed()), SLOT(notificationChanged()));
connect(notification, SIGNAL(dismissed()), SLOT(notificationDismissed()));
@@ -247,15 +248,13 @@ void WatchServer::notificationChanged()
if (obj) {
Notification* n = static_cast<Notification*>(obj);
const Notification::Type type = n->type();
+ const uint lastCount = _notificationCounts[n];
+ _notificationCounts[n] = n->count();
qDebug() << "notification changed" << n->title() << "(" << n->count() << ")";
_watch->updateNotificationCount(type, getNotificationCount(type));
- if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {
- // This is the notification that is being currently signaled on the watch
- // Therefore, show it again
- nextNotification();
- }
+
if (type == Notification::WeatherNotification) {
WeatherNotification* w = static_cast<WeatherNotification*>(n);
if (!_weather || _weather->dateTime() < w->dateTime()) {
@@ -267,6 +266,21 @@ void WatchServer::notificationChanged()
// Therefore, update the displayed information
_watch->updateWeather(w);
}
+ return; // Do not display it the usual way
+ }
+
+ if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {
+ // This is the notification that is being currently signaled on the watch
+ // Therefore, show it again no matter what.
+ nextNotification();
+ } else if (n->count() > lastCount) {
+ // This notification now contains an additional "item"; redisplay it.
+ if (_pendingNotifications.isEmpty()) {
+ _pendingNotifications.enqueue(n);
+ nextNotification();
+ } else {
+ _pendingNotifications.enqueue(n);
+ }
}
}
}
@@ -278,6 +292,7 @@ void WatchServer::notificationDismissed()
Notification* n = static_cast<Notification*>(obj);
const Notification::Type type = n->type();
_notifications[type].removeOne(n);
+ _notificationCounts.remove(n);
qDebug() << "notification dismissed" << n->title() << "(" << n->count() << ")";
diff --git a/libsowatch/watchserver.h b/libsowatch/watchserver.h
index 53c1a70..f86d224 100644
--- a/libsowatch/watchserver.h
+++ b/libsowatch/watchserver.h
@@ -64,6 +64,8 @@ private:
QList<Notification*> _notifications[Notification::TypeCount];
/** A list of notifications that are yet to be shown to the user. */
QQueue<Notification*> _pendingNotifications;
+ /** Stores the count of notifications hidden between each notification object. */
+ QMap<Notification*, uint> _notificationCounts;
/** We store a currently live weather forecast. */
WeatherNotification* _weather;