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: record video in a hidden directory and then copy the video to avoid tracker indexing it.
36 // TODO: stop viewfinder in settings pages ?
37 // TODO: prevent going to mass storage while recording and capturing
38 // TODO: grid lines, face tracking, ambr
39 // TODO: complete settings pages
40 // TODO: stop camera properly when we get closed.
41 // TODO: select primary/secondary camera.
42 // TODO: disable debug builds.
43 // TODO: a way to get buffers to the application
44 // TODO: fcam like functionality (precise control over capture parameters).
49 property alias dimmer: camDimmer
53 Component.onCompleted: {
54 theme.inverted = true;
55 if (settings.mode == 0) {
56 openFile("ImagePage.qml");
59 openFile("VideoPage.qml");
63 function showError(msg) {
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
121 if (resourcePolicy.acquired) {
125 // TODO: We need a way to force a stop.
148 imageSuffix: cam.imageSuffix
149 videoSuffix: cam.videoSuffix
152 function replacePage(file) {
153 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
156 function openFile(file) {
157 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
160 platformStyle: PageStackWindowStyle {
168 function setImageResolution() {
169 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
170 showError(qsTr("Failed to set required resolution"));
176 imageSettings.setImageResolution();
185 function setVideoResolution() {
186 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
187 showError(qsTr("Failed to set required resolution"));
193 videoSettings.setVideoResolution();
201 onImageAspectRatioChanged: {
202 imageSettings.setImageResolution();
205 onImageResolutionChanged: {
206 imageSettings.setImageResolution();
209 onVideoResolutionChanged: {
210 videoSettings.setVideoResolution();
217 // TODO: is this needed ?
218 if (platformWindow.active) {
227 console.log("Camera error (" + code + "): " + message + " " + debug);
228 showError(qsTr("Camera error. Please restart the application."));
232 // TODO: hardcoding device id
233 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
234 Component.onDestruction: {
235 console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
249 notifications: Sounds {
251 mute: !settings.soundEnabled
258 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
262 id: colorToneController
264 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
268 id: whiteBalanceController
270 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
282 value: ready ? settings.imageIso : 0
288 if (cam.mode == Camera.VideoMode) {
289 replacePage("VideoPage.qml");
292 replacePage("ImagePage.qml");