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);
if(n.isValid())
{
qDebug() << Q_FUNC_INFO ;
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
}
}

View File

@ -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<uint,Notification> m_activeNotifications;
bool m_canCloseNotification;
bool m_supportsRichtext;
void addActiveNotification(Notification n);
friend void SnoreCore::broadcastNotification(Notification notification);

View File

@ -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()

View File

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