From 1993e28c18a539436ed7e3169374db12808f1bea Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Tue, 19 Aug 2025 13:16:03 +0200 Subject: [PATCH] Possible fix for unknown screen (bar not displaying) --- Commons/Settings.qml | 34 ++++++++++++++++++++++++++++++++++ Widgets/NIconButton.qml | 2 ++ Widgets/NPill.qml | 2 ++ Widgets/NTooltip.qml | 14 +++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Commons/Settings.qml b/Commons/Settings.qml index ec156ce..6302567 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -32,6 +32,36 @@ Singleton { // Needed to only have one NPanel loaded at a time. <--- VERY BROKEN //property var openPanel: null + + // Function to validate monitor configurations + function validateMonitorConfigurations() { + var availableScreenNames = [] + for (var i = 0; i < Quickshell.screens.length; i++) { + availableScreenNames.push(Quickshell.screens[i].name) + } + + Logger.log("Settings", "Available monitors: [" + availableScreenNames.join(", ") + "]") + Logger.log("Settings", "Configured bar monitors: [" + adapter.bar.monitors.join(", ") + "]") + + // Check bar monitors + if (adapter.bar.monitors.length > 0) { + var hasValidBarMonitor = false + for (var j = 0; j < adapter.bar.monitors.length; j++) { + if (availableScreenNames.includes(adapter.bar.monitors[j])) { + hasValidBarMonitor = true + break + } + } + if (!hasValidBarMonitor) { + Logger.log("Settings", "No configured bar monitors found on system, clearing bar monitor list to show on all screens") + adapter.bar.monitors = [] + } else { + Logger.log("Settings", "Found valid bar monitors, keeping configuration") + } + } else { + Logger.log("Settings", "Bar monitor list is empty, will show on all available screens") + } + } Item { Component.onCompleted: { @@ -58,6 +88,10 @@ Singleton { Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current) WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true) } + + // Validate monitor configurations - if none of the configured monitors exist, clear the lists + validateMonitorConfigurations() + isInitialLoad = false }) } diff --git a/Widgets/NIconButton.qml b/Widgets/NIconButton.qml index c5005b4..351126c 100644 --- a/Widgets/NIconButton.qml +++ b/Widgets/NIconButton.qml @@ -52,6 +52,8 @@ Rectangle { id: tooltip target: root positionAbove: Settings.data.bar.barPosition === "bottom" + positionLeft: Settings.data.bar.barPosition === "right" + positionRight: Settings.data.bar.barPosition === "left" text: root.tooltipText } diff --git a/Widgets/NPill.qml b/Widgets/NPill.qml index 680c4a2..a05b222 100644 --- a/Widgets/NPill.qml +++ b/Widgets/NPill.qml @@ -169,6 +169,8 @@ Item { NTooltip { id: tooltip positionAbove: Settings.data.bar.barPosition === "bottom" + positionLeft: Settings.data.bar.barPosition === "right" + positionRight: Settings.data.bar.barPosition === "left" target: pill delay: Style.tooltipDelayLong text: root.tooltipText diff --git a/Widgets/NTooltip.qml b/Widgets/NTooltip.qml index 204a2ce..00b59c7 100644 --- a/Widgets/NTooltip.qml +++ b/Widgets/NTooltip.qml @@ -10,6 +10,8 @@ Window { property Item target: null property int delay: Style.tooltipDelay property bool positionAbove: false + property bool positionLeft: false + property bool positionRight: false flags: Qt.ToolTip | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint color: Color.transparent @@ -44,7 +46,17 @@ Window { return } - if (positionAbove) { + if (positionLeft) { + // Position tooltip to the left of the target + var pos = target.mapToGlobal(0, 0) + x = pos.x - width - 12 // 12 px margin to the left + y = pos.y - height / 2 + target.height / 2 + } else if (positionRight) { + // Position tooltip to the right of the target + var pos = target.mapToGlobal(target.width, 0) + x = pos.x + 12 // 12 px margin to the right + y = pos.y - height / 2 + target.height / 2 + } else if (positionAbove) { // Position tooltip above the target var pos = target.mapToGlobal(0, 0) x = pos.x - width / 2 + target.width / 2