From 7729546469a0f8517d639a9bc98554bd7ec13332 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 31 Aug 2025 22:03:58 +1000 Subject: plugin: add FileSystemModel --- services/Wallpapers.qml | 55 ++++++++----------------------------------------- 1 file changed, 9 insertions(+), 46 deletions(-) (limited to 'services') diff --git a/services/Wallpapers.qml b/services/Wallpapers.qml index 30d7b0e..9e2bf2d 100644 --- a/services/Wallpapers.qml +++ b/services/Wallpapers.qml @@ -2,6 +2,7 @@ pragma Singleton import qs.config import qs.utils +import Caelestia import Quickshell import Quickshell.Io import QtQuick @@ -39,7 +40,7 @@ Searcher { reloadableId: "wallpapers" - list: wallpapers.instances + list: wallpapers.files useFuzzy: Config.launcher.useFuzzy.wallpapers extraOpts: useFuzzy ? ({}) : ({ forward: false @@ -71,6 +72,13 @@ Searcher { } } + FileSystemModel { + id: wallpapers + + path: Paths.expandTilde(Paths.wallsdir) + filter: FileSystemModel.ImagesOnly + } + Process { id: getPreviewColoursProc @@ -82,49 +90,4 @@ Searcher { } } } - - Process { - id: getWallsProc - - running: true - command: ["find", "-L", Paths.expandTilde(Paths.wallsdir), "-type", "d", "-path", '*/.*', "-prune", "-o", "-not", "-name", '.*', "-type", "f", "-print"] - stdout: StdioCollector { - onStreamFinished: wallpapers.model = text.trim().split("\n").filter(w => Images.isValidImageByName(w)).sort() - } - } - - Process { - id: watchWallsProc - - running: true - command: ["inotifywait", "-r", "-e", "close_write,moved_to,create", "-m", Paths.expandTilde(Paths.wallsdir)] - stdout: SplitParser { - onRead: data => { - if (Images.isValidImageByName(data)) - getWallsProc.running = true; - } - } - } - - Connections { - target: Config.paths - - function onWallpaperDirChanged(): void { - getWallsProc.running = true; - watchWallsProc.running = false; - watchWallsProc.running = true; - } - } - - Variants { - id: wallpapers - - Wallpaper {} - } - - component Wallpaper: QtObject { - required property string modelData - readonly property string path: modelData - readonly property string name: path.slice(Paths.expandTilde(Paths.wallsdir).length + 1, path.lastIndexOf(".")) - } } -- cgit v1.2.3-freya