quickshell/modules/bar/Workspaces.qml

70 lines
2.2 KiB
QML
Raw Normal View History

pragma ComponentBehavior: Bound
import Quickshell.Hyprland
import QtQuick
2026-02-07 23:50:10 +01:00
import QtQuick.Layouts
import qs
import qs.settings
import qs.reusables
2026-01-26 18:20:36 +01:00
Rectangle {
id: root
2026-01-26 18:20:36 +01:00
color: Colors.surfaceContainer
2026-02-09 20:35:38 +01:00
implicitWidth: workspaceRow.implicitWidth + 10
2026-02-06 14:05:29 +01:00
implicitHeight: Settings.config.barHeight - 10
2026-01-26 18:20:36 +01:00
radius: Settings.config.barHeight / 2
2026-01-23 16:34:15 +01:00
property var screen: screen
2026-02-08 00:37:29 +01:00
Row {
id: workspaceRow
anchors.centerIn: parent
2026-02-03 00:19:20 +01:00
spacing: 5 // Slightly increase spacing between workspace buttons
Repeater {
id: wsRepeater
model: Hyprland.workspaces
Rectangle {
id: workspaceNumber
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-02-09 22:54:58 +01:00
width: !modelData.focused ? 20 : 40
2026-01-16 14:44:10 +01:00
height: isOnMon ? Settings.config.barHeight - Settings.config.barHeight / 2 : 0
2026-02-12 00:24:00 +01:00
color: modelData.focused ? Colors.primary : Colors.surfaceContainer
2026-02-09 20:34:31 +01:00
Behavior on width {
NumberAnimation {
2026-02-09 22:54:58 +01:00
duration: 500
easing.type: Easing.InOutBack
2026-02-09 20:34:31 +01:00
}
}
CustomText {
anchors.centerIn: workspaceNumber
text: parent.modelData.id
2026-02-09 22:54:58 +01:00
color: parent.modelData.focused ? Colors.onPrimaryColor : Colors.onSurfaceColor
2026-01-26 18:20:36 +01:00
opacity: workspaceNumber.modelData.focused ? 1 : 0.5
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
cursorShape: Qt.PointingHandCursor
onClicked: {
parent.modelData.activate();
}
}
}
}
}
}