Customtray #3

Merged
Zacharias-Brohn merged 6 commits from customtray into main 2025-11-02 22:26:25 +01:00
2 changed files with 12 additions and 6 deletions
Showing only changes of commit 01a0fa8bae - Show all commits
+4 -1
View File
@@ -14,6 +14,7 @@ MouseArea {
id: root id: root
required property SystemTrayItem item required property SystemTrayItem item
property var menuHandle
implicitWidth: 22 implicitWidth: 22
implicitHeight: 22 implicitHeight: 22
@@ -41,6 +42,7 @@ MouseArea {
mipmap: false mipmap: false
asynchronous: true asynchronous: true
ImageAnalyser { ImageAnalyser {
id: analyser id: analyser
sourceItem: icon sourceItem: icon
@@ -57,6 +59,7 @@ MouseArea {
grab.active = false; grab.active = false;
} }
} }
HyprlandFocusGrab { HyprlandFocusGrab {
id: grab id: grab
windows: [ trayMenu ] windows: [ trayMenu ]
@@ -65,8 +68,8 @@ MouseArea {
} }
} }
} }
} }
onClicked: { onClicked: {
if ( mouse.button === Qt.LeftButton ) { if ( mouse.button === Qt.LeftButton ) {
root.item.activate(); root.item.activate();
+8 -5
View File
@@ -8,6 +8,8 @@ import Quickshell.Hyprland
PopupWindow { PopupWindow {
id: root id: root
signal menuActionTriggered()
required property QsMenuHandle menu required property QsMenuHandle menu
property int height: { property int height: {
let count = 0; let count = 0;
@@ -17,8 +19,8 @@ PopupWindow {
return count * (entryHeight + 3); return count * (entryHeight + 3);
} }
property int entryHeight: 30 property int entryHeight: 30
property int maxWidth property int maxWidth: 100
implicitWidth: maxWidth + 20 implicitWidth: Math.max(100, maxWidth + 20)
implicitHeight: height implicitHeight: height
color: "transparent" color: "transparent"
anchor.margins { anchor.margins {
@@ -65,8 +67,8 @@ PopupWindow {
Component.onCompleted: { Component.onCompleted: {
// Measure text width to determine maximumWidth // Measure text width to determine maximumWidth
var textWidth = textMetrics.width + 20 + (iconImage.width > 0 ? iconImage.width + 10 : 0); var textWidth = textMetrics.width + 20 + (iconImage.source ? iconImage.width + 10 : 0);
if ( textWidth > root.maxWidth ) { if ( textWidth > 0 && textWidth > root.maxWidth ) {
root.maxWidth = textWidth root.maxWidth = textWidth
} }
} }
@@ -76,12 +78,13 @@ PopupWindow {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
preventStealing: true preventStealing: true
propagateComposedEvents: true propagateComposedEvents: true
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onClicked: { onClicked: {
if ( !menuItem.modelData.hasChildren ) { if ( !menuItem.modelData.hasChildren ) {
if ( menuItem.modelData.enabled ) { if ( menuItem.modelData.enabled ) {
menuItem.modelData.triggered(); menuItem.modelData.triggered();
root.menuActionTriggered();
root.visible = false; root.visible = false;
} }
} else { } else {