import QtQuick import Quickshell.Hyprland Item { id: root required property var workspaces required property color accentColor required property color fgColor required property string fontFamily width: workspacesRow.width height: 22 Rectangle { id: wsHighlight height: 22 color: root.accentColor z: 0 visible: targetWidth > 0 property real targetX: 0 property real targetWidth: 0 x: targetX width: targetWidth topLeftRadius: 4 bottomLeftRadius: 4 topRightRadius: 4 bottomRightRadius: 4 Behavior on x { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } Behavior on width { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } Behavior on topLeftRadius { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } Behavior on bottomLeftRadius { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } Behavior on topRightRadius { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } Behavior on bottomRightRadius { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } } Row { id: workspacesRow spacing: 5 z: 1 Repeater { model: root.workspaces delegate: Item { required property var modelData required property int index width: wsText.implicitWidth + 20 height: 22 property bool isActive: modelData.active Component.onCompleted: if (isActive) updateSlider() onIsActiveChanged: if (isActive) updateSlider() onXChanged: if (isActive) updateSlider() onWidthChanged: if (isActive) updateSlider() function updateSlider() { let isOnly = root.workspaces.length === 1 let isFirst = index === 0 let isLast = index === root.workspaces.length - 1 wsHighlight.targetX = x wsHighlight.targetWidth = width wsHighlight.topLeftRadius = isOnly ? 100 : (isFirst ? 100 : 4) wsHighlight.bottomLeftRadius = isOnly ? 100 : (isFirst ? 100 : 4) wsHighlight.topRightRadius = isOnly ? 100 : (isLast ? 100 : 4) wsHighlight.bottomRightRadius = isOnly ? 100 : (isLast ? 100 : 4) } Text { id: wsText anchors.centerIn: parent text: modelData.name color: root.fgColor font.pixelSize: 12 font.family: root.fontFamily } MouseArea { anchors.fill: parent cursorShape: Qt.PointingHandCursor onClicked: Hyprland.dispatch("workspace " + modelData.id) } } } } }