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.location 1.2
30 // TODO: flash not ready (battery low or flash not ready message)
31 // TODO: face tracking
32 // TODO: disable debug builds.
37 property alias dimmer: camDimmer
41 Component.onCompleted: {
42 theme.inverted = true;
43 // TODO: hardcoding device id
44 root.resetCamera(0, settings.mode);
47 function showError(msg) {
52 function resetCamera(deviceId, mode) {
53 if (!cam.reset(deviceId, mode)) {
54 showError(qsTr("Failed to set camera device and mode. Please restart the application."));
59 // NOTE: The source will not reset the position when we lose the signal.
60 // This shouldn't be a big problem as we are course enough.
61 // If we ever need street level updates then this will be an issue.
63 active: settings.useGps
64 // TODO: we cannot bind to cam.running because camera will stop
65 // when the connection dialog pops up and we end up with an infinite loop
66 // active: cam.running && settings.useGps
67 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude);
73 manufacturer: deviceInfo.manufacturer
74 model: deviceInfo.model
75 country: geocode.country
77 suburb: geocode.suburb
78 longitude: positionSource.position.coordinate.longitude
79 longitudeValid: positionSource.position.longitudeValid && settings.useGps
80 latitude: positionSource.position.coordinate.latitude
81 latitudeValid: positionSource.position.latitudeValid && settings.useGps
82 elevation: positionSource.position.coordinate.altitude
83 elevationValid: positionSource.position.altitudeValid && settings.useGps
84 orientation: orientation.orientation
85 artist: settings.creatorName
86 captureDirection: compass.direction
87 captureDirectionValid: compass.directionValid
88 horizontalError: positionSource.position.horizontalAccuracy
89 horizontalErrorValid: positionSource.position.horizontalAccuracyValid && settings.useGps
105 active: cam.running && settings.useGps && settings.useGeotags
131 imageSuffix: cam.imageSuffix
132 videoSuffix: cam.videoSuffix
137 path: fileNaming.path
145 if (!checkBattery()) {
146 pageStack.currentPage.batteryLow();
151 batteryMonitor.check();
155 batteryMonitor.check();
159 function replacePage(file) {
160 pageStack.replace(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer}, true);
163 function openFile(file) {
164 pageStack.push(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer});
167 function openFileNow(file) {
168 pageStack.push(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer}, true);
171 function checkBattery() {
172 // We are fine if we are connected to the charger:
173 if (batteryMonitor.charging) {
177 // If we have enough battery then we are fine:
178 if (!batteryMonitor.critical) {
185 platformStyle: PageStackWindowStyle {
186 cornersVisible: false
188 backgroundColor: "transparent"
194 function setImageResolution() {
195 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
196 showError(qsTr("Failed to set required resolution"));
202 imageSettings.setImageResolution();
211 function setVideoResolution() {
212 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
213 showError(qsTr("Failed to set required resolution"));
219 videoSettings.setVideoResolution();
227 onImageAspectRatioChanged: {
228 imageSettings.setImageResolution();
231 onImageResolutionChanged: {
232 imageSettings.setImageResolution();
235 onVideoResolutionChanged: {
236 videoSettings.setVideoResolution();
247 width: cam.renderArea.width
248 height: cam.renderArea.height
249 visible: settings.gridEnabled
255 visible: pageStack.currentPage && pageStack.currentPage.controlsVisible && pageStack.currentPage.focusReticleVisible && cam && cam.autoFocus.canFocus(cam.scene.value);
256 cafStatus: cam ? cam.autoFocus.cafStatus : -1
257 status: cam ? cam.autoFocus.status : -1
262 // TODO: is this needed ?
263 if (platformWindow.active) {
269 if (pipelineManager.error) {
270 // Ignore any subsequent errors.
271 // Killing pulseaudio while recording will lead to an
272 // infinite supply of errors which will break the UI
273 // if we show a banner for each.
277 pipelineManager.error = true;
278 pageStack.currentPage.cameraError();
279 console.log("Camera error (" + code + "): " + message + " " + debug);
280 showError(qsTr("Camera error. Please restart the application."));
282 // We cannot stop camera here. Seems there is a race condition somewhere
283 // which leads to a freeze if we do so.
288 mountProtector.unlock();
292 Component.onDestruction: cam.stop();
294 // We need to show viewfinder below pages.
298 property bool dimmed: false
302 opacity: dimmed ? 1.0 : 0.0
304 Behavior on opacity {
305 PropertyAnimation { duration: 150 }
309 notifications: Sounds {
311 mute: !settings.soundEnabled
319 when: cam.mode == Camera.ImageMode
320 value: settings.imageFlashMode
325 property: "imageFlashMode"
326 when: cam.mode == Camera.ImageMode
327 value: cam.flash.value
333 when: cam.mode == Camera.VideoMode
334 value: settings.videoSceneMode
340 when: cam.mode == Camera.ImageMode
341 value: settings.imageSceneMode
347 when: cam.mode == Camera.ImageMode
348 value: settings.imageEvComp
354 when: cam.mode == Camera.VideoMode
355 value: settings.videoEvComp
360 property: "imageEvComp"
361 when: cam.mode == Camera.ImageMode
362 value: cam.evComp.value
367 property: "videoEvComp"
368 when: cam.mode == Camera.VideoMode
369 value: cam.evComp.value
373 target: cam.whiteBalance
375 when: cam.mode == Camera.ImageMode
376 value: settings.imageWhiteBalance
380 target: cam.whiteBalance
382 when: cam.mode == Camera.VideoMode
383 value: settings.videoWhiteBalance
387 target: cam.colorTone
389 when: cam.mode == Camera.ImageMode
390 value: settings.imageColorFilter
394 target: cam.colorTone
396 when: cam.mode == Camera.VideoMode
397 value: settings.videoColorFilter
403 when: cam.mode == Camera.ImageMode
404 value: settings.imageIso
410 when: cam.mode == Camera.ImageMode
415 target: cam.videoMute
417 value: settings.videoMuted
423 manufacturer: deviceInfo.manufacturer
424 model: deviceInfo.model
436 if (cam.mode == Camera.VideoMode) {
437 replacePage("VideoPage.qml");
440 replacePage("ImagePage.qml");
446 policyLost: pipelineManager.state == "policyLost"
447 show: !pageStack.currentPage || (pageStack.currentPage.standbyVisible && pageStack.currentPage.status == PageStatus.Active && pipelineManager.showStandBy)