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: grid lines, face tracking, ambr
38 // TODO: complete settings pages
39 // TODO: stop camera properly when we get closed.
40 // TODO: select primary/secondary camera.
41 // TODO: disable debug builds.
42 // TODO: a way to get buffers to the application
43 // TODO: fcam like functionality (precise control over capture parameters).
48 property alias dimmer: camDimmer
52 Component.onCompleted: {
53 theme.inverted = true;
54 if (settings.mode == Camera.VideoMode) {
55 // TODO: We will use replacePage for now.
56 // If we use openPage() then we end up with 2 video pages
57 // stacked on top of each other.
58 // The first one is created when the camera mode gets
59 // changed to video upon startup and this becomes the 2nd one.
60 replacePage("VideoPage.qml");
63 replacePage("ImagePage.qml");
67 function showError(msg) {
73 // NOTE: The source will not reset the position when we lose the signal.
74 // This shouldn't be a big problem as we are course enough.
75 // If we ever need street level updates then this will be an issue.
77 active: settings.useGps
78 // TODO: we cannot bind to cam.running because camera will stop
79 // when the connection dialog pops up and we end up with an infinite loop
80 // active: cam.running && settings.useGps
81 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
87 manufacturer: deviceInfo.manufacturer
88 model: deviceInfo.model
89 country: geocode.country
91 suburb: geocode.suburb
92 longitude: positionSource.position.coordinate.longitude
93 longitudeValid: positionSource.position.longitudeValid && settings.useGps
94 latitude: positionSource.position.coordinate.latitude
95 latitudeValid: positionSource.position.latitudeValid && settings.useGps
96 elevation: positionSource.position.coordinate.altitude
97 elevationValid: positionSource.position.altitudeValid && settings.useGps
98 orientation: orientation.orientation
99 artist: settings.creatorName
100 captureDirection: compass.direction
101 captureDirectionValid: compass.directionValid
102 horizontalError: positionSource.position.horizontalAccuracy
103 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
104 dateTimeEnabled: true
119 active: cam.running && settings.useGps && settings.useGeotags
125 if (resourcePolicy.acquired) {
129 // TODO: We need a way to force a stop.
152 imageSuffix: cam.imageSuffix
153 videoSuffix: cam.videoSuffix
158 path: fileNaming.path
161 function replacePage(file) {
162 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
165 function openFile(file) {
166 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
169 platformStyle: PageStackWindowStyle {
177 function setImageResolution() {
178 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
179 showError(qsTr("Failed to set required resolution"));
185 imageSettings.setImageResolution();
194 function setVideoResolution() {
195 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
196 showError(qsTr("Failed to set required resolution"));
202 videoSettings.setVideoResolution();
210 onImageAspectRatioChanged: {
211 imageSettings.setImageResolution();
214 onImageResolutionChanged: {
215 imageSettings.setImageResolution();
218 onVideoResolutionChanged: {
219 videoSettings.setVideoResolution();
226 // TODO: is this needed ?
227 if (platformWindow.active) {
236 console.log("Camera error (" + code + "): " + message + " " + debug);
237 showError(qsTr("Camera error. Please restart the application."));
239 resourcePolicy.acquire(CameraResources.None);
240 mountProtector.unlock();
245 mountProtector.unlock();
249 // TODO: hardcoding device id
250 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
251 Component.onDestruction: {
252 console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
266 notifications: Sounds {
268 mute: !settings.soundEnabled
275 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
279 id: colorToneController
281 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
285 id: whiteBalanceController
287 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
299 value: ready ? settings.imageIso : 0
305 if (cam.mode == Camera.VideoMode) {
306 replacePage("VideoPage.qml");
309 replacePage("ImagePage.qml");