summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2015-09-03 15:18:13 (GMT)
committerAleix Pol <aleixpol@kde.org>2015-09-03 15:18:13 (GMT)
commit720c49df7640d701840ba55b46613683f6fc1205 (patch)
tree7493d553dd1a532d7a3f835458cd7ae876cf6445
parent09a944e34e2f1ad0cf6fe2a9a71b3fc513e2a8e3 (diff)
Delay updates notification
No need to automatically show the notification, we delay it 3' so that we can avoid peak moments in the system, such as boot or frequent internet connection drops. BUG: 351532
-rw-r--r--notifier/MuonNotifier.cpp28
-rw-r--r--notifier/MuonNotifier.h5
2 files changed, 19 insertions, 14 deletions
diff --git a/notifier/MuonNotifier.cpp b/notifier/MuonNotifier.cpp
index 1260338..ac06951 100644
--- a/notifier/MuonNotifier.cpp
+++ b/notifier/MuonNotifier.cpp
@@ -39,6 +39,9 @@ MuonNotifier::MuonNotifier(QObject * parent)
for(BackendNotifierModule* module : m_backends) {
connect(module, &BackendNotifierModule::foundUpdates, this, &MuonNotifier::updateStatusNotifier);
}
+ connect(&m_timer, &QTimer::timeout, this, &MuonNotifier::showUpdatesNotification);
+ m_timer.setSingleShot(true);
+ m_timer.setInterval(180000);
updateStatusNotifier();
}
@@ -68,22 +71,21 @@ bool MuonNotifier::isSystemUpToDate() const
return true;
}
+void MuonNotifier::showUpdatesNotification()
+{
+ //TODO: Better message strings
+ QString msg = message();
+ if (m_verbose) {
+ msg += ' ' + extendedMessage();
+ }
+
+ KNotification::event("Update", i18n("System update available"), msg, QStringLiteral("system-software-update"), nullptr, KNotification::CloseOnTimeout, "muonabstractnotifier");
+}
+
void MuonNotifier::updateStatusNotifier()
{
-// m_statusNotifier->setOverlayIconByName(iconName());
if (!isSystemUpToDate()) {
- //TODO: Better message strings
- QString msg = message();
- if (m_verbose) {
- msg += ' ' + extendedMessage();
- }
-// m_statusNotifier->setToolTip(iconName(), msg, i18n("A system update is recommended"));
-// m_statusNotifier->setStatus(KStatusNotifierItem::Active);
-
- KNotification::event("Update", i18n("System update available"), msg, QStringLiteral("system-software-update"), nullptr, KNotification::CloseOnTimeout, "muonabstractnotifier");
- } else {
-// m_statusNotifier->setStatus(KStatusNotifierItem::Passive);
-// m_s:tatusNotifier->setToolTip(QString(), message(), i18n("Your system is up-to-date"));
+ m_timer.start();
}
emit updatesChanged();
}
diff --git a/notifier/MuonNotifier.h b/notifier/MuonNotifier.h
index ff95ceb..3c3a94f 100644
--- a/notifier/MuonNotifier.h
+++ b/notifier/MuonNotifier.h
@@ -23,6 +23,7 @@
#include <BackendNotifierModule.h>
#include <QStringList>
+#include <QTimer>
class KStatusNotifierItem;
@@ -57,7 +58,6 @@ public:
/*** @returns count of security updates only **/
uint securityUpdatesCount() const;
- void updateStatusNotifier();
QStringList loadedModules() const;
public Q_SLOTS:
@@ -69,10 +69,13 @@ Q_SIGNALS:
void updatesChanged();
private:
+ void showUpdatesNotification();
+ void updateStatusNotifier();
void loadBackends();
QList<BackendNotifierModule*> m_backends;
bool m_verbose;
+ QTimer m_timer;
};
#endif //ABSTRACTKDEDMODULE_H