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 == Camera.VideoMode) {
56 // TODO: We will use replacePage for now.
57 // If we use openPage() then we end up with 2 video pages
58 // stacked on top of each other.
59 // The first one is created when the camera mode gets
60 // changed to video upon startup and this becomes the 2nd one.
61 replacePage("VideoPage.qml");
64 replacePage("ImagePage.qml");
68 function showError(msg) {
74 // NOTE: The source will not reset the position when we lose the signal.
75 // This shouldn't be a big problem as we are course enough.
76 // If we ever need street level updates then this will be an issue.
78 active: settings.useGps
79 // TODO: we cannot bind to cam.running because camera will stop
80 // when the connection dialog pops up and we end up with an infinite loop
81 // active: cam.running && settings.useGps
82 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
88 manufacturer: deviceInfo.manufacturer
89 model: deviceInfo.model
90 country: geocode.country
92 suburb: geocode.suburb
93 longitude: positionSource.position.coordinate.longitude
94 longitudeValid: positionSource.position.longitudeValid && settings.useGps
95 latitude: positionSource.position.coordinate.latitude
96 latitudeValid: positionSource.position.latitudeValid && settings.useGps
97 elevation: positionSource.position.coordinate.altitude
98 elevationValid: positionSource.position.altitudeValid && settings.useGps
99 orientation: orientation.orientation
100 artist: settings.creatorName
101 captureDirection: compass.direction
102 captureDirectionValid: compass.directionValid
103 horizontalError: positionSource.position.horizontalAccuracy
104 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
105 dateTimeEnabled: true
120 active: cam.running && settings.useGps && settings.useGeotags
126 if (resourcePolicy.acquired) {
130 // TODO: We need a way to force a stop.
153 imageSuffix: cam.imageSuffix
154 videoSuffix: cam.videoSuffix
157 function replacePage(file) {
158 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
161 function openFile(file) {
162 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
165 platformStyle: PageStackWindowStyle {
173 function setImageResolution() {
174 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
175 showError(qsTr("Failed to set required resolution"));
181 imageSettings.setImageResolution();
190 function setVideoResolution() {
191 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
192 showError(qsTr("Failed to set required resolution"));
198 videoSettings.setVideoResolution();
206 onImageAspectRatioChanged: {
207 imageSettings.setImageResolution();
210 onImageResolutionChanged: {
211 imageSettings.setImageResolution();
214 onVideoResolutionChanged: {
215 videoSettings.setVideoResolution();
222 // TODO: is this needed ?
223 if (platformWindow.active) {
232 console.log("Camera error (" + code + "): " + message + " " + debug);
233 showError(qsTr("Camera error. Please restart the application."));
235 resourcePolicy.acquire(CameraResources.None);
238 // TODO: hardcoding device id
239 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
240 Component.onDestruction: {
241 console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
255 notifications: Sounds {
257 mute: !settings.soundEnabled
264 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
268 id: colorToneController
270 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
274 id: whiteBalanceController
276 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
288 value: ready ? settings.imageIso : 0
294 if (cam.mode == Camera.VideoMode) {
295 replacePage("VideoPage.qml");
298 replacePage("ImagePage.qml");