1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

settings: make horizontal change more smart

This commit is contained in:
bbedward
2026-02-24 20:48:42 -05:00
parent 01218f34cb
commit 3f24cf37ca

View File

@@ -51,9 +51,34 @@ Item {
}
}
function _isBarActive(c) {
if (!c.enabled) return false;
const prefs = c.screenPreferences || ["all"];
if (prefs.length > 0) return true;
return (c.showOnLastDisplay ?? true) && Quickshell.screens.length === 1;
}
function notifyHorizontalBarChange() {
if (selectedBarIsVertical)
const configs = SettingsData.barConfigs;
if (configs.length < 2)
return;
const hasHorizontal = configs.some(c => {
if (!_isBarActive(c)) return false;
const p = c.position ?? SettingsData.Position.Top;
return p === SettingsData.Position.Top || p === SettingsData.Position.Bottom;
});
if (!hasHorizontal)
return;
const hasVertical = configs.some(c => {
if (!_isBarActive(c)) return false;
const p = c.position ?? SettingsData.Position.Top;
return p === SettingsData.Position.Left || p === SettingsData.Position.Right;
});
if (!hasVertical)
return;
horizontalBarChangeDebounce.restart();
}
@@ -147,6 +172,7 @@ Item {
SettingsData.updateBarConfig(barId, {
screenPreferences: prefs
});
notifyHorizontalBarChange();
}
function getBarShowOnLastDisplay(barId) {
@@ -158,6 +184,8 @@ Item {
SettingsData.updateBarConfig(barId, {
showOnLastDisplay: value
});
if (Quickshell.screens.length === 1)
notifyHorizontalBarChange();
}
DankFlickable {
@@ -539,13 +567,10 @@ Item {
newPos = SettingsData.Position.Right;
break;
}
const wasVertical = selectedBarIsVertical;
SettingsData.updateBarConfig(selectedBarId, {
position: newPos
});
const isVertical = newPos === SettingsData.Position.Left || newPos === SettingsData.Position.Right;
if (wasVertical !== isVertical || !isVertical)
notifyHorizontalBarChange();
notifyHorizontalBarChange();
}
}
}