TODO cleanup
[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         enableViewfinder: false
35         standbyVisible: !Qt.application.active
36
37         Rectangle {
38                 color: "black"
39                 anchors.fill: parent
40         }
41
42         Flickable {
43                 id: flickable
44                 anchors.top: parent.top
45                 anchors.left: parent.left
46                 anchors.right: parent.right
47                 anchors.bottom: toolBar.top
48                 anchors.margins: 10
49                 contentHeight: col.height
50
51                 Column {
52                         id: col
53
54                         width: parent.width
55                         spacing: 10
56
57                         Label {
58                                 font.pixelSize: 36
59                                 text: qsTr("Image settings");
60                         }
61 /*
62                         SectionHeader {
63                                 text: qsTr("Capture mode");
64                         }
65
66                         ButtonRow {
67                                 anchors.horizontalCenter: parent.horizontalCenter
68                                 // TODO:
69                                 Button { text: qsTr("Normal"); }
70                                 Button { text: qsTr("Self timer"); }
71                                 Button { text: qsTr("Fast capture"); }
72                         }
73 */
74 /*
75                         SectionHeader {
76                                 text: qsTr("Self timer");
77                         }
78
79                         ButtonRow {
80                                 anchors.horizontalCenter: parent.horizontalCenter
81                                 // TODO:
82                                 Button { text: qsTr("2 seconds"); }
83                                 Button { text: qsTr("10 seconds"); }
84                         }
85 */
86                         SectionHeader {
87                                 text: qsTr("Light sensitivity");
88                         }
89
90                         ButtonRow {
91                                 anchors.horizontalCenter: parent.horizontalCenter
92
93                                 Button {
94                                         text: qsTr("Automatic");
95                                         checked: settings.imageIso == 0;
96                                         onClicked: settings.imageIso = 0;
97                                 }
98
99                                 Button {
100                                         text: qsTr("ISO 100");
101                                         checked: settings.imageIso == 100;
102                                         onClicked: settings.imageIso = 100;
103                                 }
104
105                                 Button {
106                                         text: qsTr("ISO 200");
107                                         checked: settings.imageIso == 200;
108                                         onClicked: settings.imageIso = 200;
109                                 }
110
111                                 Button {
112                                         text: qsTr("ISO 400");
113                                         checked: settings.imageIso == 400;
114                                         onClicked: settings.imageIso = 400;
115                                 }
116
117                                 Button {
118                                         text: qsTr("ISO 800");
119                                         checked: settings.imageIso == 800;
120                                         onClicked: settings.imageIso = 800;
121                                 }
122                         }
123
124                         SectionHeader {
125                                 text: qsTr("Aspect ratio");
126                         }
127
128                         ButtonRow {
129                                 anchors.horizontalCenter: parent.horizontalCenter
130                                 exclusive: false
131                                 onCheckedButtonChanged: {
132                                         // This is needed to initially setup the
133                                         // resolutions buttons
134                                         imageSettings.resolutions.aspectRatio = checkedButton.aspect;
135                                         settings.imageAspectRatio = imageSettings.resolutions.aspectRatio;
136                                 }
137
138                                 Repeater {
139                                         model: imageSettings.aspectRatios
140                                         delegate: Button {
141                                                 property string aspect: modelData;
142                                                 text: qsTr(modelData);
143                                                 checked: settings.imageAspectRatio == modelData;
144                                                 onClicked: {
145                                                         if (!cam.idle) {
146                                                                 showError(qsTr("Camera is busy saving."));
147                                                                 return;
148                                                         }
149
150                                                         settings.imageAspectRatio = modelData;
151                                                         imageSettings.resolutions.aspectRatio = modelData;
152                                                 }
153                                         }
154                                 }
155                         }
156
157                         SectionHeader {
158                                 text: qsTr("Resolution");
159                         }
160
161                         ButtonRow {
162                                 id: resolutionsRow
163                                 anchors.horizontalCenter: parent.horizontalCenter
164                                 exclusive: false
165
166                                 Repeater {
167                                         id: resolutions
168                                         model: imageSettings.resolutions
169
170                                         // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
171                                         function name(name, mp) {
172                                                 return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
173                                         }
174
175                                         delegate: Button {
176                                                 property string resolution: resolutionName
177                                                 property string aspectRatio: resolutionAspectRatio
178                                                 text: resolutions.name(resolutionName, megaPixels);
179                                                 checked: settings.imageResolution == resolutionName
180                                                 onClicked: {
181                                                         if (!cam.idle) {
182                                                                 showError(qsTr("Camera is busy saving."));
183                                                                 return;
184                                                         }
185
186                                                         settings.imageResolution = resolutionName;
187                                                 }
188                                         }
189                                 }
190                         }
191
192                         CameraSettings {
193                                 anchors.horizontalCenter: parent.horizontalCenter
194                         }
195                 }
196         }
197
198         ToolBar {
199                 id: toolBar
200                 anchors.bottom: parent.bottom
201                 tools: ToolBarLayout {
202                         id: layout
203                         ToolIcon { iconId: "icon-m-toolbar-back-white"; onClicked: pageStack.pop(); }
204                 }
205         }
206 }