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
33 // TODO: focus, caf, ...
34 // TODO: portrait/landscape
35 // TODO: stop viewfinder in settings pages ?
36 // TODO: grid lines, face tracking, ambr
37 // TODO: complete settings pages
38 // TODO: select primary/secondary camera.
39 // TODO: disable debug builds.
40 // TODO: a way to get buffers to the application
41 // TODO: fcam like functionality (precise control over capture parameters).
42 // TODO: mute video sound
47 property alias dimmer: camDimmer
51 Component.onCompleted: {
52 theme.inverted = true;
53 // TODO: hardcoding device id
54 root.resetCamera(0, settings.mode);
57 function showError(msg) {
62 function resetCamera(deviceId, mode) {
63 if (!cam.reset(deviceId, mode)) {
64 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
69 // NOTE: The source will not reset the position when we lose the signal.
70 // This shouldn't be a big problem as we are course enough.
71 // If we ever need street level updates then this will be an issue.
73 active: settings.useGps
74 // TODO: we cannot bind to cam.running because camera will stop
75 // when the connection dialog pops up and we end up with an infinite loop
76 // active: cam.running && settings.useGps
77 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
83 manufacturer: deviceInfo.manufacturer
84 model: deviceInfo.model
85 country: geocode.country
87 suburb: geocode.suburb
88 longitude: positionSource.position.coordinate.longitude
89 longitudeValid: positionSource.position.longitudeValid && settings.useGps
90 latitude: positionSource.position.coordinate.latitude
91 latitudeValid: positionSource.position.latitudeValid && settings.useGps
92 elevation: positionSource.position.coordinate.altitude
93 elevationValid: positionSource.position.altitudeValid && settings.useGps
94 orientation: orientation.orientation
95 artist: settings.creatorName
96 captureDirection: compass.direction
97 captureDirectionValid: compass.directionValid
98 horizontalError: positionSource.position.horizontalAccuracy
99 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
100 dateTimeEnabled: true
115 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 platformStyle: PageStackWindowStyle {
165 function setImageResolution() {
166 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
167 showError(qsTr("Failed to set required resolution"));
173 imageSettings.setImageResolution();
182 function setVideoResolution() {
183 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
184 showError(qsTr("Failed to set required resolution"));
190 videoSettings.setVideoResolution();
198 onImageAspectRatioChanged: {
199 imageSettings.setImageResolution();
202 onImageResolutionChanged: {
203 imageSettings.setImageResolution();
206 onVideoResolutionChanged: {
207 videoSettings.setVideoResolution();
214 // TODO: is this needed ?
215 if (platformWindow.active) {
224 console.log("Camera error (" + code + "): " + message + " " + debug);
225 showError(qsTr("Camera error. Please restart the application."));
227 resourcePolicy.acquire(CameraResources.None);
228 mountProtector.unlock();
233 mountProtector.unlock();
237 Component.onDestruction: cam.stop();
250 notifications: Sounds {
252 mute: !settings.soundEnabled
260 when: cam.mode == Camera.ImageMode
261 value: settings.imageFlashMode
266 property: "imageFlashMode"
267 when: cam.mode == Camera.ImageMode
268 value: cam.flash.value
274 when: cam.mode == Camera.VideoMode
275 value: settings.videoSceneMode
281 when: cam.mode == Camera.ImageMode
282 value: settings.imageSceneMode
288 when: cam.mode == Camera.ImageMode
289 value: settings.imageEvComp
295 when: cam.mode == Camera.VideoMode
296 value: settings.videoEvComp
301 property: "imageEvComp"
302 when: cam.mode == Camera.ImageMode
303 value: cam.evComp.value
308 property: "videoEvComp"
309 when: cam.mode == Camera.VideoMode
310 value: cam.evComp.value
314 target: cam.whiteBalance
316 when: cam.mode == Camera.ImageMode
317 value: settings.imageWhiteBalance
321 target: cam.whiteBalance
323 when: cam.mode == Camera.VideoMode
324 value: settings.videoWhiteBalance
328 target: cam.colorTone
330 when: cam.mode == Camera.ImageMode
331 value: settings.imageColorFilter
335 target: cam.colorTone
337 when: cam.mode == Camera.VideoMode
338 value: settings.videoColorFilter
344 when: cam.mode == Camera.ImageMode
345 value: settings.imageIso
351 when: cam.mode == Camera.ImageMode
364 if (cam.mode == Camera.VideoMode) {
365 replacePage("VideoPage.qml");
368 replacePage("ImagePage.qml");