From 2b04ab65e21893f4eb95847d3ad007573fffe212 Mon Sep 17 00:00:00 2001 From: nephros Date: Fri, 26 May 2023 09:40:44 +0200 Subject: [PATCH] Add option to load last-know-good patch list Contributes-To: #277 --- .../dbus/org.SfietKonstantin.patchmanager.xml | 3 +++ src/bin/patchmanager-daemon/patchmanagerobject.cpp | 6 ++++++ src/bin/patchmanager-daemon/patchmanagerobject.h | 1 + src/qml/PatchManagerPage.qml | 6 ++++++ src/qml/patchmanager.cpp | 7 +++++++ src/qml/patchmanager.h | 1 + 6 files changed, 24 insertions(+) diff --git a/src/bin/patchmanager-daemon/dbus/org.SfietKonstantin.patchmanager.xml b/src/bin/patchmanager-daemon/dbus/org.SfietKonstantin.patchmanager.xml index ae7e5b198..faa50d9c5 100644 --- a/src/bin/patchmanager-daemon/dbus/org.SfietKonstantin.patchmanager.xml +++ b/src/bin/patchmanager-daemon/dbus/org.SfietKonstantin.patchmanager.xml @@ -107,6 +107,9 @@ + + + diff --git a/src/bin/patchmanager-daemon/patchmanagerobject.cpp b/src/bin/patchmanager-daemon/patchmanagerobject.cpp index 8039944db..148d83cd6 100644 --- a/src/bin/patchmanager-daemon/patchmanagerobject.cpp +++ b/src/bin/patchmanager-daemon/patchmanagerobject.cpp @@ -1355,6 +1355,12 @@ bool PatchManagerObject::getLoaded() const return m_serverThread->isRunning(); } +void PatchManagerObject::revertToLastGood() +{ + m_appliedPatches = getLastGoodPatches(); + setAppliedPatches(m_appliedPatches); +} + void PatchManagerObject::resolveFailure() { qDebug() << Q_FUNC_INFO; diff --git a/src/bin/patchmanager-daemon/patchmanagerobject.h b/src/bin/patchmanager-daemon/patchmanagerobject.h index 7876d320b..ffe29b693 100644 --- a/src/bin/patchmanager-daemon/patchmanagerobject.h +++ b/src/bin/patchmanager-daemon/patchmanagerobject.h @@ -129,6 +129,7 @@ public slots: bool getFailure() const; bool getLoaded() const; void resolveFailure(); + void revertToLastGood(); void loadRequest(bool apply); void lipstickChanged(const QString &state); diff --git a/src/qml/PatchManagerPage.qml b/src/qml/PatchManagerPage.qml index eb810835f..9aec60472 100644 --- a/src/qml/PatchManagerPage.qml +++ b/src/qml/PatchManagerPage.qml @@ -201,6 +201,12 @@ Page { onClicked: pageStack.push(Qt.resolvedUrl("RestartServicesDialog.qml")) } + MenuItem { + text: qsTranslate("", "Load Pre-Failure List") + visible: PatchManager.failure + onClicked: menuRemorse.execute( text, function() { PatchManager.call(PatchManager.revertToLastGood()) } ) + } + MenuItem { text: qsTranslate("", "Resolve failure") visible: PatchManager.failure diff --git a/src/qml/patchmanager.cpp b/src/qml/patchmanager.cpp index db291f160..83738f8e3 100644 --- a/src/qml/patchmanager.cpp +++ b/src/qml/patchmanager.cpp @@ -661,6 +661,13 @@ void PatchManager::onLoadedChanged(bool loaded) emit loadedChanged(m_loaded); } +void PatchManager::revertToLastGood() +{ + qDebug() << Q_FUNC_INFO; + + m_interface->revertToLastGood(); +} + void PatchManager::resolveFailure() { qDebug() << Q_FUNC_INFO; diff --git a/src/qml/patchmanager.h b/src/qml/patchmanager.h index e980a67dc..d5af9e1d0 100644 --- a/src/qml/patchmanager.h +++ b/src/qml/patchmanager.h @@ -182,6 +182,7 @@ public slots: void onFailureChanged(bool failed); void onLoadedChanged(bool loaded); + void revertToLastGood(); void resolveFailure(); signals: