diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-27 20:32:51 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-27 20:32:51 +1000 |
| commit | 4f60c07e0540f89654b469d134095c37e238d3e8 (patch) | |
| tree | 6853439cce6933475898c608d4d846fd91fde6f5 /components/images/CachingImage.qml | |
| parent | internal: move notif icon lower (diff) | |
| download | caelestia-shell-4f60c07e0540f89654b469d134095c37e238d3e8.tar.gz caelestia-shell-4f60c07e0540f89654b469d134095c37e238d3e8.tar.bz2 caelestia-shell-4f60c07e0540f89654b469d134095c37e238d3e8.zip | |
plugin: create caching image manager
No need for external proc
Diffstat (limited to 'components/images/CachingImage.qml')
| -rw-r--r-- | components/images/CachingImage.qml | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/components/images/CachingImage.qml b/components/images/CachingImage.qml index add459a..07b98b6 100644 --- a/components/images/CachingImage.qml +++ b/components/images/CachingImage.qml @@ -1,44 +1,29 @@ import qs.utils import Caelestia -import Quickshell -import Quickshell.Io import QtQuick Image { id: root - property string path - property string hash - readonly property url cachePath: `${Paths.imagecache}/${hash}@${effectiveWidth}x${effectiveHeight}.png` + property alias path: manager.path - readonly property real effectiveScale: QsWindow.window?.devicePixelRatio ?? 1 - readonly property int effectiveWidth: Math.ceil(width * effectiveScale) - readonly property int effectiveHeight: Math.ceil(height * effectiveScale) + property int sourceWidth + property int sourceHeight asynchronous: true fillMode: Image.PreserveAspectCrop - sourceSize.width: effectiveWidth - sourceSize.height: effectiveHeight - - onPathChanged: shaProc.exec(["sha256sum", Paths.strip(path)]) - - onCachePathChanged: { - if (hash) - source = cachePath; - } + sourceSize.width: sourceWidth + sourceSize.height: sourceHeight onStatusChanged: { - if (source == cachePath && status === Image.Error) - source = path; - else if (source == path && status === Image.Ready) - CUtils.saveItem(this, cachePath); + if (!manager.usingCache && status === Image.Ready) + CUtils.saveItem(this, manager.cachePath); } - Process { - id: shaProc + CachingImageManager { + id: manager - stdout: StdioCollector { - onStreamFinished: root.hash = text.split(" ")[0] - } + item: root + cacheDir: Paths.imagecache } } |