From a21fd43b883827925e16fdec709136c93b37b65c Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 26 Apr 2015 15:33:09 +0200 Subject: [PATCH] add possebility for secondary backends to only perfrom an action when the notification is displayed and not when it is broadcasted --- src/libsnore/plugins/snorebackend.cpp | 18 +++++++++++++++--- src/libsnore/plugins/snorebackend.h | 3 ++- src/plugins/secondary_backends/sound/sound.cpp | 2 +- src/plugins/secondary_backends/sound/sound.h | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/libsnore/plugins/snorebackend.cpp b/src/libsnore/plugins/snorebackend.cpp index 2c1412e..6a36e37 100644 --- a/src/libsnore/plugins/snorebackend.cpp +++ b/src/libsnore/plugins/snorebackend.cpp @@ -76,7 +76,7 @@ void SnoreBackend::closeNotification(Notification n, Notification::CloseReasons return; } n.removeActiveIn(this); - if (n.isUpdate() && n.old().isActiveIn(this)) { + if (n.isUpdate()) { n.old().removeActiveIn(this); } n.data()->setCloseReason(reason); @@ -111,14 +111,16 @@ bool SnoreSecondaryBackend::initialize() if (!SnorePlugin::initialize()) { return false; } - connect(SnoreCorePrivate::instance(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification)), Qt::QueuedConnection); + connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notify, this, &SnoreSecondaryBackend::slotNotify, Qt::QueuedConnection); + connect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notificationDisplayed, this, &SnoreSecondaryBackend::slotNotificationDisplayed, Qt::QueuedConnection); return true; } bool SnoreSecondaryBackend::deinitialize() { if (SnorePlugin::deinitialize()) { - disconnect(SnoreCorePrivate::instance(), SIGNAL(notify(Snore::Notification)), this, SLOT(slotNotify(Snore::Notification))); + disconnect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notify, this, &SnoreSecondaryBackend::slotNotify); + disconnect(SnoreCorePrivate::instance(), &SnoreCorePrivate::notificationDisplayed, this, &SnoreSecondaryBackend::slotNotificationDisplayed); return true; } return false; @@ -129,6 +131,16 @@ bool SnoreSecondaryBackend::supportsRichtext() return m_supportsRichtext; } +void SnoreSecondaryBackend::slotNotify(Notification) +{ + +} + +void SnoreSecondaryBackend::slotNotificationDisplayed(Notification) +{ + +} + bool SnoreBackend::canCloseNotification() const { return m_canCloseNotification; diff --git a/src/libsnore/plugins/snorebackend.h b/src/libsnore/plugins/snorebackend.h index 11a4f6a..b75de04 100644 --- a/src/libsnore/plugins/snorebackend.h +++ b/src/libsnore/plugins/snorebackend.h @@ -87,7 +87,8 @@ public: bool supportsRichtext(); public slots: - virtual void slotNotify(Snore::Notification notification) = 0; + virtual void slotNotify(Snore::Notification notification); + virtual void slotNotificationDisplayed(Snore::Notification notification); protected: bool m_supportsRichtext; diff --git a/src/plugins/secondary_backends/sound/sound.cpp b/src/plugins/secondary_backends/sound/sound.cpp index a9047e2..61262f5 100644 --- a/src/plugins/secondary_backends/sound/sound.cpp +++ b/src/plugins/secondary_backends/sound/sound.cpp @@ -47,7 +47,7 @@ PluginSettingsWidget *Sound::settingsWidget() return new SoundSettings(this); } -void Sound::slotNotify(Snore::Notification notification) +void Sound::slotNotificationDisplayed(Snore::Notification notification) { if (notification.hints().value("silent", false).toBool()) { return; diff --git a/src/plugins/secondary_backends/sound/sound.h b/src/plugins/secondary_backends/sound/sound.h index de71a07..5f7379f 100644 --- a/src/plugins/secondary_backends/sound/sound.h +++ b/src/plugins/secondary_backends/sound/sound.h @@ -32,7 +32,7 @@ public: Snore::PluginSettingsWidget *settingsWidget() override; public slots: - void slotNotify(Snore::Notification notification) override; + void slotNotificationDisplayed(Snore::Notification notification) override; private: class QMediaPlayer *m_player; };