quickshell/modules/bar/Workspaces.qml

59 lines
1.8 KiB
QML

pragma ComponentBehavior: Bound
import "../../reusables/"
import Quickshell.Hyprland
import Quickshell
import QtQuick
import "../../"
import "../../settings/"
Item {
id: root
implicitWidth: workspaceRow.implicitWidth
height: 30
Row {
id: workspaceRow
anchors.centerIn: parent
spacing: 10 // Slightly increase spacing between workspace buttons
Repeater {
id: wsRepeater
model: Hyprland.workspaces
anchors.centerIn: parent
Rectangle {
id: workspaceNumber
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
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
color: Colors.foreground // Set contrasting color for workspace number
opacity: workspaceNumber.modelData.focused ? 1 : 0.5
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onClicked: {
parent.modelData.activate();
}
}
}
}
}
}