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
261 if (pipelineManager.error) {
262 // Ignore any subsequent errors.
263 // Killing pulseaudio while recording will lead to an
264 // infinite supply of errors which will break the UI
265 // if we show a banner for each.
269 pipelineManager.error = true;
270 pageStack.currentPage.cameraError();
271 console.log("Camera error (" + code + "): " + message + " " + debug);
272 showError(qsTr("Camera error. Please restart the application."));
274 // We cannot stop camera here. Seems there is a race condition somewhere
275 // which leads to a freeze if we do so.
280 mountProtector.unlock();
284 Component.onDestruction: cam.stop();
286 // We need to show viewfinder below pages.
290 property bool dimmed: false
294 opacity: dimmed ? 1.0 : 0.0
296 Behavior on opacity {
297 PropertyAnimation { duration: 150 }
301 notifications: Sounds {
303 mute: !settings.soundEnabled
311 when: cam.mode == Camera.ImageMode
312 value: settings.imageFlashMode
317 property: "imageFlashMode"
318 when: cam.mode == Camera.ImageMode
319 value: cam.flash.value
325 when: cam.mode == Camera.VideoMode
326 value: settings.videoSceneMode
332 when: cam.mode == Camera.ImageMode
333 value: settings.imageSceneMode
339 when: cam.mode == Camera.ImageMode
340 value: settings.imageEvComp
346 when: cam.mode == Camera.VideoMode
347 value: settings.videoEvComp
352 property: "imageEvComp"
353 when: cam.mode == Camera.ImageMode
354 value: cam.evComp.value
359 property: "videoEvComp"
360 when: cam.mode == Camera.VideoMode
361 value: cam.evComp.value
365 target: cam.whiteBalance
367 when: cam.mode == Camera.ImageMode
368 value: settings.imageWhiteBalance
372 target: cam.whiteBalance
374 when: cam.mode == Camera.VideoMode
375 value: settings.videoWhiteBalance
379 target: cam.colorTone
381 when: cam.mode == Camera.ImageMode
382 value: settings.imageColorFilter
386 target: cam.colorTone
388 when: cam.mode == Camera.VideoMode
389 value: settings.videoColorFilter
395 when: cam.mode == Camera.ImageMode
396 value: settings.imageIso
402 when: cam.mode == Camera.ImageMode
407 target: cam.videoMute
409 value: settings.videoMuted
415 manufacturer: deviceInfo.manufacturer
416 model: deviceInfo.model
428 if (cam.mode == Camera.VideoMode) {
429 replacePage("VideoPage.qml");
432 replacePage("ImagePage.qml");
438 policyLost: pipelineManager.state == "policyLost"
439 show: !pageStack.currentPage || (pageStack.currentPage.standbyVisible && pageStack.currentPage.status == PageStatus.Active && pipelineManager.showStandBy)
444 active: Qt.application.active && pipelineManager.scaleAcquired