feat: rework wallpaper to use stack instead of A/B
Also switch colour animation to SlowEffects
This commit is contained in:
parent
3191ea9757
commit
04f34034c3
2 changed files with 31 additions and 43 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
id: img
|
||||||
}
|
|
||||||
|
|
||||||
component Img: CachingImage {
|
anchors.fill: parent
|
||||||
id: img
|
|
||||||
|
|
||||||
function update(): void {
|
opacity: 0
|
||||||
if (path === root.source)
|
|
||||||
root.current = this;
|
|
||||||
else
|
|
||||||
path = root.source;
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.fill: parent
|
onStatusChanged: {
|
||||||
|
if (status === Image.Ready)
|
||||||
opacity: 0
|
anim.start();
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
transitions: Transition {
|
Anim on opacity {
|
||||||
Anim {
|
id: anim
|
||||||
target: img
|
|
||||||
properties: "opacity,scale"
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue