Skip to content

Commit d930925

Browse files
committed
feat: "At least one window is shown" preset auto-loading condition
closes: #132
1 parent ec3bd10 commit d930925

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

package/contents/ui/TasksModel.qml

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Item {
9090
const currentTask = tasksModel.index(i, 0)
9191
if (currentTask === undefined || !tasksModel.data(currentTask, isWindow)) continue
9292
const active = tasksModel.data(currentTask, isActive)
93+
if (!tasksModel.data(currentTask, isMinimized)) visibleCount += 1
9394
if (filterByActive && !active) continue
9495
if (active) activeTask = currentTask
9596
if (tasksModel.data(currentTask, isMaximized)) maximizedCount += 1

package/contents/ui/code/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ function getPresetName(panelState, presetAutoloading) {
358358
if (presetAutoloading.hasOwnProperty("enabled") && !presetAutoloading.enabled) return null
359359
// loop until we find a the currently active 'true' panel state with a configured preset
360360
// normal is our fallback so does not need active state
361-
const priority = ["maximized", "touchingWindow", "floating", "normal"]
361+
const priority = ["maximized", "touchingWindow", "visibleWindows", "floating", "normal"]
362362
for (let state of priority) {
363363
if ((panelState[state] || state === "normal") && presetAutoloading[state]) {
364364
console.error("getPresetName()", state, "->", presetAutoloading[state])

package/contents/ui/configPresetAutoload.qml

+12
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,18 @@ KCM.SimpleKCM {
158158
enabled: enabledCheckbox.checked
159159
}
160160

161+
ComboBox {
162+
model: presetsModel
163+
textRole: "name"
164+
Kirigami.FormData.label: i18n("At least one window is shown:")
165+
onCurrentIndexChanged: {
166+
autoLoadConfig.visibleWindows = model.get(currentIndex)["value"]
167+
updateConfig()
168+
}
169+
currentIndex: getIndex(model, autoLoadConfig.visibleWindows)
170+
enabled: enabledCheckbox.checked
171+
}
172+
161173
ComboBox {
162174
model: presetsModel
163175
textRole: "name"

package/contents/ui/main.qml

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ PlasmoidItem {
6969
property var presetContent: ""
7070
property var panelState: {
7171
"maximized": tasksModel.maximizedExists,
72+
"visibleWindows": tasksModel.visibleExists,
7273
"touchingWindow": !panelElement ? false : Boolean(panelElement.touchingWindow),
7374
"floating": !panelElement ? false : Boolean(panelElement.floatingness)
7475
}

0 commit comments

Comments
 (0)