From 4f60c07e0540f89654b469d134095c37e238d3e8 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 27 Aug 2025 20:32:51 +1000 Subject: plugin: create caching image manager No need for external proc --- components/images/CachingIconImage.qml | 45 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'components/images/CachingIconImage.qml') 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 + } } } -- cgit v1.2.3-freya