[plasma/discover] kcm/ui: kcm/updates: Fix incorrect text when changing update type

Nate Graham <[email protected]> Tue, 4 Aug 2026 18:07:56 +0000 (UTC)
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 044b7a6ff75ecd274fdbea1ea83841f1ac21660f by Nate Graham, on behalf of Tobias Ozór.
Committed on 04/08/2026 at 15:28.
Pushed by ngraham into branch 'master'.

kcm/updates: Fix incorrect text when changing update type

When a non-default value is selected for `Notification frequency`,
changing the `Update software` setting causes `Notification frequency`
to incorrectly display `Daily`.
Additionally, if `Notification frequency` is set to `Never`, changing
`Update software` to `Automatically` fails to set `Update frequency` to
a valid value. As a result, reloading the KCM leaves the combobox empty.

M  +17   -19   kcm/ui/main.qml

https://invent.kde.org/plasma/discover/-/commit/044b7a6ff75ecd274fdbea1ea83841f1ac21660f

diff --git a/kcm/ui/main.qml b/kcm/ui/main.qml
index 527fdd197..f834e6181 100644
--- a/kcm/ui/main.qml
+++ b/kcm/ui/main.qml
@@ -70,13 +70,16 @@ SimpleKCM {
         }
 
         QQC2.ComboBox {
+            id: frequencyComboBox
             Kirigami.FormData.label: kcm.updatesSettings.useUnattendedUpdates ? i18nc("@title:group", "Update frequency:") : i18nc("@title:group", "Notification frequency:")
+            textRole: "text"
+            valueRole: "value"
 
             readonly property var updatesFrequencyModel: [
-                i18nc("@item:inlistbox", "Daily"),
-                i18nc("@item:inlistbox", "Weekly"),
-                i18nc("@item:inlistbox", "Monthly"),
-                i18nc("@item:inlistbox", "Never")
+                { text: i18nc("@item:inlistbox", "Daily"),   value: 60 * 60 * 24 },
+                { text: i18nc("@item:inlistbox", "Weekly"),  value: 60 * 60 * 24 * 7 },
+                { text: i18nc("@item:inlistbox", "Monthly"), value: 60 * 60 * 24 * 30 },
+                { text: i18nc("@item:inlistbox", "Never"),   value: -1 },
             ]
 
             // Same as updatesFrequencyModel but without "Never"
@@ -88,25 +91,20 @@ SimpleKCM {
 
             model: kcm.updatesSettings.useUnattendedUpdates ? unattendedUpdatesFrequencyModel : updatesFrequencyModel
 
-            readonly property var options: [
-                60 * 60 * 24,
-                60 * 60 * 24 * 7,
-                60 * 60 * 24 * 30,
-                -1
-            ]
+            currentValue: kcm.updatesSettings.requiredNotificationInterval
+            onActivated:  kcm.updatesSettings.requiredNotificationInterval = currentValue
+
+            Connections {
+                target: kcm.updatesSettings
 
-            currentIndex: {
-                let index = -1
-                for (const i in options) {
-                    if (options[i] === kcm.updatesSettings.requiredNotificationInterval) {
-                        index = i
+                function onUseUnattendedUpdatesChanged() {
+                    if (kcm.updatesSettings.useUnattendedUpdates &&
+                        kcm.updatesSettings.requiredNotificationInterval === frequencyComboBox.updatesFrequencyModel[3].value) {
+                        kcm.updatesSettings.requiredNotificationInterval = frequencyComboBox.updatesFrequencyModel[0].value
                     }
                 }
-                return index
-            }
-            onActivated: index => {
-                kcm.updatesSettings.requiredNotificationInterval = options[index]
             }
+
             SettingStateBinding {
                 configObject: kcm.updatesSettings
                 settingName: "requiredNotificationInterval"