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 (battery low or flash not ready message)
33 // TODO: portrait/landscape
34 // TODO: grid lines, face tracking
35 // TODO: select primary/secondary camera.
36 // TODO: disable debug builds.
37 // TODO: a way to get buffers to the application
38 // TODO: fcam like functionality (precise control over capture parameters).
39 // TODO: mute video sound
44 property alias dimmer: camDimmer
48 Component.onCompleted: {
49 theme.inverted = true;
50 // TODO: hardcoding device id
51 root.resetCamera(0, settings.mode);
54 function showError(msg) {
59 function resetCamera(deviceId, mode) {
60 if (!cam.reset(deviceId, mode)) {
61 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
66 // NOTE: The source will not reset the position when we lose the signal.
67 // This shouldn't be a big problem as we are course enough.
68 // If we ever need street level updates then this will be an issue.
70 active: settings.useGps
71 // TODO: we cannot bind to cam.running because camera will stop
72 // when the connection dialog pops up and we end up with an infinite loop
73 // active: cam.running && settings.useGps
74 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
80 manufacturer: deviceInfo.manufacturer
81 model: deviceInfo.model
82 country: geocode.country
84 suburb: geocode.suburb
85 longitude: positionSource.position.coordinate.longitude
86 longitudeValid: positionSource.position.longitudeValid && settings.useGps
87 latitude: positionSource.position.coordinate.latitude
88 latitudeValid: positionSource.position.latitudeValid && settings.useGps
89 elevation: positionSource.position.coordinate.altitude
90 elevationValid: positionSource.position.altitudeValid && settings.useGps
91 orientation: orientation.orientation
92 artist: settings.creatorName
93 captureDirection: compass.direction
94 captureDirectionValid: compass.directionValid
95 horizontalError: positionSource.position.horizontalAccuracy
96 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
112 active: cam.running && settings.useGps && settings.useGeotags
138 imageSuffix: cam.imageSuffix
139 videoSuffix: cam.videoSuffix
144 path: fileNaming.path
147 function replacePage(file) {
148 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
151 function openFile(file) {
152 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
155 function openFileNow(file) {
156 pageStack.push(Qt.resolvedUrl(file), {cam: cam}, true);
159 platformStyle: PageStackWindowStyle {
160 cornersVisible: false
162 backgroundColor: "transparent"
168 function setImageResolution() {
169 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
170 showError(qsTr("Failed to set required resolution"));
176 imageSettings.setImageResolution();
185 function setVideoResolution() {
186 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
187 showError(qsTr("Failed to set required resolution"));
193 videoSettings.setVideoResolution();
201 onImageAspectRatioChanged: {
202 imageSettings.setImageResolution();
205 onImageResolutionChanged: {
206 imageSettings.setImageResolution();
209 onVideoResolutionChanged: {
210 videoSettings.setVideoResolution();
221 visible: pageStack.currentPage && pageStack.currentPage.controlsVisible && pageStack.currentPage.focusReticleVisible && cam && cam.autoFocus.canFocus(cam.scene.value);
222 cafStatus: cam ? cam.autoFocus.cafStatus : -1
223 status: cam ? cam.autoFocus.status : -1
228 // TODO: is this needed ?
229 if (platformWindow.active) {
235 if (pipelineManager.error) {
236 // Ignore any subsequent errors.
237 // Killing pulseaudio while recording will lead to an
238 // infinite supply of errors which will break the UI
239 // if we show a banner for each.
243 pipelineManager.error = true;
244 pageStack.currentPage.cameraError();
245 console.log("Camera error (" + code + "): " + message + " " + debug);
246 showError(qsTr("Camera error. Please restart the application."));
248 // We cannot stop camera here. Seems there is a race condition somewhere
249 // which leads to a freeze if we do so.
254 mountProtector.unlock();
258 Component.onDestruction: cam.stop();
260 // We need to show viewfinder below pages.
271 notifications: Sounds {
273 mute: !settings.soundEnabled
281 when: cam.mode == Camera.ImageMode
282 value: settings.imageFlashMode
287 property: "imageFlashMode"
288 when: cam.mode == Camera.ImageMode
289 value: cam.flash.value
295 when: cam.mode == Camera.VideoMode
296 value: settings.videoSceneMode
302 when: cam.mode == Camera.ImageMode
303 value: settings.imageSceneMode
309 when: cam.mode == Camera.ImageMode
310 value: settings.imageEvComp
316 when: cam.mode == Camera.VideoMode
317 value: settings.videoEvComp
322 property: "imageEvComp"
323 when: cam.mode == Camera.ImageMode
324 value: cam.evComp.value
329 property: "videoEvComp"
330 when: cam.mode == Camera.VideoMode
331 value: cam.evComp.value
335 target: cam.whiteBalance
337 when: cam.mode == Camera.ImageMode
338 value: settings.imageWhiteBalance
342 target: cam.whiteBalance
344 when: cam.mode == Camera.VideoMode
345 value: settings.videoWhiteBalance
349 target: cam.colorTone
351 when: cam.mode == Camera.ImageMode
352 value: settings.imageColorFilter
356 target: cam.colorTone
358 when: cam.mode == Camera.VideoMode
359 value: settings.videoColorFilter
365 when: cam.mode == Camera.ImageMode
366 value: settings.imageIso
372 when: cam.mode == Camera.ImageMode
379 manufacturer: deviceInfo.manufacturer
380 model: deviceInfo.model
392 if (cam.mode == Camera.VideoMode) {
393 replacePage("VideoPage.qml");
396 replacePage("ImagePage.qml");