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: stop viewfinder in settings pages ?
35 // TODO: grid lines, face tracking
36 // TODO: select primary/secondary camera.
37 // TODO: disable debug builds.
38 // TODO: a way to get buffers to the application
39 // TODO: fcam like functionality (precise control over capture parameters).
40 // TODO: mute video sound
45 property alias dimmer: camDimmer
49 Component.onCompleted: {
50 theme.inverted = true;
51 // TODO: hardcoding device id
52 root.resetCamera(0, settings.mode);
55 function showError(msg) {
60 function resetCamera(deviceId, mode) {
61 if (!cam.reset(deviceId, mode)) {
62 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
67 // NOTE: The source will not reset the position when we lose the signal.
68 // This shouldn't be a big problem as we are course enough.
69 // If we ever need street level updates then this will be an issue.
71 active: settings.useGps
72 // TODO: we cannot bind to cam.running because camera will stop
73 // when the connection dialog pops up and we end up with an infinite loop
74 // active: cam.running && settings.useGps
75 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
81 manufacturer: deviceInfo.manufacturer
82 model: deviceInfo.model
83 country: geocode.country
85 suburb: geocode.suburb
86 longitude: positionSource.position.coordinate.longitude
87 longitudeValid: positionSource.position.longitudeValid && settings.useGps
88 latitude: positionSource.position.coordinate.latitude
89 latitudeValid: positionSource.position.latitudeValid && settings.useGps
90 elevation: positionSource.position.coordinate.altitude
91 elevationValid: positionSource.position.altitudeValid && settings.useGps
92 orientation: orientation.orientation
93 artist: settings.creatorName
94 captureDirection: compass.direction
95 captureDirectionValid: compass.directionValid
96 horizontalError: positionSource.position.horizontalAccuracy
97 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
113 active: cam.running && settings.useGps && settings.useGeotags
139 imageSuffix: cam.imageSuffix
140 videoSuffix: cam.videoSuffix
145 path: fileNaming.path
148 function replacePage(file) {
149 pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
152 function openFile(file) {
153 pageStack.push(Qt.resolvedUrl(file), {cam: cam});
156 function openFileNow(file) {
157 pageStack.push(Qt.resolvedUrl(file), {cam: cam}, true);
160 platformStyle: PageStackWindowStyle {
161 cornersVisible: false
163 backgroundColor: "transparent"
169 function setImageResolution() {
170 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
171 showError(qsTr("Failed to set required resolution"));
177 imageSettings.setImageResolution();
186 function setVideoResolution() {
187 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
188 showError(qsTr("Failed to set required resolution"));
194 videoSettings.setVideoResolution();
202 onImageAspectRatioChanged: {
203 imageSettings.setImageResolution();
206 onImageResolutionChanged: {
207 imageSettings.setImageResolution();
210 onVideoResolutionChanged: {
211 videoSettings.setVideoResolution();
222 visible: pageStack.currentPage && pageStack.currentPage.controlsVisible && pageStack.currentPage.focusReticleVisible && cam && cam.autoFocus.canFocus(cam.scene.value);
223 cafStatus: cam ? cam.autoFocus.cafStatus : -1
224 status: cam ? cam.autoFocus.status : -1
229 // TODO: is this needed ?
230 if (platformWindow.active) {
236 if (pipelineManager.error) {
237 // Ignore any subsequent errors.
238 // Killing pulseaudio while recording will lead to an
239 // infinite supply of errors which will break the UI
240 // if we show a banner for each.
244 pipelineManager.error = true;
245 pageStack.currentPage.cameraError();
246 console.log("Camera error (" + code + "): " + message + " " + debug);
247 showError(qsTr("Camera error. Please restart the application."));
249 // We cannot stop camera here. Seems there is a race condition somewhere
250 // which leads to a freeze if we do so.
255 mountProtector.unlock();
259 Component.onDestruction: cam.stop();
261 // We need to show viewfinder below pages.
272 notifications: Sounds {
274 mute: !settings.soundEnabled
282 when: cam.mode == Camera.ImageMode
283 value: settings.imageFlashMode
288 property: "imageFlashMode"
289 when: cam.mode == Camera.ImageMode
290 value: cam.flash.value
296 when: cam.mode == Camera.VideoMode
297 value: settings.videoSceneMode
303 when: cam.mode == Camera.ImageMode
304 value: settings.imageSceneMode
310 when: cam.mode == Camera.ImageMode
311 value: settings.imageEvComp
317 when: cam.mode == Camera.VideoMode
318 value: settings.videoEvComp
323 property: "imageEvComp"
324 when: cam.mode == Camera.ImageMode
325 value: cam.evComp.value
330 property: "videoEvComp"
331 when: cam.mode == Camera.VideoMode
332 value: cam.evComp.value
336 target: cam.whiteBalance
338 when: cam.mode == Camera.ImageMode
339 value: settings.imageWhiteBalance
343 target: cam.whiteBalance
345 when: cam.mode == Camera.VideoMode
346 value: settings.videoWhiteBalance
350 target: cam.colorTone
352 when: cam.mode == Camera.ImageMode
353 value: settings.imageColorFilter
357 target: cam.colorTone
359 when: cam.mode == Camera.VideoMode
360 value: settings.videoColorFilter
366 when: cam.mode == Camera.ImageMode
367 value: settings.imageIso
373 when: cam.mode == Camera.ImageMode
380 manufacturer: deviceInfo.manufacturer
381 model: deviceInfo.model
393 if (cam.mode == Camera.VideoMode) {
394 replacePage("VideoPage.qml");
397 replacePage("ImagePage.qml");