From 87067f706243e0b4b2f4ccd44d733d78d31b9af0 Mon Sep 17 00:00:00 2001 From: LemmyCook Date: Mon, 1 Sep 2025 14:41:12 -0400 Subject: [PATCH] TrayMenu: fix dynamic scaling --- Modules/Bar/Extras/TrayMenu.qml | 9 +++++++++ Modules/Bar/Widgets/Tray.qml | 16 +++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Modules/Bar/Extras/TrayMenu.qml b/Modules/Bar/Extras/TrayMenu.qml index e274d3d..d0f6ab3 100644 --- a/Modules/Bar/Extras/TrayMenu.qml +++ b/Modules/Bar/Extras/TrayMenu.qml @@ -17,6 +17,15 @@ PopupWindow { property ShellScreen screen property real scaling: ScalingService.getScreenScale(screen) + Connections { + target: ScalingService + function onScaleChanged(screenName, scale) { + if ((screen != null) && (screenName === screen.name)) { + scaling = scale + } + } + } + readonly property int menuWidth: 180 implicitWidth: menuWidth * scaling diff --git a/Modules/Bar/Widgets/Tray.qml b/Modules/Bar/Widgets/Tray.qml index 1c5a6cf..b44e60e 100644 --- a/Modules/Bar/Widgets/Tray.qml +++ b/Modules/Bar/Widgets/Tray.qml @@ -17,6 +17,14 @@ Rectangle { property real scaling: 1.0 readonly property real itemSize: 24 * scaling + function onLoaded() { + // When the widget is fully initialized with its props + // set the screen for the trayMenu + if (trayMenu.item) { + trayMenu.item.screen = screen + } + } + visible: SystemTray.items.values.length > 0 implicitWidth: tray.width + Style.marginM * scaling * 2 implicitHeight: Math.round(Style.capsuleHeight * scaling) @@ -155,13 +163,7 @@ Rectangle { Loader { id: trayMenu - source: "../Extras/TrayMenu.qml" - - onLoaded: { - if (item) { - item.screen = screen - } - } + source: "../Extras/TrayMenu.qml" } } }