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/CachingIconImage.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/CachingIconImage.qml')
| -rw-r--r-- | components/images/CachingIconImage.qml | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/components/images/CachingIconImage.qml b/components/images/CachingIconImage.qml index 522a947..715d379 100644 --- a/components/images/CachingIconImage.qml +++ b/components/images/CachingIconImage.qml @@ -1,31 +1,42 @@ +pragma ComponentBehavior: Bound + +import qs.utils +import Quickshell.Widgets import QtQuick Item { - property alias asynchronous: image.asynchronous - property alias status: image.status - property alias mipmap: image.mipmap - property alias backer: image + id: root - property real implicitSize + readonly property int status: loader.item?.status ?? Image.Null readonly property real actualSize: Math.min(width, height) - + property real implicitSize property url source - onSourceChanged: { - if (source?.toString().startsWith("image://icon/")) - // Directly skip the path prop and treat like a normal Image component - image.source = source; - else if (source) - image.path = source; - } - implicitWidth: implicitSize implicitHeight: implicitSize - CachingImage { - id: image + Loader { + id: loader anchors.fill: parent - fillMode: Image.PreserveAspectFit + sourceComponent: root.source ? root.source.toString().startsWith("image://icon/") ? iconImage : cachingImage : null + } + + Component { + id: cachingImage + + CachingImage { + path: Paths.strip(root.source) + fillMode: Image.PreserveAspectFit + } + } + + Component { + id: iconImage + + IconImage { + source: root.source + asynchronous: true + } } } |