timeout for freedesktop notifications, to close them all

This commit is contained in:
Patrick von Reth 2011-07-29 20:12:48 +02:00
parent 2370fd47cc
commit e348dd7f7c
3 changed files with 81 additions and 70 deletions

View File

@ -44,8 +44,9 @@ public:
_localFileName = url;
}
}
~SnoreIconData()
{/*nothing to do*/ }
{}
QImage _img;
@ -54,11 +55,6 @@ public:
QString _hash;
bool _isLocalFile;
private:
SnoreIconData(const SnoreIconData &other)
{ }
};

View File

@ -100,6 +100,8 @@ uint FreedesktopNotification_Frontend::Notify(const QString &app_name, uint repl
snore()->broadcastNotification(noti);
activeNotifications[noti.id()] = noti;
timeout_notifications.append(noti.id());
QTimer::singleShot(timeout==-1?Notification::DefaultTimeout*1000:timeout,this,SLOT(timeoutClose()));
return noti.id();
}
@ -130,5 +132,14 @@ QString FreedesktopNotification_Frontend::GetServerInformation(QString& vendor,
return "Snore";
}
void FreedesktopNotification_Frontend::timeoutClose(){
uint id = timeout_notifications.takeFirst();
if(activeNotifications.contains(id)){
Notification noti = activeNotifications[id];
noti.setCloseReason(NotificationEnums::CloseReasons::TIMED_OUT);
notificationClosed(noti);
}
}
#include "freedesktopnotificationfrontend.moc"

View File

@ -34,11 +34,15 @@ public:
QStringList GetCapabilities();
QString GetServerInformation(QString& vendor, QString& version, QString& specVersion);
private:
QList<uint> timeout_notifications;
signals:
void NotificationClosed( uint id, uint reason );
void ActionInvoked( uint id, const QString& actionKey );
private slots:
void timeoutClose();
};