From 0e6925627921287c9e70050a40e0d6a860948c83 Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Mon, 29 Sep 2025 13:13:21 +0200 Subject: [PATCH] Background: fix short flash of default wallpaper before actual wallpaper shows --- Modules/Background/Background.qml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Modules/Background/Background.qml b/Modules/Background/Background.qml index 4dd653b2..eb92df41 100644 --- a/Modules/Background/Background.qml +++ b/Modules/Background/Background.qml @@ -44,14 +44,27 @@ Variants { property real fillMode: 1.0 property vector4d fillColor: Qt.vector4d(Settings.data.wallpaper.fillColor.r, Settings.data.wallpaper.fillColor.g, Settings.data.wallpaper.fillColor.b, 1.0) - // On startup assign wallpaper immediately - Component.onCompleted: { - fillMode = WallpaperService.getFillModeUniform() + // On startup, defer assigning wallpaper until the service cache is ready + function _startWallpaperOnceReady() { + if (!modelData) { + Qt.callLater(_startWallpaperOnceReady) + return + } - var path = modelData ? WallpaperService.getWallpaper(modelData.name) : "" + var cacheReady = WallpaperService && WallpaperService.currentWallpapers && Object.keys(WallpaperService.currentWallpapers).length > 0 + if (!cacheReady) { + // Try again on the next tick until WallpaperService.init() populates cache + Qt.callLater(_startWallpaperOnceReady) + return + } + + fillMode = WallpaperService.getFillModeUniform() + var path = WallpaperService.getWallpaper(modelData.name) setWallpaperImmediate(path) } + Component.onCompleted: _startWallpaperOnceReady() + Connections { target: Settings.data.wallpaper function onFillModeChanged() {