blob: 692a09073d48a166f189cf8e02b28d82e8e12ed8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
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;
}
}
}
}
}
|