feat: wallpaper

This commit is contained in:
2 * r + 2 * t 2025-05-05 16:26:38 +10:00
parent 748d5f9e86
commit 9a813f827f
3 changed files with 91 additions and 0 deletions

View file

@ -26,6 +26,8 @@ Variants {
anchors.bottom: true anchors.bottom: true
anchors.left: true anchors.left: true
anchors.right: true anchors.right: true
Wallpaper {}
} }
} }
} }

View file

@ -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
}
}
}
}

View file

@ -9,9 +9,14 @@ import Qt.labs.platform
Singleton { Singleton {
id: root id: root
readonly property string currentPath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7)
readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7) readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7)
property list<Wallpaper> list property list<Wallpaper> list
property bool showPreview: false
readonly property string current: showPreview ? preview : actualCurrent
property string preview
property string actualCurrent
readonly property list<var> preppedWalls: list.map(w => ({ readonly property list<var> preppedWalls: list.map(w => ({
name: Fuzzy.prepare(w.name), name: Fuzzy.prepare(w.name),
@ -32,6 +37,15 @@ Singleton {
setWall.startDetached(); setWall.startDetached();
} }
reloadableId: "wallpapers"
FileView {
path: root.currentPath
watchChanges: true
onFileChanged: reload()
onLoaded: root.actualCurrent = text().trim()
}
Process { Process {
id: setWall id: setWall