From abe1a1e12f668bfcf26a27963a06c2d1e2d6ea96 Mon Sep 17 00:00:00 2001 From: voidarc Date: Thu, 6 Aug 2026 14:09:14 +0100 Subject: [PATCH] functional workspace display --- Bar/WorkspaceSelector.qml | 45 ++++++++++++++++++++++++++++------- Services/WorkspaceManager.qml | 11 +++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Bar/WorkspaceSelector.qml b/Bar/WorkspaceSelector.qml index 99e7469..4018817 100644 --- a/Bar/WorkspaceSelector.qml +++ b/Bar/WorkspaceSelector.qml @@ -1,5 +1,6 @@ +pragma ComponentBehavior: Bound import QtQuick -import QtQuick.Controls +import QtQuick.Layouts import Quickshell import Quickshell.Hyprland @@ -10,32 +11,58 @@ 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: 25 + boxHeight: barHeight + boxRadius: 8 + boxWidth: (2 * rowLeftMargin) + (workspaceCount * workspaceWidth) + ((workspaceCount - 1) + * workspaceButtonSpacing) exclusiveMonitor: monitor - Row { - spacing: 3 + 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) - delegateModelAccess: DelegateModel.ReadOnly } Component { id: workspaceButton Item { - required property var modelData + id: buttonRoot - height: 10 - width: 10 + 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: "red" + color: buttonRoot.workspaceColors[buttonRoot.stateInt] + radius: 4 + + CenteredText { + text: buttonRoot.modelData.id + } } } } diff --git a/Services/WorkspaceManager.qml b/Services/WorkspaceManager.qml index d238bc9..8b1c685 100644 --- a/Services/WorkspaceManager.qml +++ b/Services/WorkspaceManager.qml @@ -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) { let allWorkspaces = getAllNumberedWorkspaces(); let monitorWorkspaces = [];