Disable viewfinder in settings pages
[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                 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 /*
74                         SectionHeader {
75                                 text: qsTr("Self timer");
76                         }
77
78                         ButtonRow {
79                                 anchors.horizontalCenter: parent.horizontalCenter
80                                 // TODO:
81                                 Button { text: qsTr("2 seconds"); }
82                                 Button { text: qsTr("10 seconds"); }
83                         }
84 */
85                         SectionHeader {
86                                 text: qsTr("Light sensitivity");
87                         }
88
89                         ButtonRow {
90                                 anchors.horizontalCenter: parent.horizontalCenter
91
92                                 Button {
93                                         text: qsTr("Automatic");
94                                         checked: settings.imageIso == 0;
95                                         onClicked: settings.imageIso = 0;
96                                 }
97
98                                 Button {
99                                         text: qsTr("ISO 100");
100                                         checked: settings.imageIso == 100;
101                                         onClicked: settings.imageIso = 100;
102                                 }
103
104                                 Button {
105                                         text: qsTr("ISO 200");
106                                         checked: settings.imageIso == 200;
107                                         onClicked: settings.imageIso = 200;
108                                 }
109
110                                 Button {
111                                         text: qsTr("ISO 400");
112                                         checked: settings.imageIso == 400;
113                                         onClicked: settings.imageIso = 400;
114                                 }
115
116                                 Button {
117                                         text: qsTr("ISO 800");
118                                         checked: settings.imageIso == 800;
119                                         onClicked: settings.imageIso = 800;
120                                 }
121                         }
122
123                         SectionHeader {
124                                 text: qsTr("Aspect ratio");
125                         }
126
127                         ButtonRow {
128                                 anchors.horizontalCenter: parent.horizontalCenter
129                                 exclusive: false
130                                 onCheckedButtonChanged: {
131                                         // This is needed to initially setup the
132                                         // resolutions buttons
133                                         imageSettings.resolutions.aspectRatio = checkedButton.aspect;
134                                         settings.imageAspectRatio = imageSettings.resolutions.aspectRatio;
135                                 }
136
137                                 Repeater {
138                                         model: imageSettings.aspectRatios
139                                         delegate: Button {
140                                                 property string aspect: modelData;
141                                                 text: qsTr(modelData);
142                                                 checked: settings.imageAspectRatio == modelData;
143                                                 onClicked: {
144                                                         if (!cam.idle) {
145                                                                 showError(qsTr("Camera is busy saving."));
146                                                                 return;
147                                                         }
148
149                                                         settings.imageAspectRatio = modelData;
150                                                         imageSettings.resolutions.aspectRatio = modelData;
151                                                 }
152                                         }
153                                 }
154                         }
155
156                         SectionHeader {
157                                 text: qsTr("Resolution");
158                         }
159
160                         ButtonRow {
161                                 id: resolutionsRow
162                                 anchors.horizontalCenter: parent.horizontalCenter
163                                 exclusive: false
164
165                                 Repeater {
166                                         id: resolutions
167                                         model: imageSettings.resolutions
168
169                                         // http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
170                                         function name(name, mp) {
171                                                 return name.charAt(0).toUpperCase() + name.slice(1) + " " + mp + " Mpx";
172                                         }
173
174                                         delegate: Button {
175                                                 property string resolution: resolutionName
176                                                 property string aspectRatio: resolutionAspectRatio
177                                                 text: resolutions.name(resolutionName, megaPixels);
178                                                 checked: settings.imageResolution == resolutionName
179                                                 onClicked: {
180                                                         if (!cam.idle) {
181                                                                 showError(qsTr("Camera is busy saving."));
182                                                                 return;
183                                                         }
184
185                                                         settings.imageResolution = resolutionName;
186                                                 }
187                                         }
188                                 }
189                         }
190
191                         CameraSettings {
192                                 anchors.horizontalCenter: parent.horizontalCenter
193                         }
194                 }
195         }
196
197         ToolBar {
198                 id: toolBar
199                 anchors.bottom: parent.bottom
200                 tools: ToolBarLayout {
201                         id: layout
202                         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: pageStack.pop(); }
203                 }
204         }
205 }