From 98fecc6f412181cd03f557831137dc904cafb2b5 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Wed, 18 Mar 2026 05:49:10 +0100 Subject: [PATCH] qs: no its not :( --- .../Modules/Background/Background.qml | 6 +- .../quickshell/Services/BackgroundService.qml | 60 ++++++++++++------- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/config/quickshell/.config/quickshell/Modules/Background/Background.qml b/config/quickshell/.config/quickshell/Modules/Background/Background.qml index 1c833af..1276f25 100644 --- a/config/quickshell/.config/quickshell/Modules/Background/Background.qml +++ b/config/quickshell/.config/quickshell/Modules/Background/Background.qml @@ -20,8 +20,8 @@ Variants { PanelWindow { id: bgWindow - readonly property bool doBlur: BarService.focusMode && (BackgroundService.previewPath === "") - readonly property string imagePath: BackgroundService.previewPath || BackgroundService.cachedPath + readonly property bool doBlur: BarService.focusMode && !BackgroundService.inPreviewMode + readonly property string imagePath: BackgroundService.displayPath screen: modelData WlrLayershell.namespace: "quickshell-background" @@ -133,7 +133,7 @@ Variants { id: bdWindow property bool doBlur: true - property string imagePath: BackgroundService.cachedPath + property string imagePath: BackgroundService.displayPath screen: modelData WlrLayershell.namespace: "quickshell-backdrop" diff --git a/config/quickshell/.config/quickshell/Services/BackgroundService.qml b/config/quickshell/.config/quickshell/Services/BackgroundService.qml index 5576bfc..1cb0b34 100644 --- a/config/quickshell/.config/quickshell/Services/BackgroundService.qml +++ b/config/quickshell/.config/quickshell/Services/BackgroundService.qml @@ -11,8 +11,10 @@ Singleton { readonly property string backgroundWidth: "2560" readonly property string backgroundHeight: "1440" - property string cachedPath: "" - property string previewPath: "" + property string _cachedPath: "" + property string _previewPath: "" + property string displayPath: "" + property bool inPreviewMode: false // Preserved for getBlurredOverview readonly property string tintColor: Colors.mSurface readonly property real tintOpacity: 0.5 @@ -29,22 +31,25 @@ Singleton { Logger.e("BackgroundService", "Failed to load background image from path: " + SettingsService.backgroundPath); return ; } - cachedPath = path; + _cachedPath = path; Logger.i("BackgroundService", "Loaded background image as cached path: " + path); + setDisplayTimer.restart(); }); } function previewWallpaper(path) { if (!path) { - previewPath = ""; + _previewPath = ""; + setDisplayTimer.restart(); return ; } ImageCacheService.checkFileExists(path, function(exists) { if (!exists) { - previewPath = ""; + _previewPath = ""; return ; } - previewPath = path; + _previewPath = path; + setDisplayTimer.restart(); }); } @@ -52,14 +57,15 @@ Singleton { if (!path) return ; - previewPath = ""; // clear preview path - cachedPath = ""; // clear cached path + _previewPath = ""; // clear preview path + _cachedPath = ""; // clear cached path + setDisplayTimer.restart(); ImageCacheService.checkFileExists(path, function(exists) { if (!exists) return ; SettingsService.backgroundPath = path; - loadWallpaperDebouncer.start(); + loadTimer.restart(); }); } @@ -70,25 +76,37 @@ Singleton { } Component.onCompleted: { - loadWallpaperDebouncer.start(); - } - - Connections { - function onBackgroundPathChanged() { - loadWallpaperDebouncer.start(); - } - - target: SettingsService + loadTimer.start(); } Timer { - id: loadWallpaperDebouncer + id: loadTimer - interval: 200 + interval: 300 running: false repeat: false onTriggered: { - root.loadBackground(); + loadBackground(); + } + } + + Timer { + id: setDisplayTimer + + interval: 100 + running: false + repeat: false + onTriggered: { + if (root._previewPath) { + root.displayPath = root._previewPath; + root.inPreviewMode = true; + } else if (root._cachedPath) { + root.displayPath = root._cachedPath; + root.inPreviewMode = false; + } else { + root.displayPath = ""; + root.inPreviewMode = false; + } } }