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: stop viewfinder in settings pages ?
36 // TODO: grid lines, face tracking, ambr
37 // TODO: complete settings pages
38 // TODO: select primary/secondary camera.
39 // TODO: disable debug builds.
40 // TODO: a way to get buffers to the application
41 // TODO: fcam like functionality (precise control over capture parameters).
42 // TODO: changing scene mode doesn't affect the existing properties ?
43 // TODO: upon startup all properties don't load correct values.
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) {
72 function resetCamera(deviceId, mode) {
73 if (!cam.reset(deviceId, mode)) {
74 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
79 // NOTE: The source will not reset the position when we lose the signal.
80 // This shouldn't be a big problem as we are course enough.
81 // If we ever need street level updates then this will be an issue.
83 active: settings.useGps
84 // TODO: we cannot bind to cam.running because camera will stop
85 // when the connection dialog pops up and we end up with an infinite loop
86 // active: cam.running && settings.useGps
87 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
93 manufacturer: deviceInfo.manufacturer
94 model: deviceInfo.model
95 country: geocode.country
97 suburb: geocode.suburb
98 longitude: positionSource.position.coordinate.longitude
99 longitudeValid: positionSource.position.longitudeValid && settings.useGps
100 latitude: positionSource.position.coordinate.latitude
101 latitudeValid: positionSource.position.latitudeValid && settings.useGps
102 elevation: positionSource.position.coordinate.altitude
103 elevationValid: positionSource.position.altitudeValid && settings.useGps
104 orientation: orientation.orientation
105 artist: settings.creatorName
106 captureDirection: compass.direction
107 captureDirectionValid: compass.directionValid
108 horizontalError: positionSource.position.horizontalAccuracy
109 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
110 dateTimeEnabled: true
125 active: cam.running && settings.useGps && settings.useGeotags
150 imageSuffix: cam.imageSuffix
151 videoSuffix: cam.videoSuffix
156 path: fileNaming.path
159 function replacePage(file) {
160 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
163 function openFile(file) {
164 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
167 platformStyle: PageStackWindowStyle {
175 function setImageResolution() {
176 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
177 showError(qsTr("Failed to set required resolution"));
183 imageSettings.setImageResolution();
192 function setVideoResolution() {
193 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
194 showError(qsTr("Failed to set required resolution"));
200 videoSettings.setVideoResolution();
208 onImageAspectRatioChanged: {
209 imageSettings.setImageResolution();
212 onImageResolutionChanged: {
213 imageSettings.setImageResolution();
216 onVideoResolutionChanged: {
217 videoSettings.setVideoResolution();
224 // TODO: is this needed ?
225 if (platformWindow.active) {
234 console.log("Camera error (" + code + "): " + message + " " + debug);
235 showError(qsTr("Camera error. Please restart the application."));
237 resourcePolicy.acquire(CameraResources.None);
238 mountProtector.unlock();
243 mountProtector.unlock();
247 // TODO: hardcoding device id
248 Component.onCompleted: { root.resetCamera(0, settings.mode); }
249 Component.onDestruction: cam.stop();
262 notifications: Sounds {
264 mute: !settings.soundEnabled
271 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
272 onValueChanged: console.log("New scene value " + value);
276 id: colorToneController
278 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
282 id: whiteBalanceController
284 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
296 value: ready ? settings.imageIso : 0
302 if (cam.mode == Camera.VideoMode) {
303 replacePage("VideoPage.qml");
306 replacePage("ImagePage.qml");