mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-25 07:49:12 +00:00
only backends should start the timeout
This commit is contained in:
parent
a3b2805d7b
commit
3494164dce
@ -68,35 +68,6 @@ const QString &SnorePlugin::name() const
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void SnorePlugin::startTimeout(Notification ¬ification)
|
||||
{
|
||||
if(notification.isSticky())
|
||||
{
|
||||
return;
|
||||
}
|
||||
QTimer *timer = notification.data()->timeoutTimer();
|
||||
timer->stop();
|
||||
if(notification.isUpdate())
|
||||
{
|
||||
notification.old().data()->timeoutTimer()->stop();
|
||||
}
|
||||
timer->setInterval(notification.timeout() * 1000);
|
||||
connect(timer,SIGNAL(timeout()),this,SLOT(notificationTimedOut()));
|
||||
timer->start();
|
||||
}
|
||||
|
||||
void SnorePlugin::notificationTimedOut()
|
||||
{
|
||||
|
||||
QTimer *timer = qobject_cast<QTimer*>(sender());
|
||||
Notification n = snore()->getActiveNotificationByID(timer->property("notificationID").toUInt());
|
||||
if(n.isValid())
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << n;
|
||||
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
bool SnorePlugin::deinitialize()
|
||||
{
|
||||
if(m_initialized)
|
||||
|
@ -54,11 +54,6 @@ public:
|
||||
SnoreCore* snore();
|
||||
const QString &name() const;
|
||||
|
||||
protected:
|
||||
void startTimeout(Notification ¬ification);
|
||||
private slots:
|
||||
void notificationTimedOut();
|
||||
|
||||
private:
|
||||
SnorePlugin() {}
|
||||
QString m_name;
|
||||
|
@ -173,3 +173,33 @@ bool SnoreBackend::deinitialize()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void SnoreBackend::startTimeout(Notification ¬ification)
|
||||
{
|
||||
if(notification.isSticky())
|
||||
{
|
||||
return;
|
||||
}
|
||||
QTimer *timer = notification.data()->timeoutTimer();
|
||||
timer->stop();
|
||||
if(notification.isUpdate())
|
||||
{
|
||||
notification.old().data()->timeoutTimer()->stop();
|
||||
}
|
||||
timer->setInterval(notification.timeout() * 1000);
|
||||
connect(timer,SIGNAL(timeout()),this,SLOT(notificationTimedOut()));
|
||||
timer->start();
|
||||
}
|
||||
|
||||
void SnoreBackend::notificationTimedOut()
|
||||
{
|
||||
|
||||
QTimer *timer = qobject_cast<QTimer*>(sender());
|
||||
Notification n = snore()->getActiveNotificationByID(timer->property("notificationID").toUInt());
|
||||
if(n.isValid())
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << n;
|
||||
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
|
||||
}
|
||||
}
|
||||
|
@ -56,11 +56,14 @@ public slots:
|
||||
virtual void slotNotify ( Snore::Notification notification ) = 0;
|
||||
virtual void slotCloseNotification ( Snore::Notification notification );
|
||||
|
||||
private slots:
|
||||
void notificationTimedOut();
|
||||
|
||||
protected:
|
||||
void startTimeout(Notification ¬ification);
|
||||
void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons);
|
||||
void setSupportsRichtext(bool b);
|
||||
|
||||
|
||||
private:
|
||||
QHash<uint,Notification> m_activeNotifications;
|
||||
|
||||
|
@ -137,6 +137,7 @@ void Growl::slotNotify(Notification notification)
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << e.what();
|
||||
}
|
||||
startTimeout(notification);
|
||||
}
|
||||
|
||||
void Growl::gntpCallback(const int &id,const std::string &reason,const std::string &data)
|
||||
|
@ -265,5 +265,7 @@ void SnarlBackend::slotCloseNotification(Notification notification)
|
||||
qDebug() << Q_FUNC_INFO << "Unknown apllication: " << notification.application().name();
|
||||
return;
|
||||
}
|
||||
m_applications.value(notification.application().name())->Hide(notification.hints().privateValue(this, "id").toUInt());
|
||||
ULONG32 id = notification.hints().privateValue(this, "id").toUInt();
|
||||
m_idMap.take(id);
|
||||
m_applications.value(notification.application().name())->Hide(id);
|
||||
}
|
||||
|
@ -143,13 +143,13 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
|
||||
}
|
||||
|
||||
snore()->broadcastNotification(noti);
|
||||
startTimeout(noti);
|
||||
return noti.id();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FreedesktopFrontend::CloseNotification(uint id){
|
||||
void FreedesktopFrontend::CloseNotification(uint id)
|
||||
{
|
||||
Notification noti = snore()->getActiveNotificationByID(id);
|
||||
if(noti.isValid())
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user