mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-06 05:42:07 -04:00
dbar: Refactor to memoize dbar & widget state via json
This commit is contained in:
@@ -152,21 +152,35 @@ 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;
|
||||
if (aVertical !== bVertical) {
|
||||
return aVertical - bVertical;
|
||||
}
|
||||
return String(a.id).localeCompare(String(b.id));
|
||||
});
|
||||
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 +227,6 @@ Item {
|
||||
PolkitService.polkitAvailable;
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsData
|
||||
function onBarConfigsChanged() {
|
||||
dockRecreateDebounce.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: dockLoader
|
||||
active: root.dockEnabled
|
||||
|
||||
Reference in New Issue
Block a user