From 12092ca6f640b303d5d9b783d07e7b089b05a6d8 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Fri, 22 Aug 2025 17:00:39 +0200 Subject: [PATCH] Fix Brightness & Tray --- Commons/Color.qml | 1 + Modules/Bar/Bar.qml | 5 ++++- Modules/Bar/Widgets/Brightness.qml | 2 +- Modules/Bar/Widgets/Tray.qml | 17 +++++++++++------ Modules/SettingsPanel/Tabs/BarTab.qml | 11 ++++++----- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Commons/Color.qml b/Commons/Color.qml index 221716f..f31f1ac 100644 --- a/Commons/Color.qml +++ b/Commons/Color.qml @@ -47,6 +47,7 @@ Singleton { // ----------- function applyOpacity(color, opacity) { // Convert color to string and apply opacity + if (!color) return "transparent" return color.toString().replace("#", "#" + opacity) } diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 61e7940..c99cfda 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -137,13 +137,16 @@ Variants { return null } + console.log(`Attempting to load widget: ${widgetName}.qml`) + // Try to load the widget directly from file const component = Qt.createComponent(`../Bar/Widgets/${widgetName}.qml`) if (component.status === Component.Ready) { + console.log(`Successfully created component for: ${widgetName}.qml`) return component } - console.warn(`Failed to load widget: ${widgetName}.qml`) + console.warn(`Failed to load widget: ${widgetName}.qml, status:`, component.status, "error:", component.errorString()) return null } diff --git a/Modules/Bar/Widgets/Brightness.qml b/Modules/Bar/Widgets/Brightness.qml index 82bacb8..58c8cc6 100644 --- a/Modules/Bar/Widgets/Brightness.qml +++ b/Modules/Bar/Widgets/Brightness.qml @@ -10,7 +10,7 @@ Item { width: pill.width height: pill.height - visible: firstBrightnessReceived && getMonitor() !== null + visible: getMonitor() !== null // Used to avoid opening the pill on Quickshell startup property bool firstBrightnessReceived: false diff --git a/Modules/Bar/Widgets/Tray.qml b/Modules/Bar/Widgets/Tray.qml index c6ba8c9..9998fe6 100644 --- a/Modules/Bar/Widgets/Tray.qml +++ b/Modules/Bar/Widgets/Tray.qml @@ -9,10 +9,14 @@ import qs.Commons import qs.Services import qs.Widgets + + Rectangle { readonly property real itemSize: 24 * scaling visible: Settings.data.bar.showTray && (SystemTray.items.values.length > 0) + + width: tray.width + Style.marginM * scaling * 2 height: Math.round(Style.capsuleHeight * scaling) @@ -95,14 +99,14 @@ Rectangle { return } - if (modelData.hasMenu && modelData.menu && trayMenu) { + if (modelData.hasMenu && modelData.menu && trayMenu.item) { trayPanel.open() // Anchor the menu to the tray icon item (parent) and position it below the icon - const menuX = (width / 2) - (trayMenu.width / 2) + const menuX = (width / 2) - (trayMenu.item.width / 2) const menuY = (Style.barHeight * scaling) - trayMenu.menu = modelData.menu - trayMenu.showAt(parent, menuX, menuY) + trayMenu.item.menu = modelData.menu + trayMenu.item.showAt(parent, menuX, menuY) } else { Logger.log("Tray", "No menu available for", modelData.id, "or trayMenu not set") } @@ -142,7 +146,7 @@ Rectangle { function close() { visible = false - trayMenu.hideMenu() + trayMenu.item.hideMenu() } // Clicking outside of the rectangle to close @@ -151,8 +155,9 @@ Rectangle { onClicked: trayPanel.close() } - TrayMenu { + Loader { id: trayMenu + source: "TrayMenu.qml" } } } diff --git a/Modules/SettingsPanel/Tabs/BarTab.qml b/Modules/SettingsPanel/Tabs/BarTab.qml index d03c333..307db25 100644 --- a/Modules/SettingsPanel/Tabs/BarTab.qml +++ b/Modules/SettingsPanel/Tabs/BarTab.qml @@ -199,7 +199,7 @@ ColumnLayout { height: 32 * scaling radius: width * 0.5 color: Color.mPrimary - border.color: Color.mPrimaryContainer + border.color: Color.mPrimary border.width: 2 * scaling NIcon { @@ -336,7 +336,7 @@ ColumnLayout { height: 32 * scaling radius: width * 0.5 color: Color.mPrimary - border.color: Color.mPrimaryContainer + border.color: Color.mPrimary border.width: 2 * scaling NIcon { @@ -473,7 +473,7 @@ ColumnLayout { height: 32 * scaling radius: width * 0.5 color: Color.mPrimary - border.color: Color.mPrimaryContainer + border.color: Color.mPrimary border.width: 2 * scaling NIcon { @@ -612,8 +612,9 @@ ColumnLayout { border.width: Math.max(1, Style.borderS * scaling) ColumnLayout { - anchors.fill: parent - anchors.margins: Style.marginL * scaling + Layout.fillWidth: true + Layout.fillHeight: true + Layout.margins: Style.marginL * scaling spacing: Style.marginM * scaling NText {