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 // TODO: hardcoding device id
55 root.resetCamera(0, settings.mode);
58 function showError(msg) {
63 function resetCamera(deviceId, mode) {
64 if (!cam.reset(deviceId, mode)) {
65 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
70 // NOTE: The source will not reset the position when we lose the signal.
71 // This shouldn't be a big problem as we are course enough.
72 // If we ever need street level updates then this will be an issue.
74 active: settings.useGps
75 // TODO: we cannot bind to cam.running because camera will stop
76 // when the connection dialog pops up and we end up with an infinite loop
77 // active: cam.running && settings.useGps
78 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
84 manufacturer: deviceInfo.manufacturer
85 model: deviceInfo.model
86 country: geocode.country
88 suburb: geocode.suburb
89 longitude: positionSource.position.coordinate.longitude
90 longitudeValid: positionSource.position.longitudeValid && settings.useGps
91 latitude: positionSource.position.coordinate.latitude
92 latitudeValid: positionSource.position.latitudeValid && settings.useGps
93 elevation: positionSource.position.coordinate.altitude
94 elevationValid: positionSource.position.altitudeValid && settings.useGps
95 orientation: orientation.orientation
96 artist: settings.creatorName
97 captureDirection: compass.direction
98 captureDirectionValid: compass.directionValid
99 horizontalError: positionSource.position.horizontalAccuracy
100 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
101 dateTimeEnabled: true
116 active: cam.running && settings.useGps && settings.useGeotags
141 imageSuffix: cam.imageSuffix
142 videoSuffix: cam.videoSuffix
147 path: fileNaming.path
150 function replacePage(file) {
151 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
154 function openFile(file) {
155 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
158 platformStyle: PageStackWindowStyle {
166 function setImageResolution() {
167 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
168 showError(qsTr("Failed to set required resolution"));
174 imageSettings.setImageResolution();
183 function setVideoResolution() {
184 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
185 showError(qsTr("Failed to set required resolution"));
191 videoSettings.setVideoResolution();
199 onImageAspectRatioChanged: {
200 imageSettings.setImageResolution();
203 onImageResolutionChanged: {
204 imageSettings.setImageResolution();
207 onVideoResolutionChanged: {
208 videoSettings.setVideoResolution();
215 // TODO: is this needed ?
216 if (platformWindow.active) {
225 console.log("Camera error (" + code + "): " + message + " " + debug);
226 showError(qsTr("Camera error. Please restart the application."));
228 resourcePolicy.acquire(CameraResources.None);
229 mountProtector.unlock();
234 mountProtector.unlock();
238 Component.onDestruction: cam.stop();
251 notifications: Sounds {
253 mute: !settings.soundEnabled
260 value: ready ? camera.mode == Camera.VideoMode ? settings.videoSceneMode : settings.imageSceneMode : 0
261 onValueChanged: console.log("New scene value " + value);
265 id: colorToneController
267 value: ready ? camera.mode == Camera.VideoMode ? settings.videoColorFilter : settings.imageColorFilter : 0
271 id: whiteBalanceController
273 value: ready ? camera.mode == Camera.VideoMode ? settings.videoWhiteBalance : settings.imageWhiteBalance : 0
285 value: ready ? settings.imageIso : 0
291 if (cam.mode == Camera.VideoMode) {
292 replacePage("VideoPage.qml");
295 replacePage("ImagePage.qml");