Commit 41770e25 authored by Méven Car's avatar Méven Car Committed by Nate Graham
Browse files

KCM: better handle revert timer and buttons

BUG: 447199
FIXED-IN: 5.23.5

The issue was that the `revertSettings` method was called when the timer timed
out, the settings were reverted, the confirmMsg overlay closed and called a
second time `revertSettings` when the kcm backend has not been reloaded yet.

This makes sure this won't happen, as either the timer of the revert button
will revert the Settings but not simply closing `confirmMsg. This makes the
code simpler by removing book keeping but instead using only the events.
parent 99398762
Pipeline #116188 passed with stage
in 1 minute and 35 seconds
......@@ -86,26 +86,12 @@ KCM.SimpleKCM {
}
Kirigami.OverlaySheet {
id: confirmMsg
property bool keepConfig: false
property bool userInteraction: false
parent: root
title: i18n("Keep display configuration?")
onSheetOpenChanged: {
if (sheetOpen) {
revertButton.forceActiveFocus()
confirmMsg.keepConfig = false
confirmMsg.userInteraction = false
} else {
if (!confirmMsg.keepConfig) {
kcm.revertSettings()
if (!confirmMsg.userInteraction) {
revertMsg.visible = true
}
kcm.setStopUpdatesFromBackend(false)
} else {
kcm.setStopUpdatesFromBackend(false)
kcm.updateFromBackend()
}
revertTimer.stop()
}
}
......@@ -139,8 +125,6 @@ KCM.SimpleKCM {
icon.name: "dialog-ok"
text: i18n("&Keep")
onTriggered: {
confirmMsg.keepConfig = true
confirmMsg.userInteraction = true
confirmMsg.close()
}
}
......@@ -160,8 +144,9 @@ KCM.SimpleKCM {
text: i18n("&Revert")
shortcut: "Escape"
onTriggered: {
confirmMsg.userInteraction = true
confirmMsg.close()
revertTimer.stop()
kcm.setStopUpdatesFromBackend(false)
kcm.revertSettings()
}
}
}
......@@ -193,6 +178,7 @@ KCM.SimpleKCM {
}
function onSettingsReverted() {
confirmMsg.close();
revertMsg.visible = true;
}
function onShowRevertWarning() {
revertCountdown = 15;
......@@ -233,9 +219,8 @@ KCM.SimpleKCM {
onTriggered: {
revertCountdown -= 1;
if (revertCountdown < 1) {
this.stop();
revertTimer.stop();
kcm.revertSettings();
return;
}
}
}
......
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