From f5462c3274d008c1bb509cfac4eab8492d822cf5 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 13 Jul 2025 14:55:59 +0800 Subject: finish bar workspace style --- bar/Bar.qml | 23 ++++++++++++++++------- bar/Workspace.qml | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 21 deletions(-) (limited to 'bar') diff --git a/bar/Bar.qml b/bar/Bar.qml index 0591152..a18ad06 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -36,23 +36,32 @@ Scope { rightMargin: Bar.rightMargin } + color: "transparent" + + Rectangle { + id: barBackground + anchors { + left: parent.left + } + implicitWidth: workspace.width + mpris.width + implicitHeight: leftRow.height + color: Qt.rgba(Colors.r, Colors.g, Colors.b, Bar.bgTransparency) + radius: Bar.moduleRadius + } + RowLayout { id: leftRow + anchors.left: parent.left + anchors.leftMargin: 20 implicitWidth: (child.width - centerRow.width) / 2 implicitHeight: child.height Workspace { id: workspace - Layout.preferredWidth: 5 - Layout.fillHeight: true - Layout.fillWidth: true - Layout.maximumWidth: 400 // FIXME + Layout.minimumWidth: 400 // FIXME } Mpris { id: mpris - Layout.fillWidth: true - Layout.fillHeight: true - Layout.preferredWidth: 1 } Item { Layout.fillWidth: true diff --git a/bar/Workspace.qml b/bar/Workspace.qml index 0b0c672..6155bb5 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -2,7 +2,8 @@ import QtQuick.Layouts import QtQuick import Quickshell import Quickshell.Hyprland -import qs.config +import qs.config as Config +import qs.components Item { id: root @@ -14,13 +15,14 @@ Item { // return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1); // }) workspaceOccupied = Array.from({ - length: Bar.workspaces + length: Config.Bar.workspaces }, (_, i) => { return Hyprland.workspaces.values.some(ws => ws?.id === (i + 1)); }); } + // dont work no more for some reason function isActive(index: int): bool { - Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString(); + return Hyprland.focusedWorkspace?.id === (index + 1); } function isOccupied(index: int): bool { return workspaceOccupied[index] === true; @@ -37,24 +39,35 @@ Item { RowLayout { id: layout - implicitWidth: parent.width + implicitWidth: childrenRect.width anchors.verticalCenter: parent.verticalCenter - spacing: 0 + spacing: Config.Bar.workspaceSpacing Repeater { - model: Bar.workspaces + model: Config.Bar.workspaces Rectangle { - Text { - text: Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString() - // text: isActive(index) + id: workspaceRect + // text: Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString() + // text: isActive(index) + + implicitWidth: !isActive(index) ? Config.Bar.workspaceIconSize : Config.Bar.workspaceActiveIconSize + implicitHeight: Config.Bar.workspaceIconSize - 10 + anchors { + topMargin: 20 + } + radius: Config.Bar.workspaceRounding + Icons { + anchors.centerIn: parent + text: Config.Icons.ws[index + 1] + font.pixelSize: Config.Bar.workspaceIconSize / 1.9 + color: Config.Colors.foreground // TODO make IText w/ ts default color + // opacity: !isOccupied(index) ? 0 : 1 // less contrast + opacity: isActive(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity } - implicitWidth: 10 - implicitHeight: 10 - opacity: !isOccupied(index) ? 0.2 : 1 - // color: isActive(index) ? "#00ff00" : "#ffffff" - color: "#000000" + color: isOccupied(index) ? Config.Colors.alt : Config.Colors.foreground + opacity: isActive(index) ? Config.Bar.workspaceActiveOpacity : isOccupied(index) ? Config.Bar.workspaceOpacity : Config.Bar.workspaceEmptyOpacity } } } -- cgit v1.2.3