From e8fe4ef673ebb3bc89f192ad5dba0b6d54149f34 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:49:05 +1000 Subject: feat: bar workspaces show windows Better hyprland clients (update existing instead of resetting every time) Option for ws trail Custom label for occupied ws as well --- modules/bar/components/workspaces/Workspace.qml | 83 ++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 10 deletions(-) (limited to 'modules/bar/components/workspaces/Workspace.qml') diff --git a/modules/bar/components/workspaces/Workspace.qml b/modules/bar/components/workspaces/Workspace.qml index a6e2b43..c5d7475 100644 --- a/modules/bar/components/workspaces/Workspace.qml +++ b/modules/bar/components/workspaces/Workspace.qml @@ -1,9 +1,14 @@ import "root:/widgets" import "root:/services" +import "root:/utils" import "root:/config" +import Quickshell +import QtQuick import QtQuick.Layouts -StyledText { +Item { + id: root + required property int index required property bool vertical required property var occupied @@ -12,15 +17,73 @@ StyledText { readonly property bool isWorkspace: true // Flag for finding workspace children readonly property int ws: groupOffset + index + 1 - readonly property string label: BarConfig.workspaces.label || ws - readonly property string activeLabel: BarConfig.workspaces.activeLabel || label + readonly property bool isOccupied: occupied[ws] ?? false + + Layout.preferredWidth: childrenRect.width + (isOccupied && !vertical ? Appearance.padding.normal : 0) + Layout.preferredHeight: childrenRect.height + (isOccupied && vertical ? Appearance.padding.normal : 0) + + StyledText { + id: indicator + + readonly property string label: BarConfig.workspaces.label || root.ws + readonly property string occupiedLabel: BarConfig.workspaces.occupiedLabel || label + readonly property string activeLabel: BarConfig.workspaces.activeLabel || (root.isOccupied ? occupiedLabel : label) + + animate: true + animateProp: "scale" + text: Hyprland.activeWsId === root.ws ? activeLabel : root.isOccupied ? occupiedLabel : label + color: BarConfig.workspaces.occupiedBg || root.isOccupied ? Appearance.colours.text : Appearance.colours.subtext0 + horizontalAlignment: StyledText.AlignHCenter + verticalAlignment: StyledText.AlignVCenter + + width: BarConfig.sizes.innerHeight + height: BarConfig.sizes.innerHeight + } + + Grid { + flow: root.vertical ? GridLayout.TopToBottom : GridLayout.LeftToRight + rows: root.vertical ? -1 : 1 + columns: root.vertical ? 1 : -1 + spacing: Appearance.padding.small + + anchors.left: vertical ? undefined : indicator.right + anchors.top: vertical ? indicator.bottom : undefined + anchors.verticalCenter: vertical ? undefined : indicator.verticalCenter + anchors.horizontalCenter: vertical ? indicator.horizontalCenter : undefined + + add: Transition { + Anim { + properties: "scale" + from: 0 + to: 1 + duration: Appearance.anim.durations.small + } + } + + Repeater { + model: ScriptModel { + values: Hyprland.clients.filter(c => c.workspace.id === root.ws) + } + + MaterialIcon { + required property Hyprland.Client modelData + + text: Icons.getAppCategoryIcon(modelData.wmClass, "terminal") + } + } + } + + Behavior on Layout.preferredWidth { + Anim {} + } - animate: true - animateProp: "scale" - text: (Hyprland.activeWorkspace?.id ?? 1) === ws ? activeLabel : label - color: BarConfig.workspaces.occupiedBg || occupied[ws] ? Appearance.colours.text : Appearance.colours.subtext0 - horizontalAlignment: StyledText.AlignHCenter + Behavior on Layout.preferredHeight { + Anim {} + } - Layout.minimumWidth: vertical ? -1 : BarConfig.sizes.innerHeight - Layout.minimumHeight: vertical ? BarConfig.sizes.innerHeight : -1 + component Anim: NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.standard + } } -- cgit v1.2.3-freya