diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index d1d70ef..7180ba0 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -67,6 +67,48 @@ const QString &SnorePlugin::name() const return m_name; } +void SnorePlugin::startTimeout(Notification ¬ification) +{ + if(notification.sticky()) + { + return; + } + uint id = notification.id(); + QTimer *timer = qvariant_cast(notification.hints().privateValue(this, "timeout")); + if(notification.updateID() != (uint)-1) + { + id = notification.updateID(); + } + if(timer) + { + timer->stop(); + } + else + { + timer = new QTimer(this); + timer->setSingleShot(true); + timer->setProperty("notificationID", id); + } + + timer->setInterval(notification.timeout() * 1000); + connect(timer,SIGNAL(timeout()),this,SLOT(notificationTimedOut())); + timer->start(); +} + +void SnorePlugin::notificationTimedOut() +{ + + QTimer *timer = qobject_cast(sender()); + Notification n = snore()->getActiveNotificationByID(timer->property("notificationID").toUInt()); + if(n.isValid()) + { + qDebug() << Q_FUNC_INFO << n; + timer->deleteLater(); + snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT); + } + timer->deleteLater(); +} + bool SnorePlugin::deinitialize() { if(m_initialized) diff --git a/src/core/plugins/plugins.h b/src/core/plugins/plugins.h index 408e444..fe02593 100644 --- a/src/core/plugins/plugins.h +++ b/src/core/plugins/plugins.h @@ -54,6 +54,11 @@ public: SnoreCore* snore(); const QString &name() const; +protected: + void startTimeout(Notification ¬ification); +private slots: + void notificationTimedOut(); + private: SnorePlugin() {} QString m_name; diff --git a/src/core/plugins/snorebackend.cpp b/src/core/plugins/snorebackend.cpp index 60f546f..c813dba 100644 --- a/src/core/plugins/snorebackend.cpp +++ b/src/core/plugins/snorebackend.cpp @@ -167,45 +167,3 @@ bool SnoreBackend::deinitialize() } return false; } - -void SnoreBackend::startTimeout(Notification ¬ification) -{ - if(notification.sticky()) - { - return; - } - uint id = notification.id(); - QTimer *timer = qvariant_cast(notification.hints().privateValue(this, "timeout")); - if(notification.updateID() != (uint)-1) - { - id = notification.updateID(); - } - if(timer) - { - timer->stop(); - } - else - { - timer = new QTimer(this); - timer->setSingleShot(true); - timer->setProperty("notificationID", id); - } - - timer->setInterval(notification.timeout() * 1000); - connect(timer,SIGNAL(timeout()),this,SLOT(slotNotificationTimedOut())); - timer->start(); -} - - -void SnoreBackend::slotNotificationTimedOut() -{ - QTimer *timer = qobject_cast(sender()); - Notification n = snore()->getActiveNotificationByID(timer->property("notificationID").toUInt()); - if(n.isValid()) - { - qDebug() << Q_FUNC_INFO << n; - timer->deleteLater(); - snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT); - } - timer->deleteLater(); -} diff --git a/src/core/plugins/snorebackend.h b/src/core/plugins/snorebackend.h index 58abb27..257636e 100644 --- a/src/core/plugins/snorebackend.h +++ b/src/core/plugins/snorebackend.h @@ -56,12 +56,9 @@ public slots: virtual void slotNotify ( Snore::Notification notification ) = 0; virtual void slotCloseNotification ( Snore::Notification notification ); -private slots: - void slotNotificationTimedOut(); - protected: void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons); - void startTimeout(Notification ¬ification); + private: QHash m_activeNotifications;