blob: 7152e720e27b895501c21ed0ae57589af1d55caa (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
pragma Singleton
import qs.config
import qs.utils
import Caelestia
import Quickshell
import Quickshell.Io
import QtQuick
Searcher {
id: root
readonly property string currentNamePath: Paths.strip(`${Paths.state}/wallpaper/path.txt`)
readonly property list<string> smartArg: Config.services.smartScheme ? [] : ["--no-smart"]
property bool showPreview: false
readonly property string current: showPreview ? previewPath : actualCurrent
property string previewPath
property string actualCurrent
property bool previewColourLock
function setWallpaper(path: string): void {
actualCurrent = path;
Quickshell.execDetached(["caelestia", "wallpaper", "-f", path, ...smartArg]);
}
function preview(path: string): void {
previewPath = path;
showPreview = true;
if (Colours.scheme === "dynamic")
getPreviewColoursProc.running = true;
}
function stopPreview(): void {
showPreview = false;
if (!previewColourLock)
Colours.showPreview = false;
}
reloadableId: "wallpapers"
list: wallpapers.entries
useFuzzy: Config.launcher.useFuzzy.wallpapers
extraOpts: useFuzzy ? ({}) : ({
forward: false
})
IpcHandler {
target: "wallpaper"
function get(): string {
return root.actualCurrent;
}
function set(path: string): void {
root.setWallpaper(path);
}
function list(): string {
return root.list.map(w => w.path).join("\n");
}
}
FileView {
path: root.currentNamePath
watchChanges: true
onFileChanged: reload()
onLoaded: {
root.actualCurrent = text().trim();
root.previewColourLock = false;
}
}
FileSystemModel {
id: wallpapers
path: Paths.expandTilde(Paths.wallsdir)
filter: FileSystemModel.Images
}
Process {
id: getPreviewColoursProc
command: ["caelestia", "wallpaper", "-p", root.previewPath, ...root.smartArg]
stdout: StdioCollector {
onStreamFinished: {
Colours.load(text, true);
Colours.showPreview = true;
}
}
}
}
|