summaryrefslogtreecommitdiff
path: root/modules/background/Wallpaper.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-05 16:26:38 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-05 16:26:38 +1000
commit9a813f827feee7eb4a6036f7be64e3208bdf89bc (patch)
treefdc1a56541022184e1f7961d00e5e1847db0326f /modules/background/Wallpaper.qml
parentcachingimage: fix slow loading (diff)
downloadcaelestia-shell-9a813f827feee7eb4a6036f7be64e3208bdf89bc.tar.gz
caelestia-shell-9a813f827feee7eb4a6036f7be64e3208bdf89bc.tar.bz2
caelestia-shell-9a813f827feee7eb4a6036f7be64e3208bdf89bc.zip
feat: wallpaper
Diffstat (limited to 'modules/background/Wallpaper.qml')
-rw-r--r--modules/background/Wallpaper.qml75
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/background/Wallpaper.qml b/modules/background/Wallpaper.qml
new file mode 100644
index 0000000..80848d5
--- /dev/null
+++ b/modules/background/Wallpaper.qml
@@ -0,0 +1,75 @@
+pragma ComponentBehavior: Bound
+
+import "root:/widgets"
+import "root:/services"
+import "root:/config"
+import QtQuick
+
+Item {
+ id: root
+
+ property url source: Wallpapers.current ? `file://${Wallpapers.current}` : ""
+ property Image current: one
+
+ anchors.fill: parent
+
+ onSourceChanged: {
+ if (current === one)
+ two.update();
+ else
+ one.update();
+ }
+
+ Img {
+ id: one
+ }
+
+ Img {
+ id: two
+ }
+
+ component Img: Image {
+ id: img
+
+ function update(): void {
+ if (source === root.source)
+ root.current = this;
+ else
+ source = root.source;
+ }
+
+ anchors.fill: parent
+ asynchronous: true
+ fillMode: Image.PreserveAspectCrop
+ opacity: 0
+ scale: 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 {
+ from: "*"
+ to: "*"
+
+ NumberAnimation {
+ target: img
+ properties: "opacity,scale"
+ duration: Appearance.anim.durations.normal
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.standard
+ }
+ }
+ }
+}