~danielholm/+junk/torchapp

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
46
47
48
49
50
51
52
53
54
55
56
57
import QtQuick 2.0
import Ubuntu.Components 0.1
import QtMultimedia 5.0
import QtGraphicalEffects 1.0


MainView {
    id:mainView
    property bool turnon: true
    // objectName for functional testing purposes (autopilot-qt5)
    objectName: "mainView"


    // Note! applicationName needs to match the .desktop filename
    applicationName: "torch"
    
    /* 
     This property enables the application to change orientation 
     when the device is rotated. The default is false.
    */
    //automaticOrientation: true
    
    width: units.gu(50)
    height: units.gu(75)

    Rectangle {
        color: "black"
        anchors.fill: parent
    }

    Image {
        id:bulbandhand
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
        height: units.gu(20)
        width: units.gu(20)
        source: "images/torch-off.svg"

    }
    Image {
        id:bulb
        anchors.fill:bulbandhand
        source: "images/torch-on.svg"

        MouseArea {
           anchors.fill: parent
           onClicked: mainView.turnon=!mainView.turnon
       }
    }

    Camera {
            id: camera
            flash.mode:!mainView.turnon?Camera.FlashOff:Camera.FlashVideoLight
    }


}