mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-18 09:14:01 -04:00
refactor(overflow): simplify dbar widgets overflow menu
This commit is contained in:
@@ -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)])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user