pragma ComponentBehavior: Bound import Quickshell import QtQuick import QtQuick.Layouts import qs.Helpers import qs.Modules.SysTray.Widgets import qs.Config import qs.Components CustomClippingRect { id: root readonly property int firstPresent: { const values = model.values; for (let i = 0; i < values.length; i++) if (!collapsed(values[i])) return i; return -1; } required property bool horizontal // Index of the first/last entry that isn't collapsed, for edge margin gating readonly property alias items: grid readonly property int lastPresent: { const values = model.values; for (let i = values.length - 1; i >= 0; i--) if (!collapsed(values[i])) return i; return -1; } readonly property real shortSize: Config.bar.height + Appearance.padding.smallest * 2 readonly property real size: horizontal ? grid.implicitWidth + Appearance.padding.small * 2 : grid.implicitHeight + Appearance.padding.small * 2 readonly property int spacing: Appearance.spacing.normal / 2 // Entries that can shrink to nothing, spacing included function collapsed(entry: var): bool { if (entry.id === "lockStatus") return !Hypr.capsLock && !Hypr.numLock; return false; } anchors.fill: parent bottomLeftRadius: horizontal ? Appearance.rounding.smallest / 2 : Appearance.rounding.full color: DynamicColors.tPalette.m3surfaceContainer implicitHeight: horizontal ? shortSize : size implicitWidth: horizontal ? size : shortSize radius: Appearance.rounding.full topLeftRadius: Appearance.rounding.smallest / 2 topRightRadius: horizontal ? Appearance.rounding.full : Appearance.rounding.smallest / 2 Behavior on implicitHeight { enabled: !root.horizontal Anim { } } Behavior on implicitWidth { enabled: root.horizontal Anim { } } GridLayout { id: grid anchors.bottomMargin: root.horizontal ? 0 : Appearance.padding.small anchors.fill: parent anchors.leftMargin: root.horizontal ? Appearance.padding.small : 0 anchors.rightMargin: root.horizontal ? Appearance.padding.small : 0 anchors.topMargin: root.horizontal ? 0 : Appearance.padding.small columns: root.horizontal ? -1 : 1 Repeater { model: ScriptModel { id: model values: Config.bar.tray.statusIcons.filter(e => e.enabled) } DelegateChooser { role: "id" DelegateChoice { roleValue: "audio" delegate: EntryWrapper { name: "audio" AudioWidget { horizontal: root.horizontal } } } DelegateChoice { roleValue: "microphone" delegate: EntryWrapper { name: "audio" MicWidget { horizontal: root.horizontal } } } DelegateChoice { roleValue: "power" delegate: EntryWrapper { name: "upower" UPowerWidget { horizontal: root.horizontal } } } } } } component EntryWrapper: Item { required property int index default property Item item property real leftGap: present && index !== root.lastPresent ? margin : 0 property int margin: root.spacing / 2 required property var modelData property string name: modelData.id.toLowerCase() readonly property bool present: !root.collapsed(modelData) property real rightGap: present && index !== root.firstPresent ? margin : 0 Layout.alignment: Qt.AlignHCenter Layout.bottomMargin: root.horizontal ? 0 : Math.round(rightGap) Layout.leftMargin: root.horizontal ? Math.round(leftGap) : 0 Layout.rightMargin: root.horizontal ? Math.round(rightGap) : 0 Layout.topMargin: root.horizontal ? 0 : Math.round(leftGap) children: item implicitHeight: item?.implicitHeight ?? 0 implicitWidth: item?.implicitWidth ?? 0 Behavior on leftGap { Anim { type: Anim.SlowEffects } } Behavior on rightGap { Anim { type: Anim.SlowEffects } } } }