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, ambr
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
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 console.log("Camera error (" + code + "): " + message + " " + debug);
237 showError(qsTr("Camera error. Please restart the application."));
239 mountProtector.unlock();
244 mountProtector.unlock();
248 Component.onDestruction: cam.stop();
261 notifications: Sounds {
263 mute: !settings.soundEnabled
271 when: cam.mode == Camera.ImageMode
272 value: settings.imageFlashMode
277 property: "imageFlashMode"
278 when: cam.mode == Camera.ImageMode
279 value: cam.flash.value
285 when: cam.mode == Camera.VideoMode
286 value: settings.videoSceneMode
292 when: cam.mode == Camera.ImageMode
293 value: settings.imageSceneMode
299 when: cam.mode == Camera.ImageMode
300 value: settings.imageEvComp
306 when: cam.mode == Camera.VideoMode
307 value: settings.videoEvComp
312 property: "imageEvComp"
313 when: cam.mode == Camera.ImageMode
314 value: cam.evComp.value
319 property: "videoEvComp"
320 when: cam.mode == Camera.VideoMode
321 value: cam.evComp.value
325 target: cam.whiteBalance
327 when: cam.mode == Camera.ImageMode
328 value: settings.imageWhiteBalance
332 target: cam.whiteBalance
334 when: cam.mode == Camera.VideoMode
335 value: settings.videoWhiteBalance
339 target: cam.colorTone
341 when: cam.mode == Camera.ImageMode
342 value: settings.imageColorFilter
346 target: cam.colorTone
348 when: cam.mode == Camera.VideoMode
349 value: settings.videoColorFilter
355 when: cam.mode == Camera.ImageMode
356 value: settings.imageIso
362 when: cam.mode == Camera.ImageMode
369 manufacturer: deviceInfo.manufacturer
370 model: deviceInfo.model
382 if (cam.mode == Camera.VideoMode) {
383 replacePage("VideoPage.qml");
386 replacePage("ImagePage.qml");