Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 853a092f authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

notifier: Include a button on the plasmoid to reboot when necessary

BUG: 399332
parent a2a9d9e1
......@@ -44,6 +44,7 @@ DiscoverNotifier::DiscoverNotifier(QObject * parent)
m_needsReboot = true;
showRebootNotification();
Q_EMIT updatesChanged();
Q_EMIT needsRebootChanged(true);
}
});
}
......@@ -203,10 +204,13 @@ void DiscoverNotifier::showRebootNotification()
notification->setTitle(i18n("Restart is required"));
notification->setText(i18n("The system needs to be restarted for the updates to take effect."));
connect(notification, &KNotification::action1Activated, this, [] () {
QDBusInterface interface(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QStringLiteral("org.kde.KSMServerInterface"), QDBusConnection::sessionBus());
interface.asyncCall(QStringLiteral("logout"), 0, 1, 2); // Options: do not ask again | reboot | force
});
connect(notification, &KNotification::action1Activated, this, &DiscoverNotifier::loadBackends);
notification->sendEvent();
}
void DiscoverNotifier::loadBackends()
{
QDBusInterface interface(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QStringLiteral("org.kde.KSMServerInterface"), QDBusConnection::sessionBus());
interface.asyncCall(QStringLiteral("logout"), 0, 1, 2); // Options: do not ask again | reboot | force
}
......@@ -36,6 +36,7 @@ Q_PROPERTY(QString iconName READ iconName NOTIFY updatesChanged)
Q_PROPERTY(QString message READ message NOTIFY updatesChanged)
Q_PROPERTY(QString extendedMessage READ extendedMessage NOTIFY updatesChanged)
Q_PROPERTY(State state READ state NOTIFY updatesChanged)
Q_PROPERTY(bool needsReboot READ needsReboot NOTIFY needsRebootChanged)
public:
enum State {
NoUpdates,
......@@ -60,6 +61,7 @@ public:
uint securityUpdatesCount() const;
QStringList loadedModules() const;
bool needsReboot() const { return m_needsReboot; }
public Q_SLOTS:
void configurationChanged();
......@@ -67,9 +69,11 @@ public Q_SLOTS:
void showDiscover();
void showDiscoverUpdates();
void showUpdatesNotification();
void reboot();
Q_SIGNALS:
void updatesChanged();
bool needsRebootChanged(bool needsReboot);
private:
void showRebootNotification();
......
......@@ -52,5 +52,14 @@ Item {
tooltip: i18n("Launches Discover to update the software")
onClicked: DiscoverNotifier.showDiscoverUpdates()
}
Button {
visible: true
Layout.alignment: Qt.AlignHCenter
iconSource: "system-reboot"
text: i18n("Restart")
tooltip: i18n("Restart the system")
onClicked: DiscoverNotifier.reboot()
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment