feat: rework wallpaper to use stack instead of A/B

Also switch colour animation to SlowEffects
This commit is contained in:
2 * r + 2 * t 2026-04-23 01:00:35 +10:00
parent 3191ea9757
commit 04f34034c3
2 changed files with 31 additions and 43 deletions

View file

@ -2,6 +2,6 @@ import QtQuick
import Caelestia.Config import Caelestia.Config
ColorAnimation { ColorAnimation {
duration: Tokens.anim.durations.normal duration: Tokens.anim.durations.expressiveSlowEffects
easing: Tokens.anim.standard easing: Tokens.anim.expressiveSlowEffects
} }

View file

@ -12,22 +12,24 @@ Item {
id: root id: root
property string source: Wallpapers.current property string source: Wallpapers.current
property Image current: one property CachingImage current
property bool completed property bool completed
onSourceChanged: { onSourceChanged: {
if (!source) if (!source)
current = null; current = null;
else if (current === one)
two.update();
else else
one.update(); current = imgComp.createObject(this, {
path: source
});
} }
Component.onCompleted: { Component.onCompleted: {
if (source) if (source)
Qt.callLater(() => { Qt.callLater(() => {
one.update(); current = imgComp.createObject(this, {
path: source
});
completed = true; completed = true;
}); });
} }
@ -98,48 +100,34 @@ Item {
} }
} }
Img { Component {
id: one id: imgComp
}
Img { CachingImage {
id: two
}
component Img: CachingImage {
id: img id: img
function update(): void {
if (path === root.source)
root.current = this;
else
path = root.source;
}
anchors.fill: parent anchors.fill: parent
opacity: 0 opacity: 0
scale: Wallpapers.showPreview ? 1 : 0.8
onStatusChanged: { onStatusChanged: {
if (status === Image.Ready) if (status === Image.Ready)
root.current = this; anim.start();
} }
states: State { Anim on opacity {
name: "visible" id: anim
when: root.current === img
PropertyChanges { type: Anim.SlowEffects
img.opacity: 1 running: false
img.scale: 1 from: 0
} to: 1
} }
transitions: Transition { Timer {
Anim { running: root.current !== img && root.current?.status === Image.Ready
target: img interval: anim.duration
properties: "opacity,scale" onTriggered: img.destroy()
} }
} }
} }