Pages which don't need the pipeline should show standby when application window is...
[harmattan/cameraplus] / qml / ImageSettingsPage.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 import QtQuick 1.1
24 import com.nokia.meego 1.1
25 import QtCamera 1.0
26 import CameraPlus 1.0
27
28 import "data.js" as Data
29
30 CameraPage {
31         id: page
32         controlsVisible: false
33         policyMode: CameraResources.Image
34         needsPipeline: false
35         standbyVisible: !Qt.application.active
36
37         Rectangle {
38                 color: "black"
39                 anchors.fill: parent
40         }
41
42         Flickable {
43                 anchors.top: parent.top
44                 anchors.left: parent.left
45                 anchors.right: parent.right
46                 anchors.bottom: toolBar.top
47                 anchors.margins: 10
48                 contentHeight: col.height
49
50                 Column {
51                         id: col
52
53                         width: parent.width
54                         spacing: 10
55
56                         Label {
57                                 font.pixelSize: 36
58                                 text: qsTr("Image settings");
59                         }
60
61                         SectionHeader {
62                                 text: qsTr("Capture mode");
63                         }
64
65                         ButtonRow {
66                                 anchors.horizontalCenter: parent.horizontalCenter
67                                 // TODO:
68                                 Button { text: qsTr("Normal"); }
69                                 Button { text: qsTr("Self timer"); }
70                                 Button { text: qsTr("Fast capture"); }
71                         }
72
73                         Row {
74                                 width: parent.width
75
76                                 ListItem {
77                                         id: wb
78                                         width: parent.width / 2
79                                         title: qsTr("White balance");
80                                         subtitle: Data.wbName(settings.imageWhiteBalance);
81                                         iconId: Data.wbSelectedIcon(settings.imageWhiteBalance);
82                                         onClicked: openFile("ImageWhiteBalancePage.qml");
83                                 }
84
85                                 ListItem {
86                                         id: cf
87                                         width: parent.width / 2
88                                         title: qsTr("Color filter");
89                                         subtitle: Data.cfName(settings.imageColorFilter);
90                                         iconId: Data.cfSelectedIcon(settings.imageColorFilter);
91                                         onClicked: openFile("ImageColorFilterPage.qml");
92                                 }
93                         }
94
95                         SectionHeader {
96                                 text: qsTr("Self timer");
97                         }
98
99                         ButtonRow {
100                                 anchors.horizontalCenter: parent.horizontalCenter
101                                 // TODO:
102                                 Button { text: qsTr("2 seconds"); }
103                                 Button { text: qsTr("10 seconds"); }
104                         }
105
106                         SectionHeader {
107                                 text: qsTr("Light sensitivity");
108                         }
109
110                         ButtonRow {
111                                 anchors.horizontalCenter: parent.horizontalCenter
112
113                                 Button {
114                                         text: qsTr("Automatic");
115                                         checked: settings.imageIso == 0;
116                                         onClicked: settings.imageIso = 0;
117                                 }
118
119                                 Button {
120                                         text: qsTr("ISO 100");
121                                         checked: settings.imageIso == 100;
122                                         onClicked: settings.imageIso = 100;
123                                 }
124
125                                 Button {
126                                         text: qsTr("ISO 200");
127                                         checked: settings.imageIso == 200;
128                                         onClicked: settings.imageIso = 200;
129                                 }
130
131                                 Button {
132                                         text: qsTr("ISO 400");
133                                         checked: settings.imageIso == 400;
134                                         onClicked: settings.imageIso = 400;
135                                 }
136
137                                 Button {
138                                         text: qsTr("ISO 800");
139                                         checked: settings.imageIso == 800;
140                                         onClicked: settings.imageIso = 800;
141                                 }
142                         }
143
144                         SectionHeader {
145                                 text: qsTr("Aspect ratio");
146                         }
147
148                         ButtonRow {
149                                 anchors.horizontalCenter: parent.horizontalCenter
150                                 exclusive: false
151                                 onCheckedButtonChanged: {
152                                         // This is needed to initially setup the
153                                         // resolutions buttons
154                                         imageSettings.resolutions.aspectRatio = checkedButton.aspect;
155                                         settings.imageAspectRatio = imageSettings.resolutions.aspectRatio;
156                                 }
157
158                                 Repeater {
159                                         model: imageSettings.aspectRatios
160                                         delegate: Button {
161                                                 property string aspect: modelData;
162                                                 text: qsTr(modelData);
163                                                 checked: settings.imageAspectRatio == modelData;
164                                                 onClicked: {
165                                                         if (!cam.idle) {
166                                                                 showError(qsTr("Camera is busy saving."));
167                                                                 return;
168                                                         }
169
170                                                         settings.imageAspectRatio = modelData;
171                                                         imageSettings.resolutions.aspectRatio = modelData;
172                                                 }
173                                         }
174                                 }
175                         }
176
177                         SectionHeader {
178                                 text: qsTr("Resolution");
179                         }
180
181                         ButtonRow {
182                                 id: resolutionsRow
183                                 anchors.horizontalCenter: parent.horizontalCenter
184                                 exclusive: false
185
186                                 Repeater {
187                                         id: resolutions
188                                         model: imageSettings.resolutions
189
190                                         // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
191                                         function name(name, mp) {
192                                                 return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
193                                         }
194
195                                         delegate: Button {
196                                                 property string resolution: resolutionName
197                                                 property string aspectRatio: resolutionAspectRatio
198                                                 text: resolutions.name(resolutionName, megaPixels);
199                                                 checked: settings.imageResolution == resolutionName
200                                                 onClicked: {
201                                                         if (!cam.idle) {
202                                                                 showError(qsTr("Camera is busy saving."));
203                                                                 return;
204                                                         }
205
206                                                         settings.imageResolution = resolutionName;
207                                                 }
208                                         }
209                                 }
210                         }
211
212                         CameraSettings {
213                                 anchors.horizontalCenter: parent.horizontalCenter
214                         }
215                 }
216         }
217
218         ToolBar {
219                 id: toolBar
220                 anchors.bottom: parent.bottom
221                 tools: ToolBarLayout {
222                         id: layout
223                         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
224                 }
225         }
226 }