mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
dbar: Refactor to memoize dbar & widget state via json
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user