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)
{
m_closeReason = r;
if (m_timeoutTimer) {
m_timeoutTimer->deleteLater();
m_timeoutTimer.reset();
}
stopTimeoutTimer();
}
QString NotificationData::resolveMarkup(const QString &string, Utils::MARKUP_FLAGS flags)
@ -127,3 +124,12 @@ bool NotificationData::sourceAndTargetAreSimilar(const SnorePlugin *target)
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:
Q_DISABLE_COPY(NotificationData)
void stopTimeoutTimer();
uint m_id;
uint m_updateID;
int m_timeout;

View File

@ -235,15 +235,13 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
return;
}
if (notification.data()->m_timeoutTimer) {
stopNotificationTimeoutTimer(notification);
}
notification.data()->stopTimeoutTimer();
QTimer *timer = new QTimer();
notification.data()->m_timeoutTimer.reset(timer);
timer->setSingleShot(true);
if (notification.isUpdate()) {
stopNotificationTimeoutTimer(notification.old());
notification.old().data()->stopTimeoutTimer();
}
timer->setInterval(notification.timeout() * 1000);
connect(timer, &QTimer::timeout, [q, notification]() {
@ -253,15 +251,6 @@ void SnoreCorePrivate::startNotificationTimeoutTimer(Notification notification)
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
static void loadTranslator()

View File

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