nosignal-shell/widgets/CachingImage.qml
2 * r + 2 * t 0505ba8f92 launcher: anim wallpaperitem creation
Also fix cachingimage
2025-05-04 16:17:10 +10:00

50 lines
1.2 KiB
QML

import "root:/services"
import Quickshell.Io
import QtQuick
Image {
id: root
required property string path
property string thumbnail: path
source: {
if (thumbnail)
return `file://${thumbnail}`;
shaProc.running = true;
return "";
}
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;
}
}
}
}
}