mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-17 10:56:25 +00:00
timeout for freedesktop notifications, to close them all
This commit is contained in:
parent
2370fd47cc
commit
e348dd7f7c
@ -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)
|
||||
{ }
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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();
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user