nosignal-shell/modules/bar/workspaces/OccupiedBg.qml
2025-04-28 19:54:47 +10:00

52 lines
1.7 KiB
QML

import "root:/widgets"
import "root:/services"
import "root:/config"
import QtQuick
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
BoxLayout {
id: root
required property bool vertical
required property list<Label> workspaces
required property BoxLayout layout
readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
acc[curr.id] = curr.lastIpcObject.windows > 0;
return acc;
}, {})
anchors.centerIn: parent
spacing: 0
z: -1
Repeater {
model: BarConfig.workspaces.shown
Rectangle {
required property int index
readonly property int roundLeft: index === 0 || !root.occupied[index] ? Appearance.rounding.full : 0
readonly property int roundRight: index === BarConfig.workspaces.shown - 1 || !root.occupied[index + 2] ? Appearance.rounding.full : 0
color: Appearance.alpha(Appearance.colours.surface2, true)
opacity: root.occupied[index + 1] ? 1 : 0
topLeftRadius: roundLeft
bottomLeftRadius: roundLeft
topRightRadius: roundRight
bottomRightRadius: roundRight
// Ugh stupid size errors on reload
Layout.preferredWidth: root.vertical ? layout.width : root.workspaces[index]?.width ?? 1
Layout.preferredHeight: root.vertical ? root.workspaces[index]?.height ?? 1 : layout.height
Behavior on opacity {
NumberAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
}
}
}