Handle close on qued notification

This commit is contained in:
Hannah von Reth 2015-10-05 16:18:31 +02:00
parent f5fbb6a7ed
commit 9adfebd339
3 changed files with 12 additions and 4 deletions

View File

@ -280,12 +280,18 @@ public:
bool isActiveIn(const QObject *o) const; bool isActiveIn(const QObject *o) const;
bool removeActiveIn(const QObject *o); bool removeActiveIn(const QObject *o);
inline bool operator ==(const Notification &other);
private: private:
QExplicitlySharedDataPointer<NotificationData> d; QExplicitlySharedDataPointer<NotificationData> d;
friend class NotificationData; friend class NotificationData;
}; };
inline bool Notification::operator ==(const Notification &other){
return id() == other.id();
}
} }
Q_DECLARE_METATYPE(Snore::Notification) Q_DECLARE_METATYPE(Snore::Notification)

View File

@ -116,7 +116,6 @@ void SnoreCore::broadcastNotification(Notification notification)
{ {
Q_D(SnoreCore); Q_D(SnoreCore);
if (d->m_activeNotifications.size() > d->maxNumberOfActiveNotifications()) { 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(); snoreDebug(SNORE_DEBUG) << "queue size:" << d->m_notificationQue.size() << "active size:" << d->m_activeNotifications.size();
d->m_notificationQue.append(notification); d->m_notificationQue.append(notification);
return; return;
@ -189,8 +188,11 @@ bool SnoreCore::setPrimaryNotificationBackend(const QString &backend)
void SnoreCore::requestCloseNotification(Notification n, Notification::CloseReasons r) void SnoreCore::requestCloseNotification(Notification n, Notification::CloseReasons r)
{ {
Q_D(SnoreCore); Q_D(SnoreCore);
bool wasQued = d->m_notificationQue.removeOne(n);
if (d->m_notificationBackend) { if(wasQued){
snoreDebug(SNORE_DEBUG) << n << " was qued.";
}
if (!wasQued && d->m_notificationBackend) {
d->m_notificationBackend->requestCloseNotification(n, r); d->m_notificationBackend->requestCloseNotification(n, r);
} else { } else {
if (n.isValid()) { if (n.isValid()) {

View File

@ -27,7 +27,7 @@
using namespace Snore; using namespace Snore;
SnoreNotifier::SnoreNotifier(): SnoreNotifier::SnoreNotifier():
m_widgets(1), m_widgets(3),
m_timer(new QTimer(this)) m_timer(new QTimer(this))
{ {
for (int i = 0; i < m_widgets.size(); ++i) { for (int i = 0; i < m_widgets.size(); ++i) {