130 lines
2.7 KiB
QML
130 lines
2.7 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import qs.Helpers
|
|
import qs.Modules.SysTray.Widgets
|
|
import ZShell.Config
|
|
import qs.Components
|
|
import qs.Services
|
|
|
|
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: Tokens.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: Tokens.rounding.smallest / 2
|
|
color: Colors.tPalette.m3surfaceContainer
|
|
implicitHeight: Config.bar.height + Tokens.padding.smallest * 2
|
|
implicitWidth: row.implicitWidth + Tokens.padding.small * 2
|
|
radius: Tokens.rounding.full
|
|
topLeftRadius: Tokens.rounding.smallest / 2
|
|
|
|
RowLayout {
|
|
id: row
|
|
|
|
anchors.fill: parent
|
|
anchors.leftMargin: Tokens.padding.small
|
|
anchors.rightMargin: Tokens.padding.small
|
|
|
|
Repeater {
|
|
model: ScriptModel {
|
|
id: model
|
|
|
|
values: Config.bar.tray.statusIcons.values.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
|
|
}
|
|
}
|
|
}
|
|
}
|