add possebility for secondary backends to only perfrom an action when the notification is displayed and not when it is broadcasted

This commit is contained in:
Patrick von Reth 2015-04-26 15:33:09 +02:00
parent 4b0b6e128b
commit a21fd43b88
4 changed files with 19 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
};