From ca9fcf800485ac5dff633275d56f0b33c4670225 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 9 Jul 2025 11:55:23 +0800 Subject: finished bar --- bar/Workspace.qml | 59 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'bar') diff --git a/bar/Workspace.qml b/bar/Workspace.qml index 2f8d1ea..9c78e30 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -1,21 +1,56 @@ import "../services" +import "../config" import QtQuick.Layouts import QtQuick import Quickshell Item { - Layout.preferredHeight: 50 - Layout.preferredWidth: parent.width / 3 + Layout.preferredHeight: 50 + Layout.preferredWidth: parent.width / 3 - RowLayout { - anchors.fill: parent - spacing: 0 - Repeater { - model: Hyprland.workspaces + property list workspaceOccupied: [] - Text { - text: modelData.active ? modelData.name + " (Active)" : modelData.name - } - } - } + function updateWorkspaceOccupied() { + // workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => { + // return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1); + // }) + workspaceOccupied = Array.from({ length: Bar.workspaces }, (_, i) => { + return Hyprland.workspaces.values.some(ws => ws.id === (i + 1)); + }); + } + function isActive(index: int): bool { + Hyprland.focusedWorkspace.id.toString() == (index + 1).toString(); + } + function isOccupied(index: int): bool { + return workspaceOccupied[index] === true; + } + + Connections { + target: Hyprland.workspaces + function onValuesChanged() { + updateWorkspaceOccupied(); + } + } + + Component.onCompleted: updateWorkspaceOccupied() + + RowLayout { + anchors.fill: parent + spacing: 0 + Repeater { + model: Bar.workspaces + + Rectangle { + Text { + text: Hyprland.focusedWorkspace.id.toString() == (index + 1).toString() + // text: isActive(index) + } + implicitWidth: 10 + implicitHeight: 10 + opacity: !isOccupied(index) ? 0.2 : 1 + // color: isActive(index) ? "#00ff00" : "#ffffff" + color: "#000000" + } + } + } } -- cgit v1.2.3