diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-05 19:06:32 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-05 19:06:32 +1000 |
| commit | 1a650b73bc75a7b617d9e0c24d680eae47218f3d (patch) | |
| tree | 33d7d5d76733bff274eda57fe7b3f93f7534f7c6 /widgets | |
| parent | wallpaper: limit source size (diff) | |
| download | caelestia-shell-1a650b73bc75a7b617d9e0c24d680eae47218f3d.tar.gz caelestia-shell-1a650b73bc75a7b617d9e0c24d680eae47218f3d.tar.bz2 caelestia-shell-1a650b73bc75a7b617d9e0c24d680eae47218f3d.zip | |
thumbnailer: better caching
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/CachingImage.qml | 47 |
1 files changed, 12 insertions, 35 deletions
diff --git a/widgets/CachingImage.qml b/widgets/CachingImage.qml index 85593ed..08be473 100644 --- a/widgets/CachingImage.qml +++ b/widgets/CachingImage.qml @@ -5,46 +5,23 @@ import QtQuick Image { id: root - required property string path - property string thumbnail + property string path + readonly property Thumbnailer.Thumbnail thumbnail: Thumbnailer.go(path, width, height) - source: { - if (thumbnail) - return `file://${thumbnail}`; - shaProc.running = true; - return ""; - } + source: thumbnail.path ? `file://${thumbnail.path}` : "" 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; + onPathChanged: { + thumbnail.originalPath = path; + thumbnail.reload(); } - - Process { - id: shaProc - - command: ["sha1sum", root.path] - stdout: SplitParser { - onRead: data => root.thumbnail = Thumbnailer.go(data.split(" ")[0], root.path, root.width, root.height) - } + onWidthChanged: { + thumbnail.width = width; + thumbnail.reload(); } - - 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; - } - } - } + onHeightChanged: { + thumbnail.height = height; + thumbnail.reload(); } } |