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).
43 property alias dimmer: camDimmer
47 Component.onCompleted: {
48 theme.inverted = true;
49 // TODO: hardcoding device id
50 root.resetCamera(0, settings.mode);
53 function showError(msg) {
58 function resetCamera(deviceId, mode) {
59 if (!cam.reset(deviceId, mode)) {
60 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
65 // NOTE: The source will not reset the position when we lose the signal.
66 // This shouldn't be a big problem as we are course enough.
67 // If we ever need street level updates then this will be an issue.
69 active: settings.useGps
70 // TODO: we cannot bind to cam.running because camera will stop
71 // when the connection dialog pops up and we end up with an infinite loop
72 // active: cam.running && settings.useGps
73 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
79 manufacturer: deviceInfo.manufacturer
80 model: deviceInfo.model
81 country: geocode.country
83 suburb: geocode.suburb
84 longitude: positionSource.position.coordinate.longitude
85 longitudeValid: positionSource.position.longitudeValid && settings.useGps
86 latitude: positionSource.position.coordinate.latitude
87 latitudeValid: positionSource.position.latitudeValid && settings.useGps
88 elevation: positionSource.position.coordinate.altitude
89 elevationValid: positionSource.position.altitudeValid && settings.useGps
90 orientation: orientation.orientation
91 artist: settings.creatorName
92 captureDirection: compass.direction
93 captureDirectionValid: compass.directionValid
94 horizontalError: positionSource.position.horizontalAccuracy
95 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
111 active: cam.running && settings.useGps && settings.useGeotags
137 imageSuffix: cam.imageSuffix
138 videoSuffix: cam.videoSuffix
143 path: fileNaming.path
146 function replacePage(file) {
147 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
150 function openFile(file) {
151 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
154 function openFileNow(file) {
155 pageStack.push(Qt.resolvedUrl(file), {cam: cam}, true);
158 platformStyle: PageStackWindowStyle {
159 cornersVisible: false
161 backgroundColor: "transparent"
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();
220 visible: pageStack.currentPage && pageStack.currentPage.controlsVisible && pageStack.currentPage.focusReticleVisible && cam && cam.autoFocus.canFocus(cam.scene.value);
221 cafStatus: cam ? cam.autoFocus.cafStatus : -1
222 status: cam ? cam.autoFocus.status : -1
227 // TODO: is this needed ?
228 if (platformWindow.active) {
234 if (pipelineManager.error) {
235 // Ignore any subsequent errors.
236 // Killing pulseaudio while recording will lead to an
237 // infinite supply of errors which will break the UI
238 // if we show a banner for each.
242 pipelineManager.error = true;
243 pageStack.currentPage.cameraError();
244 console.log("Camera error (" + code + "): " + message + " " + debug);
245 showError(qsTr("Camera error. Please restart the application."));
247 // We cannot stop camera here. Seems there is a race condition somewhere
248 // which leads to a freeze if we do so.
253 mountProtector.unlock();
257 Component.onDestruction: cam.stop();
259 // We need to show viewfinder below pages.
270 notifications: Sounds {
272 mute: !settings.soundEnabled
280 when: cam.mode == Camera.ImageMode
281 value: settings.imageFlashMode
286 property: "imageFlashMode"
287 when: cam.mode == Camera.ImageMode
288 value: cam.flash.value
294 when: cam.mode == Camera.VideoMode
295 value: settings.videoSceneMode
301 when: cam.mode == Camera.ImageMode
302 value: settings.imageSceneMode
308 when: cam.mode == Camera.ImageMode
309 value: settings.imageEvComp
315 when: cam.mode == Camera.VideoMode
316 value: settings.videoEvComp
321 property: "imageEvComp"
322 when: cam.mode == Camera.ImageMode
323 value: cam.evComp.value
328 property: "videoEvComp"
329 when: cam.mode == Camera.VideoMode
330 value: cam.evComp.value
334 target: cam.whiteBalance
336 when: cam.mode == Camera.ImageMode
337 value: settings.imageWhiteBalance
341 target: cam.whiteBalance
343 when: cam.mode == Camera.VideoMode
344 value: settings.videoWhiteBalance
348 target: cam.colorTone
350 when: cam.mode == Camera.ImageMode
351 value: settings.imageColorFilter
355 target: cam.colorTone
357 when: cam.mode == Camera.VideoMode
358 value: settings.videoColorFilter
364 when: cam.mode == Camera.ImageMode
365 value: settings.imageIso
371 when: cam.mode == Camera.ImageMode
376 target: cam.videoMute
378 value: settings.videoMuted
384 manufacturer: deviceInfo.manufacturer
385 model: deviceInfo.model
397 if (cam.mode == Camera.VideoMode) {
398 replacePage("VideoPage.qml");
401 replacePage("ImagePage.qml");
407 policyLost: pipelineManager.state == "policyLost"
408 show: !pageStack.currentPage || (pageStack.currentPage.standbyVisible && pageStack.currentPage.status == PageStatus.Active && pipelineManager.showStandBy)