From 01a0fa8bae7ed355fec0b36eca5489deb4c20115 Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Sun, 2 Nov 2025 22:26:00 +0100 Subject: [PATCH] stuff --- Modules/TrayItem.qml | 5 ++++- Modules/TrayMenu.qml | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Modules/TrayItem.qml b/Modules/TrayItem.qml index 73c884b..c6350da 100644 --- a/Modules/TrayItem.qml +++ b/Modules/TrayItem.qml @@ -14,6 +14,7 @@ MouseArea { id: root required property SystemTrayItem item + property var menuHandle implicitWidth: 22 implicitHeight: 22 @@ -41,6 +42,7 @@ MouseArea { mipmap: false asynchronous: true + ImageAnalyser { id: analyser sourceItem: icon @@ -57,6 +59,7 @@ MouseArea { grab.active = false; } } + HyprlandFocusGrab { id: grab windows: [ trayMenu ] @@ -65,8 +68,8 @@ MouseArea { } } } - } + onClicked: { if ( mouse.button === Qt.LeftButton ) { root.item.activate(); diff --git a/Modules/TrayMenu.qml b/Modules/TrayMenu.qml index a8f90f9..207f979 100644 --- a/Modules/TrayMenu.qml +++ b/Modules/TrayMenu.qml @@ -8,6 +8,8 @@ import Quickshell.Hyprland PopupWindow { id: root + + signal menuActionTriggered() required property QsMenuHandle menu property int height: { let count = 0; @@ -17,8 +19,8 @@ PopupWindow { return count * (entryHeight + 3); } property int entryHeight: 30 - property int maxWidth - implicitWidth: maxWidth + 20 + property int maxWidth: 100 + implicitWidth: Math.max(100, maxWidth + 20) implicitHeight: height color: "transparent" anchor.margins { @@ -65,8 +67,8 @@ PopupWindow { Component.onCompleted: { // Measure text width to determine maximumWidth - var textWidth = textMetrics.width + 20 + (iconImage.width > 0 ? iconImage.width + 10 : 0); - if ( textWidth > root.maxWidth ) { + var textWidth = textMetrics.width + 20 + (iconImage.source ? iconImage.width + 10 : 0); + if ( textWidth > 0 && textWidth > root.maxWidth ) { root.maxWidth = textWidth } } @@ -76,12 +78,13 @@ PopupWindow { anchors.fill: parent hoverEnabled: true preventStealing: true - propagateComposedEvents: true +propagateComposedEvents: true acceptedButtons: Qt.LeftButton onClicked: { if ( !menuItem.modelData.hasChildren ) { if ( menuItem.modelData.enabled ) { menuItem.modelData.triggered(); + root.menuActionTriggered(); root.visible = false; } } else {