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