From 04f34034c3ddbe264076652a608a4082b115d370 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 23 Apr 2026 01:00:35 +1000 Subject: [PATCH] feat: rework wallpaper to use stack instead of A/B Also switch colour animation to SlowEffects --- components/CAnim.qml | 4 +- modules/background/Wallpaper.qml | 70 +++++++++++++------------------- 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/components/CAnim.qml b/components/CAnim.qml index b86fcce1..17168de3 100644 --- a/components/CAnim.qml +++ b/components/CAnim.qml @@ -2,6 +2,6 @@ import QtQuick import Caelestia.Config ColorAnimation { - duration: Tokens.anim.durations.normal - easing: Tokens.anim.standard + duration: Tokens.anim.durations.expressiveSlowEffects + easing: Tokens.anim.expressiveSlowEffects } diff --git a/modules/background/Wallpaper.qml b/modules/background/Wallpaper.qml index c0980f34..21ff34eb 100644 --- a/modules/background/Wallpaper.qml +++ b/modules/background/Wallpaper.qml @@ -12,22 +12,24 @@ Item { id: root property string source: Wallpapers.current - property Image current: one + property CachingImage current property bool completed onSourceChanged: { if (!source) current = null; - else if (current === one) - two.update(); else - one.update(); + current = imgComp.createObject(this, { + path: source + }); } Component.onCompleted: { if (source) Qt.callLater(() => { - one.update(); + current = imgComp.createObject(this, { + path: source + }); completed = true; }); } @@ -98,48 +100,34 @@ Item { } } - Img { - id: one - } + Component { + id: imgComp - Img { - id: two - } + CachingImage { + id: img - component Img: CachingImage { - id: img + anchors.fill: parent - function update(): void { - if (path === root.source) - root.current = this; - else - path = root.source; - } + opacity: 0 - anchors.fill: parent - - opacity: 0 - scale: Wallpapers.showPreview ? 1 : 0.8 - - onStatusChanged: { - if (status === Image.Ready) - root.current = this; - } - - states: State { - name: "visible" - when: root.current === img - - PropertyChanges { - img.opacity: 1 - img.scale: 1 + onStatusChanged: { + if (status === Image.Ready) + anim.start(); } - } - transitions: Transition { - Anim { - target: img - properties: "opacity,scale" + Anim on opacity { + id: anim + + type: Anim.SlowEffects + running: false + from: 0 + to: 1 + } + + Timer { + running: root.current !== img && root.current?.status === Image.Ready + interval: anim.duration + onTriggered: img.destroy() } } }