mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-02 10:37:50 +00:00
Background: Smarter wallpaper resize to respect aspect ratio.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user