This commit is contained in:
Patrick von Reth 2015-07-15 15:25:01 +02:00
parent f05300178d
commit 0c072f3368
4 changed files with 15 additions and 18 deletions

View File

@ -79,10 +79,7 @@ void NotificationData::setActionInvoked(const Snore::Action &action)
void NotificationData::setCloseReason(Snore::Notification::CloseReasons r) void NotificationData::setCloseReason(Snore::Notification::CloseReasons r)
{ {
m_closeReason = r; m_closeReason = r;
if (m_timeoutTimer) { stopTimeoutTimer();
m_timeoutTimer->deleteLater();
m_timeoutTimer.reset();
}
} }
QString NotificationData::resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags) QString NotificationData::resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags)
@ -127,3 +124,12 @@ bool NotificationData::sourceAndTargetAreSimilar(const SnorePlugin *target)
return false; return false;
} }
void NotificationData::stopTimeoutTimer()
{
if (m_timeoutTimer) {
m_timeoutTimer->stop();
m_timeoutTimer->deleteLater();
m_timeoutTimer.reset(nullptr);
}
}

View File

@ -71,6 +71,8 @@ public:
private: private:
Q_DISABLE_COPY(NotificationData) Q_DISABLE_COPY(NotificationData)
void stopTimeoutTimer();
uint m_id; uint m_id;
uint m_updateID; uint m_updateID;
int m_timeout; int m_timeout;

View File

@ -235,15 +235,13 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
return; return;
} }
if (notification.data()->m_timeoutTimer) { notification.data()->stopTimeoutTimer();
stopNotificationTimeoutTimer(notification);
}
QTimer *timer = new QTimer(); QTimer *timer = new QTimer();
notification.data()->m_timeoutTimer.reset(timer); notification.data()->m_timeoutTimer.reset(timer);
timer->setSingleShot(true); timer->setSingleShot(true);
if (notification.isUpdate()) { if (notification.isUpdate()) {
stopNotificationTimeoutTimer(notification.old()); notification.old().data()->stopTimeoutTimer();
} }
timer->setInterval(notification.timeout() * 1000); timer->setInterval(notification.timeout() * 1000);
connect(timer, &QTimer::timeout, [q, notification]() { connect(timer, &QTimer::timeout, [q, notification]() {
@ -253,15 +251,6 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
timer->start(); timer->start();
} }
void SnoreCorePrivate::stopNotificationTimeoutTimer(Notification &notification)
{
if (notification.data()->m_timeout) {
notification.data()->m_timeoutTimer->stop();
notification.data()->m_timeoutTimer->deleteLater();
notification.data()->m_timeoutTimer.reset(nullptr);
}
}
///Startup code ///Startup code
static void loadTranslator() static void loadTranslator()

View File

@ -70,7 +70,7 @@ public:
void setDefaultSettingsValueIntern(const QString &key, const QVariant &value); void setDefaultSettingsValueIntern(const QString &key, const QVariant &value);
void startNotificationTimeoutTimer(Notification notification); void startNotificationTimeoutTimer(Notification notification);
void stopNotificationTimeoutTimer(Notification &notification);
private Q_SLOTS: private Q_SLOTS:
//TODO: find a better solutinon for the slots in this section //TODO: find a better solutinon for the slots in this section
friend class Snore::SnoreBackend; friend class Snore::SnoreBackend;