summaryrefslogtreecommitdiff
path: root/widgets/CachingImage.qml
blob: 08be473746aed32004cbf06e39dc50c34219e3eb (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
import "root:/services"
import Quickshell.Io
import QtQuick

Image {
    id: root

    property string path
    readonly property Thumbnailer.Thumbnail thumbnail: Thumbnailer.go(path, width, height)

    source: thumbnail.path ? `file://${thumbnail.path}` : ""
    asynchronous: true
    fillMode: Image.PreserveAspectCrop

    onPathChanged: {
        thumbnail.originalPath = path;
        thumbnail.reload();
    }
    onWidthChanged: {
        thumbnail.width = width;
        thumbnail.reload();
    }
    onHeightChanged: {
        thumbnail.height = height;
        thumbnail.reload();
    }
}