summaryrefslogtreecommitdiffstats
path: root/experimental/Camera/CapturePreview.qml
blob: 611fa53e28f8ab9858f8930c07805a13e110f19d (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import QtQuick 2.0

Rectangle {
    id: root
    anchors.fill: parent
    color: "black"
    opacity: 0
    enabled: opacity !== 0

    property string previewSrc: ""

    onOpacityChanged: {
        if (opacity === 1 && previewSrc !== "") {
            previewImage.source = previewSrc;
            previewSrc = "";
        }
    }

    Behavior on opacity { NumberAnimation { duration: 100 } }

    function show() {
        previewImage.source = "";
        opacity = 1;
    }

    function setPreview(preview) {
        if (root.opacity === 1)
            previewImage.source = preview;
        else
            root.previewSrc = preview;
    }

    Image {
        id: previewImage
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            root.opacity = 0;
        }
    }
}