From d025ccdfc8b217b1ed7895c453efd54f5151915e Mon Sep 17 00:00:00 2001 From: purian23 Date: Sat, 3 Oct 2026 18:35:26 -0400 Subject: [PATCH] refactor(overflow): simplify dbar widgets overflow menu --- quickshell/Modules/Settings/BarWidgetTab.qml | 10 ++++++---- quickshell/tests/qml/settings-overflow.qml | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/quickshell/Modules/Settings/BarWidgetTab.qml b/quickshell/Modules/Settings/BarWidgetTab.qml index 3181c0af5..1af6815bd 100644 --- a/quickshell/Modules/Settings/BarWidgetTab.qml +++ b/quickshell/Modules/Settings/BarWidgetTab.qml @@ -154,16 +154,18 @@ Item { } SettingsDropdownRow { - readonly property var placementValues: ["section", "bar", "auto", "always"] - readonly property var placementLabels: [I18n.tr("Section default (%1)").arg(root.sectionAutoOverflow ? I18n.tr("Overflow when needed") : I18n.tr("Keep in Bar")), I18n.tr("Keep in Bar"), I18n.tr("Overflow when needed"), I18n.tr("Always in overflow")] + readonly property string sectionMode: root.sectionAutoOverflow ? "auto" : "bar" + readonly property var placementValues: ["section"].concat(["auto", "bar", "always"].filter(mode => mode !== sectionMode)) + readonly property var placementLabels: [sectionMode].concat(placementValues.slice(1)).map(mode => mode === "auto" ? I18n.tr("Auto") : mode === "bar" ? I18n.tr("Keep in Bar") : I18n.tr("Always in overflow")) + readonly property string placementValue: root.value("overflowMode") === sectionMode ? "section" : root.value("overflowMode") visible: !root.dockHosted && !OverflowLayout.pinned(root.widgetType) resetStore: root.store resetKeys: ["overflowMode"] text: I18n.tr("Placement") - description: I18n.tr("Move this widget into overflow when the bar runs out of space") + description: I18n.tr("Auto moves this widget into overflow when the bar runs out of space") options: placementLabels - currentValue: placementLabels[Math.max(0, placementValues.indexOf(root.value("overflowMode")))] + currentValue: placementLabels[Math.max(0, placementValues.indexOf(placementValue))] onValueChanged: value => root.set("overflowMode", placementValues[placementLabels.indexOf(value)]) } } diff --git a/quickshell/tests/qml/settings-overflow.qml b/quickshell/tests/qml/settings-overflow.qml index bd45e3d9c..200f01e25 100644 --- a/quickshell/tests/qml/settings-overflow.qml +++ b/quickshell/tests/qml/settings-overflow.qml @@ -79,6 +79,7 @@ ShellRoot { started = Date.now(); try { const config = SettingsData.getBarConfig(section.barId); + const placement = root.find(page, item => item.placementLabels !== undefined); switch (step) { case 0: root.check(page.entry && section.autoOverflow && section.overflowPosition === 2, "sections default to auto overflow"); @@ -89,12 +90,16 @@ ShellRoot { const position = root.find(section, item => item.positionLabels !== undefined); root.check(position.positionLabels.length === 3 && position.currentValue === position.positionLabels[2], "position dropdown lists the start and every entry, defaulting to the end"); root.check(section.overflowStore.isDefault(["leftOverflowMode", "leftOverflowPosition"]), "omitted section keys read as default"); + root.check(placement.placementLabels.length === 3 && placement.currentValue === "Auto" && placement.placementLabels.includes("Keep in Bar"), "placement leads with the section mode and lists no duplicate of it"); section.setOverflowOption("Mode", "bar"); position.valueChanged(position.positionLabels[1]); break; case 1: root.check(!section.autoOverflow && section.overflowPosition === 1, "section controls save and update their bindings"); root.check(!section.overflowStore.isDefault(["leftOverflowMode"]) && !section.overflowStore.isDefault(["leftOverflowPosition"]), "changed section keys are no longer default"); + root.check(placement.currentValue === "Keep in Bar" && placement.placementLabels.includes("Auto"), "placement follows the section when it switches to the bar"); + page.set("overflowMode", "bar"); + root.check(placement.currentValue === "Keep in Bar" && placement.placementValue === "section", "an explicit copy of the section mode shows as the section entry"); section.setOverflowOption("Mode", "auto"); section.overflowStore.resetToDefault(["leftOverflowPosition"]); root.check(config.leftWidgets.every(entry => typeof entry === "string"), "section-wide overflow does not rewrite each widget");