Files
quickshell/Bar/WorkspaceSelector.qml
2026-08-06 14:09:14 +01:00

71 lines
1.6 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Hyprland
import "../Color.js" as Colors
import "../Components/"
import "../Services/"
Container {
id: root
property double barHeight: 25
required property HyprlandMonitor monitor
property double rowLeftMargin: 5
property double workspaceButtonSpacing: 4
property double workspaceCount: WorkspaceManager.getNumberOfWorkspaces(monitor)
property double workspaceWidth: 17
boxHeight: barHeight
boxRadius: 8
boxWidth: (2 * rowLeftMargin) + (workspaceCount * workspaceWidth) + ((workspaceCount - 1)
* workspaceButtonSpacing)
exclusiveMonitor: monitor
RowLayout {
spacing: root.workspaceButtonSpacing
anchors {
bottom: parent.bottom
left: parent.left
leftMargin: root.rowLeftMargin
top: parent.top
}
Repeater {
delegate: workspaceButton
delegateModelAccess: DelegateModel.ReadOnly
model: WorkspaceManager.getWorkspacesForMonitor(root.exclusiveMonitor)
}
Component {
id: workspaceButton
Item {
id: buttonRoot
required property var modelData
property double stateInt: WorkspaceManager.getWorkspaceStateIndex(modelData)
property variant workspaceColors: [Colors.lavender, Colors.overlay2, Colors.surface2]
property string workspaceId: modelData.id
Layout.alignment: Qt.AlignLeft
height: root.barHeight - 7
implicitWidth: root.workspaceWidth
Rectangle {
anchors.fill: parent
color: buttonRoot.workspaceColors[buttonRoot.stateInt]
radius: 4
CenteredText {
text: buttonRoot.modelData.id
}
}
}
}
}
}