diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-25 16:14:24 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-25 16:14:24 +1000 |
| commit | d191ac44b566f452757289b59704b64ad4dc10bb (patch) | |
| tree | d6f23f2394fab47c84ab5999ce60011ece661c2b /modules/bar/Bar.qml | |
| parent | readme: update example config (#693) (diff) | |
| download | caelestia-shell-d191ac44b566f452757289b59704b64ad4dc10bb.tar.gz caelestia-shell-d191ac44b566f452757289b59704b64ad4dc10bb.tar.bz2 caelestia-shell-d191ac44b566f452757289b59704b64ad4dc10bb.zip | |
bar: add compact tray option
Closes #659
Diffstat (limited to 'modules/bar/Bar.qml')
| -rw-r--r-- | modules/bar/Bar.qml | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index ea7ec7f..64b1d86 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -17,8 +17,24 @@ ColumnLayout { required property BarPopouts.Wrapper popouts readonly property int vPadding: Appearance.padding.large + function closeTray(): void { + if (!Config.bar.tray.compact) + return; + + for (let i = 0; i < repeater.count; i++) { + const item = repeater.itemAt(i); + if (item?.enabled && item.id === "tray") { + item.item.expanded = false; + } + } + } + function checkPopout(y: real): void { const ch = childAt(width / 2, y) as WrappedLoader; + + if (ch?.id !== "tray") + closeTray(); + if (!ch) { popouts.hasCurrent = false; return; @@ -38,12 +54,19 @@ ColumnLayout { popouts.hasCurrent = true; } } else if (id === "tray") { - const index = Math.floor(((y - top) / itemHeight) * item.items.count); - const trayItem = item.items.itemAt(index); - if (trayItem) { - popouts.currentName = `traymenu${index}`; - popouts.currentCenter = Qt.binding(() => trayItem.mapToItem(root, 0, trayItem.implicitHeight / 2).y); - popouts.hasCurrent = true; + if (!Config.bar.tray.compact || (item.expanded && !item.expandIcon.contains(mapToItem(item.expandIcon, item.implicitWidth / 2, y)))) { + const index = Math.floor(((y - top - item.padding * 2 + item.spacing) / item.layout.implicitHeight) * item.items.count); + const trayItem = item.items.itemAt(index); + if (trayItem) { + popouts.currentName = `traymenu${index}`; + popouts.currentCenter = Qt.binding(() => trayItem.mapToItem(root, 0, trayItem.implicitHeight / 2).y); + popouts.hasCurrent = true; + } else { + popouts.hasCurrent = false; + } + } else { + popouts.hasCurrent = false; + item.expanded = true; } } else if (id === "activeWindow") { popouts.currentName = id.toLowerCase(); |