From 9adfebd33967fd22d4cf8744f7f6c9f4ebcb506d Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Mon, 5 Oct 2015 16:18:31 +0200 Subject: [PATCH] Handle close on qued notification --- src/libsnore/notification/notification.h | 6 ++++++ src/libsnore/snore.cpp | 8 +++++--- src/plugins/backends/snore/snorenotifier.cpp | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libsnore/notification/notification.h b/src/libsnore/notification/notification.h index c41ea38..b50df76 100644 --- a/src/libsnore/notification/notification.h +++ b/src/libsnore/notification/notification.h @@ -280,12 +280,18 @@ public: bool isActiveIn(const QObject *o) const; bool removeActiveIn(const QObject *o); + inline bool operator ==(const Notification &other); + private: QExplicitlySharedDataPointer d; friend class NotificationData; }; +inline bool Notification::operator ==(const Notification &other){ + return id() == other.id(); +} + } Q_DECLARE_METATYPE(Snore::Notification) diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index d8a5800..e7669a1 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -116,7 +116,6 @@ void SnoreCore::broadcastNotification(Notification notification) { Q_D(SnoreCore); if (d->m_activeNotifications.size() > d->maxNumberOfActiveNotifications()) { -#pragma message "TODO: handle updates in queue" snoreDebug(SNORE_DEBUG) << "queue size:" << d->m_notificationQue.size() << "active size:" << d->m_activeNotifications.size(); d->m_notificationQue.append(notification); return; @@ -189,8 +188,11 @@ bool SnoreCore::setPrimaryNotificationBackend(const QString &backend) void SnoreCore::requestCloseNotification(Notification n, Notification::CloseReasons r) { Q_D(SnoreCore); - - if (d->m_notificationBackend) { + bool wasQued = d->m_notificationQue.removeOne(n); + if(wasQued){ + snoreDebug(SNORE_DEBUG) << n << " was qued."; + } + if (!wasQued && d->m_notificationBackend) { d->m_notificationBackend->requestCloseNotification(n, r); } else { if (n.isValid()) { diff --git a/src/plugins/backends/snore/snorenotifier.cpp b/src/plugins/backends/snore/snorenotifier.cpp index 0e78594..1b6e793 100644 --- a/src/plugins/backends/snore/snorenotifier.cpp +++ b/src/plugins/backends/snore/snorenotifier.cpp @@ -27,7 +27,7 @@ using namespace Snore; SnoreNotifier::SnoreNotifier(): - m_widgets(1), + m_widgets(3), m_timer(new QTimer(this)) { for (int i = 0; i < m_widgets.size(); ++i) {