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:
@@ -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() {
|
function notifyHorizontalBarChange() {
|
||||||
if (selectedBarIsVertical)
|
const configs = SettingsData.barConfigs;
|
||||||
|
if (configs.length < 2)
|
||||||
return;
|
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();
|
horizontalBarChangeDebounce.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,6 +172,7 @@ Item {
|
|||||||
SettingsData.updateBarConfig(barId, {
|
SettingsData.updateBarConfig(barId, {
|
||||||
screenPreferences: prefs
|
screenPreferences: prefs
|
||||||
});
|
});
|
||||||
|
notifyHorizontalBarChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBarShowOnLastDisplay(barId) {
|
function getBarShowOnLastDisplay(barId) {
|
||||||
@@ -158,6 +184,8 @@ Item {
|
|||||||
SettingsData.updateBarConfig(barId, {
|
SettingsData.updateBarConfig(barId, {
|
||||||
showOnLastDisplay: value
|
showOnLastDisplay: value
|
||||||
});
|
});
|
||||||
|
if (Quickshell.screens.length === 1)
|
||||||
|
notifyHorizontalBarChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
DankFlickable {
|
DankFlickable {
|
||||||
@@ -539,13 +567,10 @@ Item {
|
|||||||
newPos = SettingsData.Position.Right;
|
newPos = SettingsData.Position.Right;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const wasVertical = selectedBarIsVertical;
|
|
||||||
SettingsData.updateBarConfig(selectedBarId, {
|
SettingsData.updateBarConfig(selectedBarId, {
|
||||||
position: newPos
|
position: newPos
|
||||||
});
|
});
|
||||||
const isVertical = newPos === SettingsData.Position.Left || newPos === SettingsData.Position.Right;
|
notifyHorizontalBarChange();
|
||||||
if (wasVertical !== isVertical || !isVertical)
|
|
||||||
notifyHorizontalBarChange();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user