Fixes for CheckButton API.
[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         title: qsTr("Flash mode");
14
15         Flash {
16                 id: flash
17                 camera: cam
18                 value: settings.imageFlashMode
19         }
20
21         function flashIcon(val) {
22                 var x = row.children.length;
23                 var i = 0;
24                 for (i = 0; i < x; i++) {
25                         if (row.children[i].value == val) {
26                                 return row.children[i].normalIcon;
27                         }
28                 }
29         }
30
31         widget: Row {
32                 id: row
33                 height: button.checked ? 64 : 0
34                 width: button.checked ? (children.length * height) +  (children.length - 1) * spacing : 0
35                 spacing: 10
36
37                 Behavior on width {
38                         // TODO: seems animation is not working
39                         PropertyAnimation { duration: 250; }
40                 }
41
42                 CheckButton {
43                         normalIcon: "image://theme/icon-m-camera-flash-auto"
44                         checkedIcon: "image://theme/icon-m-camera-flash-auto-pressed"
45                         onClicked: settings.imageFlashMode = value;
46                         value: Flash.Auto
47                         savedValue: settings.imageFlashMode
48                 }
49
50                 CheckButton {
51                         normalIcon: "image://theme/icon-m-camera-flash-always"
52                         checkedIcon: "image://theme/icon-m-camera-flash-always-pressed"
53                         onClicked: settings.imageFlashMode = value;
54                         value: Flash.On
55                         savedValue: settings.imageFlashMode
56                 }
57
58                 CheckButton {
59                         normalIcon: "image://theme/icon-m-camera-flash-off"
60                         checkedIcon: "image://theme/icon-m-camera-flash-off-pressed"
61                         onClicked: settings.imageFlashMode = value;
62                         value: Flash.Off
63                         savedValue: settings.imageFlashMode
64                 }
65
66                 CheckButton {
67                         normalIcon: "image://theme/icon-m-camera-flash-red-eye"
68                         checkedIcon: "image://theme/icon-m-camera-flash-red-eye-pressed"
69                         onClicked: settings.imageFlashMode = value;
70                         value: Flash.RedEye
71                         savedValue: settings.imageFlashMode
72                 }
73         }
74 }