summaryrefslogtreecommitdiff
path: root/components/images/CachingImage.qml
blob: 07b98b666ad86e67b99cda88bf3897db6c2a7392 (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
import qs.utils
import Caelestia
import QtQuick

Image {
    id: root

    property alias path: manager.path

    property int sourceWidth
    property int sourceHeight

    asynchronous: true
    fillMode: Image.PreserveAspectCrop
    sourceSize.width: sourceWidth
    sourceSize.height: sourceHeight

    onStatusChanged: {
        if (!manager.usingCache && status === Image.Ready)
            CUtils.saveItem(this, manager.cachePath);
    }

    CachingImageManager {
        id: manager

        item: root
        cacheDir: Paths.imagecache
    }
}