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: battery low state
34 // TODO: flash not ready
35 // TODO: focus, caf, ...
36 // TODO: portrait/landscape
37 // TODO: record video in a hidden directory and then copy the video to avoid tracker indexing it.
38 // TODO: stop viewfinder in settings pages ?
39 // TODO: prevent going to mass storage while recording and capturing
40 // TODO: grid lines, face tracking, ambr
41 // TODO: complete settings pages
42 // TODO: stop camera properly when we get closed.
43 // TODO: select primary/secondary camera.
44 // TODO: disable debug builds.
45 // TODO: a way to get buffers to the application
46 // TODO: fcam like functionality (precise control over capture parameters).
51 property alias dimmer: camDimmer
55 Component.onCompleted: {
56 theme.inverted = true;
57 if (settings.mode == 0) {
58 openFile("ImagePage.qml");
61 openFile("VideoPage.qml");
65 function showError(msg) {
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
120 if (resourcePolicy.acquired) {
124 // TODO: We need a way to force a stop.
147 imageSuffix: cam.imageSuffix
148 videoSuffix: cam.videoSuffix
151 function replacePage(file) {
152 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
155 function openFile(file) {
156 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
159 platformStyle: PageStackWindowStyle {
167 function setImageResolution() {
168 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
169 showError(qsTr("Failed to set required resolution"));
175 imageSettings.setImageResolution();
184 function setVideoResolution() {
185 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
186 showError(qsTr("Failed to set required resolution"));
192 videoSettings.setVideoResolution();
200 onImageAspectRatioChanged: {
201 imageSettings.setImageResolution();
204 onImageResolutionChanged: {
205 imageSettings.setImageResolution();
208 onVideoResolutionChanged: {
209 videoSettings.setVideoResolution();
216 // TODO: is this needed ?
217 if (platformWindow.active) {
226 console.log("Camera error (" + code + "): " + message + " " + debug);
227 showError(qsTr("Camera error. Please restart the application."));
231 // TODO: hardcoding device id
232 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
233 Component.onDestruction: {
234 console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
248 notifications: Sounds {
256 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
260 id: colorToneController
262 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
266 id: whiteBalanceController
268 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
280 value: ready ? settings.imageIso : 0
286 if (cam.mode == Camera.VideoMode) {
287 replacePage("VideoPage.qml");
290 replacePage("ImagePage.qml");