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