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; } // Index of the first/last entry that isn't collapsed, for edge margin gating readonly property alias items: row 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 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; } bottomLeftRadius: Appearance.rounding.smallest / 2 color: DynamicColors.tPalette.m3surfaceContainer implicitHeight: Config.bar.height + Appearance.padding.smallest * 2 implicitWidth: row.implicitWidth + Appearance.padding.small * 2 radius: Appearance.rounding.full topLeftRadius: Appearance.rounding.smallest / 2 RowLayout { id: row anchors.fill: parent anchors.leftMargin: Appearance.padding.small anchors.rightMargin: Appearance.padding.small 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 { } } } DelegateChoice { roleValue: "microphone" delegate: EntryWrapper { name: "audio" MicWidget { } } } DelegateChoice { roleValue: "power" delegate: EntryWrapper { name: "upower" UPowerWidget { } } } } } } 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.leftMargin: Math.round(leftGap) Layout.rightMargin: Math.round(rightGap) children: item implicitHeight: item?.implicitHeight ?? 0 implicitWidth: item?.implicitWidth ?? 0 Behavior on leftGap { Anim { type: Anim.SlowEffects } } Behavior on rightGap { Anim { type: Anim.SlowEffects } } } }