Skip to content

Commit

Permalink
feat: "Fullscreen window" preset auto-loading condition
Browse files Browse the repository at this point in the history
  • Loading branch information
luisbocanegra committed Jan 9, 2025
1 parent cc80c59 commit eba4a14
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions package/contents/ui/TasksModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Item {
property var screenGeometry
property bool activeExists: false
property bool maximizedExists: false
property bool fullscreenExists: false
property bool visibleExists: false
property var abstractTasksModel: TaskManager.AbstractTasksModel
property var isMaximized: abstractTasksModel.IsMaximized
Expand Down Expand Up @@ -86,6 +87,7 @@ Item {
let activeCount = 0
let visibleCount = 0
let maximizedCount = 0
let fullscreenCount = 0
for (var i = 0; i < tasksModel.count; i++) {
const currentTask = tasksModel.index(i, 0)
if (currentTask === undefined || !tasksModel.data(currentTask, isWindow)) continue
Expand All @@ -94,9 +96,11 @@ Item {
if (filterByActive && !active) continue
if (active) activeTask = currentTask
if (tasksModel.data(currentTask, isMaximized)) maximizedCount += 1
if (tasksModel.data(currentTask, isFullScreen)) fullscreenCount += 1
}
root.visibleExists = visibleCount > 0
root.maximizedExists = filterByActive ? tasksModel.data(activeTask, isMaximized) : maximizedCount > 0
root.fullscreenExists = filterByActive ? tasksModel.data(activeTask, isFullScreen) : fullscreenCount > 0
root.activeExists = activeCount > 0
}
}
Expand Down
2 changes: 1 addition & 1 deletion package/contents/ui/code/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function getPresetName(panelState, presetAutoloading) {
if (presetAutoloading.hasOwnProperty("enabled") && !presetAutoloading.enabled) return null
// loop until we find a the currently active 'true' panel state with a configured preset
// normal is our fallback so does not need active state
const priority = ["maximized", "touchingWindow", "visibleWindows", "floating", "normal"]
const priority = ["fullscreenWindow", "maximized", "touchingWindow", "visibleWindows", "floating", "normal"]
for (let state of priority) {
if ((panelState[state] || state === "normal") && presetAutoloading[state]) {
console.error("getPresetName()", state, "->", presetAutoloading[state])
Expand Down
12 changes: 12 additions & 0 deletions package/contents/ui/configPresetAutoload.qml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ KCM.SimpleKCM {
Kirigami.ContextualHelpButton {
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.")
}
ComboBox {
model: presetsModel
textRole: "name"
Kirigami.FormData.label: i18n("Fullscreen window:")
onCurrentIndexChanged: {
autoLoadConfig.fullscreenWindow = model.get(currentIndex)["value"]
updateConfig()
}
currentIndex: getIndex(model, autoLoadConfig.fullscreenWindow)
enabled: enabledCheckbox.checked
}

ComboBox {
model: presetsModel
textRole: "name"
Expand Down
5 changes: 5 additions & 0 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ PlasmoidItem {
StandardPaths.HomeLocation).toString().substring(7) + "/.config/panel-colorizer/presets/"
property var presetContent: ""
property var panelState: {
"fullscreenWindow": tasksModel.fullscreenExists,
"maximized": tasksModel.maximizedExists,
"visibleWindows": tasksModel.visibleExists,
"touchingWindow": !panelElement ? false : Boolean(panelElement.touchingWindow),
Expand Down Expand Up @@ -407,12 +408,16 @@ PlasmoidItem {
if (!fgEnabled && !inTray) {
return Kirigami.Theme.textColor
} else if ((!fgEnabled && inTray && widgetEnabled)) {
// inherit tray widget fg color to tray icons
return trayWidgetBgItem.fgColor
} else if (separateTray || cfgOverride) {
// passs override config
return getColor(rect.fgColorCfg, targetIndex, rect.color, itemType, fgColorHolder)
} else if (inTray) {
// pass tray icon index
return getColor(widgetSettings.foregroundColor, trayIndex, rect.color, itemType, fgColorHolder)
} else {
// pass regular widget index
return getColor(widgetSettings.foregroundColor, targetIndex, rect.color, itemType, fgColorHolder)
}
}
Expand Down

0 comments on commit eba4a14

Please sign in to comment.