This commit is contained in:
Patrick von Reth 2014-01-16 10:32:24 +01:00
parent adfe9f3380
commit 98fbac1fa1
4 changed files with 14 additions and 16 deletions

View File

@ -94,6 +94,7 @@ void SnorePlugin::notificationTimedOut()
Notification n = snore()->getActiveNotificationByID(id); Notification n = snore()->getActiveNotificationByID(id);
if(n.isValid()) if(n.isValid())
{ {
qDebug() << Q_FUNC_INFO ;
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT); snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
} }
} }

View File

@ -57,14 +57,15 @@ public slots:
virtual void slotCloseNotification ( Snore::Notification notification ); virtual void slotCloseNotification ( Snore::Notification notification );
protected: protected:
bool m_canCloseNotification;
bool m_supportsRichtext;
void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons); void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons);
private: private:
QHash<uint,Notification> m_activeNotifications; QHash<uint,Notification> m_activeNotifications;
bool m_canCloseNotification;
bool m_supportsRichtext;
void addActiveNotification(Notification n); void addActiveNotification(Notification n);
friend void SnoreCore::broadcastNotification(Notification notification); friend void SnoreCore::broadcastNotification(Notification notification);

View File

@ -12,7 +12,7 @@ using namespace Snore;
Q_EXPORT_PLUGIN2(trayicon,TrayIconNotifer) Q_EXPORT_PLUGIN2(trayicon,TrayIconNotifer)
TrayIconNotifer::TrayIconNotifer () : TrayIconNotifer::TrayIconNotifer () :
SnoreBackend ( "SystemTray",false,false ), SnoreBackend ( "SystemTray",true,false ),
m_trayIcon(NULL), m_trayIcon(NULL),
m_displayed(-1), m_displayed(-1),
m_currentlyDisplaying(false) m_currentlyDisplaying(false)
@ -56,6 +56,13 @@ void TrayIconNotifer::slotNotify( Notification notification )
displayNotification(); displayNotification();
} }
void TrayIconNotifer::slotCloseNotification(Notification n)
{
qDebug() << Q_FUNC_INFO << n;
m_currentlyDisplaying = false;
displayNotification();
}
void TrayIconNotifer::displayNotification() void TrayIconNotifer::displayNotification()
{ {
if(m_currentlyDisplaying) if(m_currentlyDisplaying)
@ -71,18 +78,7 @@ void TrayIconNotifer::displayNotification()
Notification notification = m_notificationQue.takeFirst(); Notification notification = m_notificationQue.takeFirst();
m_displayed = notification.id(); m_displayed = notification.id();
m_trayIcon->showMessage ( Snore::toPlainText(notification.title()),Snore::toPlainText(notification.text()),QSystemTrayIcon::NoIcon,notification.timeout() *1000 ); m_trayIcon->showMessage ( Snore::toPlainText(notification.title()),Snore::toPlainText(notification.text()),QSystemTrayIcon::NoIcon,notification.timeout() *1000 );
QTimer::singleShot(notification.timeout()*1000,this,SLOT(slotCloseNotificationByTimeout())); startTimeout(notification.id(),notification.timeout());
}
void TrayIconNotifer::slotCloseNotificationByTimeout()
{
Notification n = getActiveNotificationByID(m_displayed);
if(n.isValid())
{
closeNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
m_currentlyDisplaying = false;
displayNotification();
}
} }
void TrayIconNotifer::actionInvoked() void TrayIconNotifer::actionInvoked()

View File

@ -23,6 +23,7 @@ public:
public slots: public slots:
void slotNotify(Snore::Notification notification); void slotNotify(Snore::Notification notification);
void slotCloseNotification(Snore::Notification notification);
private: private:
QSystemTrayIcon *m_trayIcon; QSystemTrayIcon *m_trayIcon;
@ -33,7 +34,6 @@ private:
private slots: private slots:
void displayNotification(); void displayNotification();
void actionInvoked(); void actionInvoked();
void slotCloseNotificationByTimeout();
}; };
#endif // TRAYICONNOTIFER_H #endif // TRAYICONNOTIFER_H