Initial import
[harmattan/cameraplus] / qml / FlashButton.qml
1 // -*- qml -*-
2 import QtQuick 1.1
3 import com.nokia.meego 1.1
4 import QtCamera 1.0
5
6 MouseArea {
7         id: mouse
8         anchors.fill: parent
9         enabled: false
10         onClicked: enabled = !enabled;
11         onEnabledChanged: button.checked = enabled;
12
13         function flashIcon(val) {
14                 var x = row.children.length;
15                 var i = 0;
16                 for (i = 0; i < x; i++) {
17                         if (row.children[i].value == val) {
18                                 return row.children[i].normalIcon;
19                         }
20                 }
21         }
22
23         Timer {
24                 interval: 2000
25                 running: mouse.enabled
26                 repeat: false
27                 onTriggered: mouse.enabled = !mouse.enabled
28         }
29
30         Flash {
31                 id: flash
32                 camera: cam
33                 // TODO: hardcoding
34                 value: Flash.Auto
35         }
36
37         Button {
38                 anchors.left: parent.left
39                 id: button
40                 width: 64
41                 height: 64
42                 opacity: 0.5
43                 onClicked: mouse.enabled = !mouse.enabled;
44                 checkable: true
45                 iconSource: flashIcon(flash.value);
46         }
47
48         Row {
49                 id: row
50                 height: mouse.enabled ? 64 : 0
51                 width: mouse.enabled ? (children.length * height) +  (children.length - 1) * spacing : 0
52                 anchors.left: button.right
53                 anchors.leftMargin: 20
54                 spacing: 10
55
56                 Behavior on width {
57                         // TODO: seems animation is not working
58                         PropertyAnimation { duration: 250; }
59                 }
60
61                 CheckButton {
62                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-auto.png"
63                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-auto-pressed.png"
64                         controller: flash
65                         value: Flash.Auto
66                         fader: mouse
67                 }
68
69                 CheckButton {
70                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-always.png"
71                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-always-pressed.png"
72                         controller: flash
73                         value: Flash.On
74                         fader: mouse
75                 }
76
77                 CheckButton {
78                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-off.png"
79                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-off-pressed.png"
80                         controller: flash
81                         value: Flash.Off
82                         fader: mouse
83                 }
84
85                 CheckButton {
86                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-red-eye.png"
87                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-red-eye-pressed.png"
88                         controller: flash
89                         value: Flash.RedEye
90                         fader: mouse
91                 }
92         }
93 }