51a8476759d873592d5e2e563937a88fc9f962b6
[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 Selector {
7         id: button
8
9         property alias value: flash.value
10
11         iconSource: flashIcon(flash.value);
12
13         Flash {
14                 id: flash
15                 camera: cam
16                 // TODO: hardcoding
17                 value: Flash.Auto
18         }
19
20         function flashIcon(val) {
21                 var x = row.children.length;
22                 var i = 0;
23                 for (i = 0; i < x; i++) {
24                         if (row.children[i].value == val) {
25                                 return row.children[i].normalIcon;
26                         }
27                 }
28         }
29
30         widget: Row {
31                 id: row
32                 height: button.checked ? 64 : 0
33                 width: button.checked ? (children.length * height) +  (children.length - 1) * spacing : 0
34                 anchors.left: button.right
35                 anchors.leftMargin: 20
36                 spacing: 10
37
38                 Behavior on width {
39                         // TODO: seems animation is not working
40                         PropertyAnimation { duration: 250; }
41                 }
42
43                 CheckButton {
44                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-auto.png"
45                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-auto-pressed.png"
46                         controller: flash
47                         value: Flash.Auto
48                 }
49
50                 CheckButton {
51                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-always.png"
52                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-always-pressed.png"
53                         controller: flash
54                         value: Flash.On
55                 }
56
57                 CheckButton {
58                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-off.png"
59                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-off-pressed.png"
60                         controller: flash
61                         value: Flash.Off
62                 }
63
64                 CheckButton {
65                         normalIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-red-eye.png"
66                         checkedIcon: "/usr/share/themes/blanco/meegotouch/icons/icon-m-camera-flash-red-eye-pressed.png"
67                         controller: flash
68                         value: Flash.RedEye
69                 }
70         }
71 }