Skip to content

Commit 20a77d0

Browse files
committed
feat: allow disabling preset auto-loading
1 parent 6de0278 commit 20a77d0

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

package/contents/ui/code/utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ function loadPreset(presetContent, item, ignoredConfigs, defaults, store) {
340340
}
341341

342342
function getPresetName(panelState, presetAutoloading) {
343+
if (presetAutoloading.hasOwnProperty("enabled") && !presetAutoloading.enabled) return null
343344
// loop until we find a the currently active 'true' panel state with a configured preset
344345
// normal is our fallback so does not need active state
345346
const priority = ["maximized", "touchingWindow", "floating", "normal"]

package/contents/ui/configPresetAutoload.qml

+20-8
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@ KCM.SimpleKCM {
8383
return 0;
8484
}
8585

86-
function dumpProps(obj) {
87-
console.error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
88-
for (var k of Object.keys(obj)) {
89-
print(k + "=" + obj[k]+"\n")
90-
}
91-
}
92-
9386
Component.onCompleted: {
9487
runCommand.run(cratePresetsDirCmd)
9588
runCommand.run(listPresetsCmd)
@@ -105,13 +98,28 @@ KCM.SimpleKCM {
10598

10699
ColumnLayout {
107100
enabled: cfg_isEnabled
101+
Kirigami.InlineMessage {
102+
Layout.fillWidth: true
103+
text: i18n("Disable preset auto-loading when making changes to presets, unsaved preset settings will be lost when presets change!")
104+
visible: true
105+
type: Kirigami.MessageType.Information
106+
}
108107
Label {
109108
text: i18n("Switch between different panel presets based on the Panel and window states")
110109
Layout.maximumWidth: root.width - (Kirigami.Units.gridUnit * 2)
111110
wrapMode: Text.Wrap
112111
}
113112

114113
Kirigami.FormLayout {
114+
CheckBox {
115+
id: enabledCheckbox
116+
Kirigami.FormData.label: i18n("Enabled:")
117+
checked: autoLoadConfig.enabled
118+
onCheckedChanged: {
119+
autoLoadConfig.enabled = checked
120+
updateConfig()
121+
}
122+
}
115123
Kirigami.ContextualHelpButton {
116124
toolTipText: i18n("Priorities go in descending order. E.g. if both <b>Maximized window is shown</b> and <b>Panel touching window</b> have a preset selected, and there is a maximized window on the screen, the <b>Maximized</b> preset will be applied.")
117125
}
@@ -124,6 +132,7 @@ KCM.SimpleKCM {
124132
updateConfig()
125133
}
126134
currentIndex: getIndex(model, autoLoadConfig.maximized)
135+
enabled: enabledCheckbox.checked
127136
}
128137

129138
CheckBox {
@@ -134,7 +143,7 @@ KCM.SimpleKCM {
134143
autoLoadConfig.maximizedFilterByActive = checked
135144
updateConfig()
136145
}
137-
enabled: autoLoadConfig.maximized ?? "" !== ""
146+
enabled: (autoLoadConfig.maximized ?? "" !== "") && enabledCheckbox.checked
138147
}
139148

140149
ComboBox {
@@ -146,6 +155,7 @@ KCM.SimpleKCM {
146155
updateConfig()
147156
}
148157
currentIndex: getIndex(model, autoLoadConfig.touchingWindow)
158+
enabled: enabledCheckbox.checked
149159
}
150160

151161
ComboBox {
@@ -157,6 +167,7 @@ KCM.SimpleKCM {
157167
updateConfig()
158168
}
159169
currentIndex: getIndex(model, autoLoadConfig.floating)
170+
enabled: enabledCheckbox.checked
160171
}
161172

162173
ComboBox {
@@ -168,6 +179,7 @@ KCM.SimpleKCM {
168179
updateConfig()
169180
}
170181
currentIndex: getIndex(model, autoLoadConfig.normal)
182+
enabled: enabledCheckbox.checked
171183
}
172184
}
173185
}

0 commit comments

Comments
 (0)