summaryrefslogtreecommitdiff
path: root/widgets/CachingIconImage.qml
blob: 522a947346d901295b48dbcd6411bd21ded8efbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import QtQuick

Item {
    property alias asynchronous: image.asynchronous
    property alias status: image.status
    property alias mipmap: image.mipmap
    property alias backer: image

    property real implicitSize
    readonly property real actualSize: Math.min(width, height)

    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

        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
    }
}