4 * This file is part of CameraPlus.
6 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
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.
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.
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
24 import com.nokia.meego 1.1
25 import com.nokia.extras 1.1
28 import QtMobility.systeminfo 1.2
29 import QtMobility.location 1.2
32 // TODO: flash not ready
34 // TODO: portrait/landscape
35 // TODO: stop viewfinder in settings pages ?
36 // TODO: grid lines, face tracking, ambr
37 // TODO: select primary/secondary camera.
38 // TODO: disable debug builds.
39 // TODO: a way to get buffers to the application
40 // TODO: fcam like functionality (precise control over capture parameters).
41 // TODO: mute video sound
46 property alias dimmer: camDimmer
50 Component.onCompleted: {
51 theme.inverted = true;
52 // TODO: hardcoding device id
53 root.resetCamera(0, settings.mode);
56 function showError(msg) {
61 function resetCamera(deviceId, mode) {
62 if (!cam.reset(deviceId, mode)) {
63 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
68 // NOTE: The source will not reset the position when we lose the signal.
69 // This shouldn't be a big problem as we are course enough.
70 // If we ever need street level updates then this will be an issue.
72 active: settings.useGps
73 // TODO: we cannot bind to cam.running because camera will stop
74 // when the connection dialog pops up and we end up with an infinite loop
75 // active: cam.running && settings.useGps
76 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
82 manufacturer: deviceInfo.manufacturer
83 model: deviceInfo.model
84 country: geocode.country
86 suburb: geocode.suburb
87 longitude: positionSource.position.coordinate.longitude
88 longitudeValid: positionSource.position.longitudeValid && settings.useGps
89 latitude: positionSource.position.coordinate.latitude
90 latitudeValid: positionSource.position.latitudeValid && settings.useGps
91 elevation: positionSource.position.coordinate.altitude
92 elevationValid: positionSource.position.altitudeValid && settings.useGps
93 orientation: orientation.orientation
94 artist: settings.creatorName
95 captureDirection: compass.direction
96 captureDirectionValid: compass.directionValid
97 horizontalError: positionSource.position.horizontalAccuracy
98 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
114 active: cam.running && settings.useGps && settings.useGeotags
140 imageSuffix: cam.imageSuffix
141 videoSuffix: cam.videoSuffix
146 path: fileNaming.path
149 function replacePage(file) {
150 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
153 function openFile(file) {
154 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
157 function openFileNow(file) {
158 pageStack.push(Qt.resolvedUrl(file), {cam: cam}, true);
161 platformStyle: PageStackWindowStyle {
162 cornersVisible: false
170 function setImageResolution() {
171 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
172 showError(qsTr("Failed to set required resolution"));
178 imageSettings.setImageResolution();
187 function setVideoResolution() {
188 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
189 showError(qsTr("Failed to set required resolution"));
195 videoSettings.setVideoResolution();
203 onImageAspectRatioChanged: {
204 imageSettings.setImageResolution();
207 onImageResolutionChanged: {
208 imageSettings.setImageResolution();
211 onVideoResolutionChanged: {
212 videoSettings.setVideoResolution();
219 // TODO: is this needed ?
220 if (platformWindow.active) {
229 console.log("Camera error (" + code + "): " + message + " " + debug);
230 showError(qsTr("Camera error. Please restart the application."));
232 mountProtector.unlock();
237 mountProtector.unlock();
241 Component.onDestruction: cam.stop();
254 notifications: Sounds {
256 mute: !settings.soundEnabled
264 when: cam.mode == Camera.ImageMode
265 value: settings.imageFlashMode
270 property: "imageFlashMode"
271 when: cam.mode == Camera.ImageMode
272 value: cam.flash.value
278 when: cam.mode == Camera.VideoMode
279 value: settings.videoSceneMode
285 when: cam.mode == Camera.ImageMode
286 value: settings.imageSceneMode
292 when: cam.mode == Camera.ImageMode
293 value: settings.imageEvComp
299 when: cam.mode == Camera.VideoMode
300 value: settings.videoEvComp
305 property: "imageEvComp"
306 when: cam.mode == Camera.ImageMode
307 value: cam.evComp.value
312 property: "videoEvComp"
313 when: cam.mode == Camera.VideoMode
314 value: cam.evComp.value
318 target: cam.whiteBalance
320 when: cam.mode == Camera.ImageMode
321 value: settings.imageWhiteBalance
325 target: cam.whiteBalance
327 when: cam.mode == Camera.VideoMode
328 value: settings.videoWhiteBalance
332 target: cam.colorTone
334 when: cam.mode == Camera.ImageMode
335 value: settings.imageColorFilter
339 target: cam.colorTone
341 when: cam.mode == Camera.VideoMode
342 value: settings.videoColorFilter
348 when: cam.mode == Camera.ImageMode
349 value: settings.imageIso
355 when: cam.mode == Camera.ImageMode
362 manufacturer: deviceInfo.manufacturer
363 model: deviceInfo.model
375 if (cam.mode == Camera.VideoMode) {
376 replacePage("VideoPage.qml");
379 replacePage("ImagePage.qml");