diff --git a/quickshell/DMSShell.qml b/quickshell/DMSShell.qml index e33e3f17..8641c816 100644 --- a/quickshell/DMSShell.qml +++ b/quickshell/DMSShell.qml @@ -152,21 +152,32 @@ Item { } } + property string _barLayoutStateJson: { + const configs = SettingsData.barConfigs; + const mapped = configs.map(c => ({ + id: c.id, + position: c.position, + autoHide: c.autoHide, + visible: c.visible + })).sort((a, b) => { + const aVertical = a.position === SettingsData.Position.Left || a.position === SettingsData.Position.Right; + const bVertical = b.position === SettingsData.Position.Left || b.position === SettingsData.Position.Right; + return aVertical - bVertical; + }); + return JSON.stringify(mapped); + } + + on_BarLayoutStateJsonChanged: { + if (typeof dockRecreateDebounce !== "undefined") { + dockRecreateDebounce.restart(); + } + } + Repeater { id: dankBarRepeater model: ScriptModel { id: barRepeaterModel - values: { - const configs = SettingsData.barConfigs; - return configs.map(c => ({ - id: c.id, - position: c.position - })).sort((a, b) => { - const aVertical = a.position === SettingsData.Position.Left || a.position === SettingsData.Position.Right; - const bVertical = b.position === SettingsData.Position.Left || b.position === SettingsData.Position.Right; - return aVertical - bVertical; - }); - } + values: JSON.parse(root._barLayoutStateJson) } property var hyprlandOverviewLoaderRef: hyprlandOverviewLoader @@ -213,13 +224,6 @@ Item { PolkitService.polkitAvailable; } - Connections { - target: SettingsData - function onBarConfigsChanged() { - dockRecreateDebounce.restart(); - } - } - Loader { id: dockLoader active: root.dockEnabled diff --git a/quickshell/Modules/DankBar/DankBar.qml b/quickshell/Modules/DankBar/DankBar.qml index b3534ec3..392bf9b7 100644 --- a/quickshell/Modules/DankBar/DankBar.qml +++ b/quickshell/Modules/DankBar/DankBar.qml @@ -21,73 +21,82 @@ Item { property alias centerWidgetsModel: centerWidgetsModel property alias rightWidgetsModel: rightWidgetsModel + property string _leftWidgetsJson: { + root.barConfig; + const leftWidgets = root.barConfig?.leftWidgets || []; + const mapped = leftWidgets.map((w, index) => { + if (typeof w === "string") { + return { + widgetId: w, + id: w + "_" + index, + enabled: true + }; + } else { + const obj = Object.assign({}, w); + obj.widgetId = w.id || w.widgetId; + obj.id = (w.id || w.widgetId) + "_" + index; + obj.enabled = w.enabled !== false; + return obj; + } + }); + return JSON.stringify(mapped); + } + + property string _centerWidgetsJson: { + root.barConfig; + const centerWidgets = root.barConfig?.centerWidgets || []; + const mapped = centerWidgets.map((w, index) => { + if (typeof w === "string") { + return { + widgetId: w, + id: w + "_" + index, + enabled: true + }; + } else { + const obj = Object.assign({}, w); + obj.widgetId = w.id || w.widgetId; + obj.id = (w.id || w.widgetId) + "_" + index; + obj.enabled = w.enabled !== false; + return obj; + } + }); + return JSON.stringify(mapped); + } + + property string _rightWidgetsJson: { + root.barConfig; + const rightWidgets = root.barConfig?.rightWidgets || []; + const mapped = rightWidgets.map((w, index) => { + if (typeof w === "string") { + return { + widgetId: w, + id: w + "_" + index, + enabled: true + }; + } else { + const obj = Object.assign({}, w); + obj.widgetId = w.id || w.widgetId; + obj.id = (w.id || w.widgetId) + "_" + index; + obj.enabled = w.enabled !== false; + return obj; + } + }); + return JSON.stringify(mapped); + } + ScriptModel { id: leftWidgetsModel - values: { - root.barConfig; - const leftWidgets = root.barConfig?.leftWidgets || []; - return leftWidgets.map((w, index) => { - if (typeof w === "string") { - return { - widgetId: w, - id: w + "_" + index, - enabled: true - }; - } else { - const obj = Object.assign({}, w); - obj.widgetId = w.id || w.widgetId; - obj.id = (w.id || w.widgetId) + "_" + index; - obj.enabled = w.enabled !== false; - return obj; - } - }); - } + values: JSON.parse(root._leftWidgetsJson) } ScriptModel { id: centerWidgetsModel - values: { - root.barConfig; - const centerWidgets = root.barConfig?.centerWidgets || []; - return centerWidgets.map((w, index) => { - if (typeof w === "string") { - return { - widgetId: w, - id: w + "_" + index, - enabled: true - }; - } else { - const obj = Object.assign({}, w); - obj.widgetId = w.id || w.widgetId; - obj.id = (w.id || w.widgetId) + "_" + index; - obj.enabled = w.enabled !== false; - return obj; - } - }); - } + values: JSON.parse(root._centerWidgetsJson) } ScriptModel { id: rightWidgetsModel - values: { - root.barConfig; - const rightWidgets = root.barConfig?.rightWidgets || []; - return rightWidgets.map((w, index) => { - if (typeof w === "string") { - return { - widgetId: w, - id: w + "_" + index, - enabled: true - }; - } else { - const obj = Object.assign({}, w); - obj.widgetId = w.id || w.widgetId; - obj.id = (w.id || w.widgetId) + "_" + index; - obj.enabled = w.enabled !== false; - return obj; - } - }); - } + values: JSON.parse(root._rightWidgetsJson) } function triggerControlCenterOnFocusedScreen() { diff --git a/quickshell/Modules/Settings/DankBarTab.qml b/quickshell/Modules/Settings/DankBarTab.qml index 82ebf8c2..7457fe24 100644 --- a/quickshell/Modules/Settings/DankBarTab.qml +++ b/quickshell/Modules/Settings/DankBarTab.qml @@ -28,35 +28,6 @@ Item { return pos === SettingsData.Position.Left || pos === SettingsData.Position.Right; } - Timer { - id: horizontalBarChangeDebounce - interval: 500 - repeat: false - onTriggered: { - const verticalBars = SettingsData.barConfigs.filter(cfg => { - const pos = cfg.position ?? SettingsData.Position.Top; - return pos === SettingsData.Position.Left || pos === SettingsData.Position.Right; - }); - - verticalBars.forEach(bar => { - if (!bar.enabled) - return; - SettingsData.updateBarConfig(bar.id, { - enabled: false - }); - Qt.callLater(() => SettingsData.updateBarConfig(bar.id, { - enabled: true - })); - }); - } - } - - function notifyHorizontalBarChange() { - if (selectedBarIsVertical) - return; - horizontalBarChangeDebounce.restart(); - } - function createNewBar() { if (SettingsData.barConfigs.length >= 4) return; @@ -543,9 +514,6 @@ Item { SettingsData.updateBarConfig(selectedBarId, { position: newPos }); - const isVertical = newPos === SettingsData.Position.Left || newPos === SettingsData.Position.Right; - if (wasVertical !== isVertical || !isVertical) - notifyHorizontalBarChange(); } } } @@ -564,7 +532,6 @@ Item { SettingsData.updateBarConfig(selectedBarId, { autoHide: toggled }); - notifyHorizontalBarChange(); } } @@ -631,7 +598,6 @@ Item { SettingsData.updateBarConfig(selectedBarId, { visible: toggled }); - notifyHorizontalBarChange(); } } @@ -923,9 +889,9 @@ Item { value: Math.round((selectedBarConfig?.fontScale ?? 1.0) * 100) unit: "%" defaultValue: 100 - onSliderDragFinished: finalValue => { + onSliderValueChanged: newValue => { SettingsData.updateBarConfig(selectedBarId, { - fontScale: finalValue / 100 + fontScale: newValue / 100 }); } @@ -948,9 +914,9 @@ Item { value: Math.round((selectedBarConfig?.iconScale ?? 1.0) * 100) unit: "%" defaultValue: 100 - onSliderDragFinished: finalValue => { + onSliderValueChanged: newValue => { SettingsData.updateBarConfig(selectedBarId, { - iconScale: finalValue / 100 + iconScale: newValue / 100 }); }