From dbabb7bb69cbf97c446f6ea87db8a52c25a00887 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Sat, 4 Oct 2025 18:33:27 -0400 Subject: [PATCH] Background: Smarter wallpaper resize to respect aspect ratio. --- Modules/Background/Background.qml | 35 +++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/Modules/Background/Background.qml b/Modules/Background/Background.qml index 77522f26..60aeaaec 100644 --- a/Modules/Background/Background.qml +++ b/Modules/Background/Background.qml @@ -99,34 +99,65 @@ Variants { Image { id: currentWallpaper + + property bool dimensionsCalculated: false + source: "" smooth: true mipmap: false visible: false cache: false asynchronous: true - sourceSize: Qt.size(modelData.width, modelData.height) + + // Don't set sourceSize initially - will be set after we know aspect ratio onStatusChanged: { if (status === Image.Error) { Logger.warn("Current wallpaper failed to load:", source) + } else if (status === Image.Ready && !dimensionsCalculated) { + // First load: get original dimensions + const aspectRatio = implicitWidth / implicitHeight + dimensionsCalculated = true + + // Now set sourceSize to screen width and calculated height + const w = Math.min(modelData.width, implicitWidth) + sourceSize = Qt.size(w, w / aspectRatio) } } + + onSourceChanged: { + // Reset for new image + dimensionsCalculated = false + sourceSize = undefined // Clear sourceSize for initial load + } } Image { id: nextWallpaper + + property bool dimensionsCalculated: false + source: "" smooth: true mipmap: false visible: false cache: false asynchronous: true - sourceSize: Qt.size(modelData.width, modelData.height) + onStatusChanged: { if (status === Image.Error) { Logger.warn("Next wallpaper failed to load:", source) + } else if (status === Image.Ready && !dimensionsCalculated) { + const aspectRatio = implicitWidth / implicitHeight + dimensionsCalculated = true + const w = Math.min(modelData.width, implicitWidth) + sourceSize = Qt.size(w, w / aspectRatio) } } + + onSourceChanged: { + dimensionsCalculated = false + sourceSize = undefined + } } // Dynamic shader loader - only loads the active transition shader