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) {
71 // NOTE: The source will not reset the position when we lose the signal.
72 // This shouldn't be a big problem as we are course enough.
73 // If we ever need street level updates then this will be an issue.
75 active: settings.useGps
76 // TODO: we cannot bind to cam.running because camera will stop
77 // when the connection dialog pops up and we end up with an infinite loop
78 // active: cam.running && settings.useGps
79 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
85 manufacturer: deviceInfo.manufacturer
86 model: deviceInfo.model
87 country: geocode.country
89 suburb: geocode.suburb
90 longitude: positionSource.position.coordinate.longitude
91 longitudeValid: positionSource.position.longitudeValid && settings.useGps
92 latitude: positionSource.position.coordinate.latitude
93 latitudeValid: positionSource.position.latitudeValid && settings.useGps
94 elevation: positionSource.position.coordinate.altitude
95 elevationValid: positionSource.position.altitudeValid && settings.useGps
96 orientation: orientation.orientation
97 artist: settings.creatorName
98 captureDirection: compass.direction
99 captureDirectionValid: compass.directionValid
100 horizontalError: positionSource.position.horizontalAccuracy
101 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
102 dateTimeEnabled: true
117 active: cam.running && settings.useGps && settings.useGeotags
123 if (resourcePolicy.acquired) {
127 // TODO: We need a way to force a stop.
150 imageSuffix: cam.imageSuffix
151 videoSuffix: cam.videoSuffix
154 function replacePage(file) {
155 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
158 function openFile(file) {
159 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
162 platformStyle: PageStackWindowStyle {
170 function setImageResolution() {
171 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
172 showError(qsTr("Failed to set required resolution"));
178 imageSettings.setImageResolution();
187 function setVideoResolution() {
188 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
189 showError(qsTr("Failed to set required resolution"));
195 videoSettings.setVideoResolution();
203 onImageAspectRatioChanged: {
204 imageSettings.setImageResolution();
207 onImageResolutionChanged: {
208 imageSettings.setImageResolution();
211 onVideoResolutionChanged: {
212 videoSettings.setVideoResolution();
219 // TODO: is this needed ?
220 if (platformWindow.active) {
229 console.log("Camera error (" + code + "): " + message + " " + debug);
230 showError(qsTr("Camera error. Please restart the application."));
234 // TODO: hardcoding device id
235 Component.onCompleted: { cam.deviceId = 0; mode = settings.mode; }
236 Component.onDestruction: {
237 console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
251 notifications: Sounds {
253 mute: !settings.soundEnabled
260 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
264 id: colorToneController
266 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
270 id: whiteBalanceController
272 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
284 value: ready ? settings.imageIso : 0
290 if (cam.mode == Camera.VideoMode) {
291 replacePage("VideoPage.qml");
294 replacePage("ImagePage.qml");