From fb864da6fba9d23d3898ec84ae1bb0d9dbcfa150 Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Wed, 26 Nov 2025 20:04:31 +0100 Subject: [PATCH] traymenu width calc --- Modules/Search.qml | 2 +- Modules/TrayMenuPopout.qml | 29 +++++++++--- Modules/Workspaces.qml | 95 ++++++++++++++++++++------------------ testwindow/shell.qml | 14 ++++++ 4 files changed, 87 insertions(+), 53 deletions(-) create mode 100644 testwindow/shell.qml diff --git a/Modules/Search.qml b/Modules/Search.qml index 12b7173..060dca5 100644 --- a/Modules/Search.qml +++ b/Modules/Search.qml @@ -16,7 +16,7 @@ Searcher { Quickshell.execDetached({ command: ["app2unit", "--", ...entry.command], - workingDirectory: entry.workingDirectory + workingDirectory: entry.workingDirectory || Quickshell.env("HOME") }); } diff --git a/Modules/TrayMenuPopout.qml b/Modules/TrayMenuPopout.qml index 26c7849..cb0cd24 100644 --- a/Modules/TrayMenuPopout.qml +++ b/Modules/TrayMenuPopout.qml @@ -6,6 +6,7 @@ import Quickshell import Quickshell.Widgets import QtQuick import QtQuick.Controls +import QtQuick.Effects StackView { id: root @@ -13,6 +14,7 @@ StackView { required property Item popouts required property QsMenuHandle trayItem + property int rootWidth: 0 property int biggestWidth: 0 implicitWidth: currentItem.implicitWidth @@ -97,12 +99,14 @@ StackView { function onClicked(): void { const entry = item.modelData; - if (entry.hasChildren) + if (entry.hasChildren) { + root.rootWidth = root.biggestWidth; + root.biggestWidth = 0; root.push(subMenuComp.createObject(null, { handle: entry, isSubMenu: true })); - else { + } else { item.modelData.triggered(); root.popouts.hasCurrent = false; } @@ -119,10 +123,22 @@ StackView { active: item.modelData.icon !== "" asynchronous: true - sourceComponent: IconImage { - implicitSize: label.implicitHeight + sourceComponent: Item { + implicitHeight: label.implicitHeight + implicitWidth: label.implicitHeight + IconImage { + id: iconImage + implicitSize: parent.implicitHeight + source: item.modelData.icon + visible: false + } - source: item.modelData.icon + MultiEffect { + anchors.fill: iconImage + source: iconImage + colorization: 1.0 + colorizationColor: item.modelData.enabled ? DynamicColors.palette.m3onSurface : DynamicColors.palette.m3outline + } } } @@ -187,7 +203,7 @@ StackView { CustomRect { anchors.fill: parent - radius: 1000 + radius: 4 color: DynamicColors.palette.m3secondaryContainer StateLayer { @@ -196,6 +212,7 @@ StackView { function onClicked(): void { root.pop(); + root.biggestWidth = root.rootWidth; } } } diff --git a/Modules/Workspaces.qml b/Modules/Workspaces.qml index d5fe931..6d183eb 100644 --- a/Modules/Workspaces.qml +++ b/Modules/Workspaces.qml @@ -7,6 +7,7 @@ import QtQuick.Effects import Quickshell import Quickshell.Hyprland import qs.Config +import qs.Components Item { id: itemRoot @@ -18,7 +19,7 @@ Item { property HyprlandMonitor monitor: Hyprland.monitorFor( itemRoot.bar?.screen ) - implicitWidth: workspacesRow.implicitWidth + 6 + implicitWidth: workspacesRow.implicitWidth + 10 implicitHeight: 22 function shouldShow(monitor) { @@ -49,69 +50,71 @@ Item { id: workspacesRow anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 3 + anchors.leftMargin: 6 spacing: 8 Repeater { model: Hyprland.workspaces - Rectangle { + RowLayout { id: workspaceIndicator required property var modelData + visible: root.shouldShow( workspaceIndicator.modelData.monitor ) + CustomText { + text: workspaceIndicator.modelData.name + font.pointSize: 12 + color: workspaceIndicator.modelData.id === Hyprland.focusedWorkspace.id ? ( Config.useDynamicColors ? DynamicColors.palette.m3primary : Config.accentColor.accents.primary ) : ( Config.useDynamicColors ? DynamicColors.palette.m3onSurfaceVariant : "#606060" ) + visible: true + } - width: 16 - height: 16 - radius: height / 2 + Rectangle { - color: modelData.id === Hyprland.focusedWorkspace.id ? ( Config.useDynamicColors ? DynamicColors.palette.m3primary : Config.accentColor.accents.primary ) : ( Config.useDynamicColors ? DynamicColors.palette.m3outline : "#606060" ) + implicitWidth: 14 + implicitHeight: 14 + radius: height / 2 + border.width: 1 - border.color: modelData.id === Hyprland.focusedWorkspace.id ? ( Config.useDynamicColors ? DynamicColors.palette.m3onPrimary : Config.accentColor.accents.primaryAlt ) : ( Config.useDynamicColors ? DynamicColors.palette.m3outlineVariant : "#808080" ) - border.width: 1 + color: "transparent" + border.color: workspaceIndicator.modelData.id === Hyprland.focusedWorkspace.id ? ( Config.useDynamicColors ? DynamicColors.palette.m3primary : Config.accentColor.accents.primary ) : ( Config.useDynamicColors ? DynamicColors.palette.m3onSurfaceVariant : "#606060" ) - visible: root.shouldShow( modelData.monitor ) - scale: 1.0 - opacity: 1.0 + scale: 1.0 + opacity: 1.0 - Behavior on color { - ColorAnimation { - duration: 150 - easing.type: Easing.InOutQuad + CustomRect { + anchors.centerIn: parent + implicitWidth: 8 + implicitHeight: 8 + + radius: implicitHeight / 2 + color: workspaceIndicator.modelData.id === Hyprland.focusedWorkspace.id ? ( Config.useDynamicColors ? DynamicColors.palette.m3primary : Config.accentColor.accents.primary ) : "transparent" } - } - Behavior on border.color { - ColorAnimation { - duration: 150 - easing.type: Easing.InOutQuad + Behavior on border.color { + ColorAnimation { + duration: 150 + easing.type: Easing.InOutQuad + } } - } - NumberAnimation on scale { - from: 0.0 - to: 1.0 - duration: 300 - easing.type: Easing.OutBack - } - - NumberAnimation on opacity { - from: 0.0 - to: 1.0 - duration: 200 - } + NumberAnimation on scale { + from: 0.0 + to: 1.0 + duration: 300 + easing.type: Easing.OutBack + } + + NumberAnimation on opacity { + from: 0.0 + to: 1.0 + duration: 200 + } - // Text { - // anchors.centerIn: parent - // text: modelData.id - // font.pixelSize: 10 - // font.family: "Rubik" - // color: modelData.id === Hyprland.focusedWorkspace.id ? Config.workspaceWidget.textColor : Config.workspaceWidget.inactiveTextColor - // } - - MouseArea { - anchors.fill: parent - onClicked: { - Hyprland.dispatch("workspace " + modelData.id) + MouseArea { + anchors.fill: parent + onClicked: { + workspaceIndicator.modelData.activate(); + } } } } diff --git a/testwindow/shell.qml b/testwindow/shell.qml new file mode 100644 index 0000000..b7bd507 --- /dev/null +++ b/testwindow/shell.qml @@ -0,0 +1,14 @@ +import Quickshell +import QtQuick +import Quickshell.Hyprland + +FloatingWindow { + id: root + + title: "terminal" + minimumSize: Qt.size(400, 300) + Component.onCompleted: { + Hyprland.refreshToplevels() + console.log(Hyprland.toplevels.values) + } +}