cleanup
This commit is contained in:
parent
f05300178d
commit
0c072f3368
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,8 @@ public:
|
|||
private:
|
||||
Q_DISABLE_COPY(NotificationData)
|
||||
|
||||
void stopTimeoutTimer();
|
||||
|
||||
uint m_id;
|
||||
uint m_updateID;
|
||||
int m_timeout;
|
||||
|
|
|
@ -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 ¬ification)
|
||||
{
|
||||
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()
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
void setDefaultSettingsValueIntern(const QString &key, const QVariant &value);
|
||||
|
||||
void startNotificationTimeoutTimer(Notification notification);
|
||||
void stopNotificationTimeoutTimer(Notification ¬ification);
|
||||
|
||||
private Q_SLOTS:
|
||||
//TODO: find a better solutinon for the slots in this section
|
||||
friend class Snore::SnoreBackend;
|
||||
|
|
Loading…
Reference in New Issue