Skip to content

Commit 3f24cf3

Browse files
committed
settings: make horizontal change more smart
1 parent 01218f3 commit 3f24cf3

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

quickshell/Modules/Settings/DankBarTab.qml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,34 @@ Item {
5151
}
5252
}
5353

54+
function _isBarActive(c) {
55+
if (!c.enabled) return false;
56+
const prefs = c.screenPreferences || ["all"];
57+
if (prefs.length > 0) return true;
58+
return (c.showOnLastDisplay ?? true) && Quickshell.screens.length === 1;
59+
}
60+
5461
function notifyHorizontalBarChange() {
55-
if (selectedBarIsVertical)
62+
const configs = SettingsData.barConfigs;
63+
if (configs.length < 2)
64+
return;
65+
66+
const hasHorizontal = configs.some(c => {
67+
if (!_isBarActive(c)) return false;
68+
const p = c.position ?? SettingsData.Position.Top;
69+
return p === SettingsData.Position.Top || p === SettingsData.Position.Bottom;
70+
});
71+
if (!hasHorizontal)
5672
return;
73+
74+
const hasVertical = configs.some(c => {
75+
if (!_isBarActive(c)) return false;
76+
const p = c.position ?? SettingsData.Position.Top;
77+
return p === SettingsData.Position.Left || p === SettingsData.Position.Right;
78+
});
79+
if (!hasVertical)
80+
return;
81+
5782
horizontalBarChangeDebounce.restart();
5883
}
5984

@@ -147,6 +172,7 @@ Item {
147172
SettingsData.updateBarConfig(barId, {
148173
screenPreferences: prefs
149174
});
175+
notifyHorizontalBarChange();
150176
}
151177

152178
function getBarShowOnLastDisplay(barId) {
@@ -158,6 +184,8 @@ Item {
158184
SettingsData.updateBarConfig(barId, {
159185
showOnLastDisplay: value
160186
});
187+
if (Quickshell.screens.length === 1)
188+
notifyHorizontalBarChange();
161189
}
162190

163191
DankFlickable {
@@ -539,13 +567,10 @@ Item {
539567
newPos = SettingsData.Position.Right;
540568
break;
541569
}
542-
const wasVertical = selectedBarIsVertical;
543570
SettingsData.updateBarConfig(selectedBarId, {
544571
position: newPos
545572
});
546-
const isVertical = newPos === SettingsData.Position.Left || newPos === SettingsData.Position.Right;
547-
if (wasVertical !== isVertical || !isVertical)
548-
notifyHorizontalBarChange();
573+
notifyHorizontalBarChange();
549574
}
550575
}
551576
}

0 commit comments

Comments
 (0)