summaryrefslogtreecommitdiff
path: root/widgets
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-04 14:19:38 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-05-04 14:19:38 +1000
commit9c4821b4b4c298eeaec6c108f435de4cb5fefc16 (patch)
treeacbba6cff7c1550e60db3c6a15ad3f54e8f36979 /widgets
parentfeat: launcher wallpaper selector (diff)
downloadcaelestia-shell-9c4821b4b4c298eeaec6c108f435de4cb5fefc16.tar.gz
caelestia-shell-9c4821b4b4c298eeaec6c108f435de4cb5fefc16.tar.bz2
caelestia-shell-9c4821b4b4c298eeaec6c108f435de4cb5fefc16.zip
feat: cache wallpapers
Reduces wallpaper load time massively
Diffstat (limited to 'widgets')
-rw-r--r--widgets/CachingImage.qml45
1 files changed, 45 insertions, 0 deletions
diff --git a/widgets/CachingImage.qml b/widgets/CachingImage.qml
new file mode 100644
index 0000000..cff5676
--- /dev/null
+++ b/widgets/CachingImage.qml
@@ -0,0 +1,45 @@
+import "root:/services"
+import Quickshell.Io
+import QtQuick
+
+Image {
+ id: root
+
+ required property string path
+ property string thumbnail: path
+
+ source: `file://${thumbnail}`
+ asynchronous: true
+ fillMode: Image.PreserveAspectCrop
+
+ onPathChanged: shaProc.running = true
+ onWidthChanged: shaProc.running = true
+ onHeightChanged: shaProc.running = true
+ onStatusChanged: {
+ if (status === Image.Error)
+ waitProc.running = true;
+ }
+
+ Process {
+ id: shaProc
+
+ command: ["sha1sum", root.path]
+ stdout: SplitParser {
+ onRead: data => root.thumbnail = Thumbnailer.go(data.split(" ")[0], root.path, root.width, root.height)
+ }
+ }
+
+ Process {
+ id: waitProc
+
+ command: ["inotifywait", "-q", "-e", "close_write", "--format", "%w%f", "-m", root.thumbnail.slice(0, root.thumbnail.lastIndexOf("/"))]
+ stdout: SplitParser {
+ onRead: file => {
+ if (file === root.thumbnail) {
+ root.source = file;
+ waitProc.running = false;
+ }
+ }
+ }
+ }
+}