functional workspace display

This commit is contained in:
2026-08-06 14:09:14 +01:00
parent 8e59d2dcec
commit abe1a1e12f
2 changed files with 47 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Hyprland import Quickshell.Hyprland
@@ -10,32 +11,58 @@ import "../Services/"
Container { Container {
id: root id: root
property double barHeight: 25
required property HyprlandMonitor monitor required property HyprlandMonitor monitor
property double rowLeftMargin: 5
property double workspaceButtonSpacing: 4
property double workspaceCount: WorkspaceManager.getNumberOfWorkspaces(monitor)
property double workspaceWidth: 17
boxHeight: 25 boxHeight: barHeight
boxRadius: 8
boxWidth: (2 * rowLeftMargin) + (workspaceCount * workspaceWidth) + ((workspaceCount - 1)
* workspaceButtonSpacing)
exclusiveMonitor: monitor exclusiveMonitor: monitor
Row { RowLayout {
spacing: 3 spacing: root.workspaceButtonSpacing
anchors {
bottom: parent.bottom
left: parent.left
leftMargin: root.rowLeftMargin
top: parent.top
}
Repeater { Repeater {
delegate: workspaceButton delegate: workspaceButton
delegateModelAccess: DelegateModel.ReadOnly
model: WorkspaceManager.getWorkspacesForMonitor(root.exclusiveMonitor) model: WorkspaceManager.getWorkspacesForMonitor(root.exclusiveMonitor)
delegateModelAccess: DelegateModel.ReadOnly
} }
Component { Component {
id: workspaceButton id: workspaceButton
Item { Item {
required property var modelData id: buttonRoot
height: 10 required property var modelData
width: 10 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 { Rectangle {
anchors.fill: parent anchors.fill: parent
color: "red" color: buttonRoot.workspaceColors[buttonRoot.stateInt]
radius: 4
CenteredText {
text: buttonRoot.modelData.id
}
} }
} }
} }

View File

@@ -62,6 +62,17 @@ Singleton {
} }
} }
function getWorkspaceStateIndex(workspace) {
let state = getWorkspaceState(workspace);
if (state == "focused") {
return 0;
} else if (state == "active") {
return 1;
} else if (state == "inactive") {
return 2;
}
}
function getWorkspacesForMonitor(monitor) { function getWorkspacesForMonitor(monitor) {
let allWorkspaces = getAllNumberedWorkspaces(); let allWorkspaces = getAllNumberedWorkspaces();
let monitorWorkspaces = []; let monitorWorkspaces = [];