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