From 98fbac1fa13d964895f2a076d7d073f935f92d7f Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Thu, 16 Jan 2014 10:32:24 +0100 Subject: [PATCH] cleanup --- src/core/plugins/plugins.cpp | 1 + src/core/plugins/snorebackend.h | 5 +++-- .../backends/trayicon/trayiconnotifer.cpp | 22 ++++++++----------- .../backends/trayicon/trayiconnotifer.h | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index ba18492..1d7d3b5 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -94,6 +94,7 @@ void SnorePlugin::notificationTimedOut() Notification n = snore()->getActiveNotificationByID(id); if(n.isValid()) { + qDebug() << Q_FUNC_INFO ; snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT); } } diff --git a/src/core/plugins/snorebackend.h b/src/core/plugins/snorebackend.h index 98b7579..257636e 100644 --- a/src/core/plugins/snorebackend.h +++ b/src/core/plugins/snorebackend.h @@ -57,14 +57,15 @@ public slots: virtual void slotCloseNotification ( Snore::Notification notification ); protected: - bool m_canCloseNotification; - bool m_supportsRichtext; void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons); private: QHash m_activeNotifications; + bool m_canCloseNotification; + bool m_supportsRichtext; + void addActiveNotification(Notification n); friend void SnoreCore::broadcastNotification(Notification notification); diff --git a/src/plugins/backends/trayicon/trayiconnotifer.cpp b/src/plugins/backends/trayicon/trayiconnotifer.cpp index 1fbf4b7..a116c9e 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.cpp +++ b/src/plugins/backends/trayicon/trayiconnotifer.cpp @@ -12,7 +12,7 @@ using namespace Snore; Q_EXPORT_PLUGIN2(trayicon,TrayIconNotifer) TrayIconNotifer::TrayIconNotifer () : - SnoreBackend ( "SystemTray",false,false ), + SnoreBackend ( "SystemTray",true,false ), m_trayIcon(NULL), m_displayed(-1), m_currentlyDisplaying(false) @@ -56,6 +56,13 @@ void TrayIconNotifer::slotNotify( Notification notification ) displayNotification(); } +void TrayIconNotifer::slotCloseNotification(Notification n) +{ + qDebug() << Q_FUNC_INFO << n; + m_currentlyDisplaying = false; + displayNotification(); +} + void TrayIconNotifer::displayNotification() { if(m_currentlyDisplaying) @@ -71,18 +78,7 @@ void TrayIconNotifer::displayNotification() Notification notification = m_notificationQue.takeFirst(); m_displayed = notification.id(); m_trayIcon->showMessage ( Snore::toPlainText(notification.title()),Snore::toPlainText(notification.text()),QSystemTrayIcon::NoIcon,notification.timeout() *1000 ); - QTimer::singleShot(notification.timeout()*1000,this,SLOT(slotCloseNotificationByTimeout())); -} - -void TrayIconNotifer::slotCloseNotificationByTimeout() -{ - Notification n = getActiveNotificationByID(m_displayed); - if(n.isValid()) - { - closeNotification(n,NotificationEnums::CloseReasons::TIMED_OUT); - m_currentlyDisplaying = false; - displayNotification(); - } + startTimeout(notification.id(),notification.timeout()); } void TrayIconNotifer::actionInvoked() diff --git a/src/plugins/backends/trayicon/trayiconnotifer.h b/src/plugins/backends/trayicon/trayiconnotifer.h index c1e297c..f58933d 100644 --- a/src/plugins/backends/trayicon/trayiconnotifer.h +++ b/src/plugins/backends/trayicon/trayiconnotifer.h @@ -23,6 +23,7 @@ public: public slots: void slotNotify(Snore::Notification notification); + void slotCloseNotification(Snore::Notification notification); private: QSystemTrayIcon *m_trayIcon; @@ -33,7 +34,6 @@ private: private slots: void displayNotification(); void actionInvoked(); - void slotCloseNotificationByTimeout(); }; #endif // TRAYICONNOTIFER_H