Request theme icons instead of hardcoding paths
[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                 // TODO: hardcoding
19                 value: Flash.Auto
20         }
21
22         function flashIcon(val) {
23                 var x = row.children.length;
24                 var i = 0;
25                 for (i = 0; i < x; i++) {
26                         if (row.children[i].value == val) {
27                                 return row.children[i].normalIcon;
28                         }
29                 }
30         }
31
32         widget: Row {
33                 id: row
34                 height: button.checked ? 64 : 0
35                 width: button.checked ? (children.length * height) +  (children.length - 1) * spacing : 0
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: "image://theme/icon-m-camera-flash-auto"
45                         checkedIcon: "image://theme/icon-m-camera-flash-auto-pressed"
46                         controller: flash
47                         value: Flash.Auto
48                 }
49
50                 CheckButton {
51                         normalIcon: "image://theme/icon-m-camera-flash-always"
52                         checkedIcon: "image://theme/icon-m-camera-flash-always-pressed"
53                         controller: flash
54                         value: Flash.On
55                 }
56
57                 CheckButton {
58                         normalIcon: "image://theme/icon-m-camera-flash-off"
59                         checkedIcon: "image://theme/icon-m-camera-flash-off-pressed"
60                         controller: flash
61                         value: Flash.Off
62                 }
63
64                 CheckButton {
65                         normalIcon: "image://theme/icon-m-camera-flash-red-eye"
66                         checkedIcon: "image://theme/icon-m-camera-flash-red-eye-pressed"
67                         controller: flash
68                         value: Flash.RedEye
69                 }
70         }
71 }