quickshell/modules/bar/Workspaces.qml

61 lines
1.9 KiB
QML
Raw Normal View History

pragma ComponentBehavior: Bound
import Quickshell.Hyprland
import Quickshell
import QtQuick
import qs
import qs.settings
import qs.reusables
Item {
id: root
implicitWidth: workspaceRow.implicitWidth
2026-01-21 18:11:12 +01:00
implicitHeight: workspaceRow.implicitHeight
anchors.verticalCenter: parent.verticalCenter
2026-01-23 16:34:15 +01:00
property var screen: screen
Row {
id: workspaceRow
anchors.centerIn: parent
2026-01-16 14:44:10 +01:00
spacing: 10 // Slightly increase spacing between workspace buttons
Repeater {
id: wsRepeater
model: Hyprland.workspaces
Rectangle {
id: workspaceNumber
2026-01-21 18:11:12 +01:00
anchors.verticalCenter: parent.verticalCenter
2026-01-16 14:44:10 +01:00
radius: 20
property bool isOnMon: {
if (!modelData)
return false;
if (!modelData.monitor)
return false;
if (!root.screen)
return false;
return modelData.monitor.name === root.screen.name;
}
required property var modelData
2026-01-16 14:44:10 +01:00
width: isOnMon ? Settings.config.barHeight - Settings.config.barHeight / 2 : 0
height: isOnMon ? Settings.config.barHeight - Settings.config.barHeight / 2 : 0
color: "transparent"
CustomText {
anchors.centerIn: workspaceNumber
text: parent.modelData.id
2026-01-23 16:34:15 +01:00
color: workspaceNumber.modelData.focused ? Colors.onSecondaryContainerColor : Colors.surfaceVariant
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: {
parent.modelData.activate();
}
}
}
}
}
}