Background: Smarter wallpaper resize to respect aspect ratio.

This commit is contained in:
ItsLemmy
2025-10-04 18:33:27 -04:00
parent 673ae8d040
commit dbabb7bb69
+33 -2
View File
@@ -99,34 +99,65 @@ Variants {
Image { Image {
id: currentWallpaper id: currentWallpaper
property bool dimensionsCalculated: false
source: "" source: ""
smooth: true smooth: true
mipmap: false mipmap: false
visible: false visible: false
cache: false cache: false
asynchronous: true asynchronous: true
sourceSize: Qt.size(modelData.width, modelData.height)
// Don't set sourceSize initially - will be set after we know aspect ratio
onStatusChanged: { onStatusChanged: {
if (status === Image.Error) { if (status === Image.Error) {
Logger.warn("Current wallpaper failed to load:", source) 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 { Image {
id: nextWallpaper id: nextWallpaper
property bool dimensionsCalculated: false
source: "" source: ""
smooth: true smooth: true
mipmap: false mipmap: false
visible: false visible: false
cache: false cache: false
asynchronous: true asynchronous: true
sourceSize: Qt.size(modelData.width, modelData.height)
onStatusChanged: { onStatusChanged: {
if (status === Image.Error) { if (status === Image.Error) {
Logger.warn("Next wallpaper failed to load:", source) 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 // Dynamic shader loader - only loads the active transition shader