A theme switch that plays an intro gave the shell the new still only when the intro failed. The shell kept the old theme's path, which the theme swap deletes, and loaded it again when OWE handed the desktop back, leaving it empty. The new still is now handed over either way. The shell also re-reads the background link whenever OWE hands the desktop back or a wallpaper fails to load, falling back to the theme's first background when the link itself is broken. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
2.0 KiB
QML
50 lines
2.0 KiB
QML
import QtQuick
|
|
import qs.Commons
|
|
|
|
// The shell draws stills only. OWE owns video backgrounds on the desktop, and
|
|
// it feeds the lock screen through its own socket.
|
|
Item {
|
|
id: root
|
|
|
|
property string path: ""
|
|
property int version: 0
|
|
// Unversioned images cache by path. A caller whose version changes with every
|
|
// new file, as the lock's does, may cache too: the version is in the URL.
|
|
property bool cached: version === 0
|
|
// A caller that knows the size its screen needs, in physical pixels, sets
|
|
// constrainDecode and decodeSize. The image then waits for that size rather
|
|
// than decoding at the file's native size first.
|
|
property bool constrainDecode: false
|
|
property size decodeSize: Qt.size(0, 0)
|
|
readonly property var current: imageLoader.item
|
|
readonly property bool ready: current ? current.ready : false
|
|
// The file behind path could not be loaded, as when it was deleted.
|
|
readonly property bool failed: current ? current.failed : false
|
|
readonly property bool video: Util.isVideoPath(path)
|
|
// Cache-bust images selected in a running lock session, so a theme switch
|
|
// that replaces the file behind an unchanged path shows the new pixels.
|
|
readonly property url imageUrl: path && !video ? Util.fileUrl(path) + (version ? "?v=" + version : "") : ""
|
|
|
|
Loader {
|
|
id: imageLoader
|
|
anchors.fill: parent
|
|
active: root.path !== "" && !root.video
|
|
sourceComponent: imageComponent
|
|
}
|
|
|
|
Component {
|
|
id: imageComponent
|
|
|
|
Image {
|
|
readonly property bool ready: status === Image.Ready
|
|
readonly property bool failed: status === Image.Error
|
|
source: !root.constrainDecode || root.decodeSize.width > 0 ? root.imageUrl : ""
|
|
fillMode: Image.PreserveAspectCrop
|
|
asynchronous: true
|
|
cache: root.cached
|
|
sourceSize.width: root.constrainDecode ? root.decodeSize.width : (root.version > 0 ? width : 0)
|
|
sourceSize.height: root.constrainDecode ? root.decodeSize.height : (root.version > 0 ? height : 0)
|
|
}
|
|
}
|
|
}
|