From 8a6b842ed03310080f8853bd36d9c5f8cf16ffa4 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Thu, 7 Aug 2025 21:21:03 +0200 Subject: [PATCH] Add close logic for WallpaperSelector --- Widgets/SettingsWindow/SettingsWindow.qml | 9 +++++++- .../Tabs/Components/WallpaperSelector.qml | 21 +++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Widgets/SettingsWindow/SettingsWindow.qml b/Widgets/SettingsWindow/SettingsWindow.qml index 593c386..d57e5e2 100644 --- a/Widgets/SettingsWindow/SettingsWindow.qml +++ b/Widgets/SettingsWindow/SettingsWindow.qml @@ -294,7 +294,14 @@ PanelWithOverlay { anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor - onClicked: panelMain.dismiss() + onClicked: { + // If wallpaper selector is open, close it instead of the settings window + if (wallpaperSelector.visible) { + wallpaperSelector.hide(); + } else { + panelMain.dismiss(); + } + } } } diff --git a/Widgets/SettingsWindow/Tabs/Components/WallpaperSelector.qml b/Widgets/SettingsWindow/Tabs/Components/WallpaperSelector.qml index ab28d4e..5d2722d 100644 --- a/Widgets/SettingsWindow/Tabs/Components/WallpaperSelector.qml +++ b/Widgets/SettingsWindow/Tabs/Components/WallpaperSelector.qml @@ -8,23 +8,38 @@ import qs.Settings Rectangle { id: wallpaperOverlay + focus: true // Function to show the overlay and load wallpapers function show() { // Ensure wallpapers are loaded WallpaperManager.loadWallpapers(); wallpaperOverlay.visible = true; + wallpaperOverlay.forceActiveFocus(); + } + + // Function to hide the overlay + function hide() { + wallpaperOverlay.visible = false; } color: Theme.backgroundPrimary visible: false z: 1000 + // Handle escape key to close + Keys.onPressed: function(event) { + if (event.key === Qt.Key_Escape) { + wallpaperOverlay.hide(); + event.accepted = true; + } + } + // Click outside to close MouseArea { anchors.fill: parent onClicked: { - wallpaperOverlay.visible = false; + wallpaperOverlay.hide(); } } @@ -41,6 +56,8 @@ Rectangle { anchors.fill: parent spacing: 0 + + // Wallpaper Grid Item { Layout.fillWidth: true @@ -133,7 +150,7 @@ Rectangle { cursorShape: Qt.PointingHandCursor onClicked: { WallpaperManager.changeWallpaper(modelData); - wallpaperOverlay.visible = false; + wallpaperOverlay.hide(); } }