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 // TODO: seems we freeze here somehow
237 console.log("Camera error (" + code + "): " + message + " " + debug);
238 showError(qsTr("Camera error. Please restart the application."));
240 mountProtector.unlock();
245 mountProtector.unlock();
249 Component.onDestruction: cam.stop();
251 // We need to show viewfinder below pages.
262 notifications: Sounds {
264 mute: !settings.soundEnabled
272 when: cam.mode == Camera.ImageMode
273 value: settings.imageFlashMode
278 property: "imageFlashMode"
279 when: cam.mode == Camera.ImageMode
280 value: cam.flash.value
286 when: cam.mode == Camera.VideoMode
287 value: settings.videoSceneMode
293 when: cam.mode == Camera.ImageMode
294 value: settings.imageSceneMode
300 when: cam.mode == Camera.ImageMode
301 value: settings.imageEvComp
307 when: cam.mode == Camera.VideoMode
308 value: settings.videoEvComp
313 property: "imageEvComp"
314 when: cam.mode == Camera.ImageMode
315 value: cam.evComp.value
320 property: "videoEvComp"
321 when: cam.mode == Camera.VideoMode
322 value: cam.evComp.value
326 target: cam.whiteBalance
328 when: cam.mode == Camera.ImageMode
329 value: settings.imageWhiteBalance
333 target: cam.whiteBalance
335 when: cam.mode == Camera.VideoMode
336 value: settings.videoWhiteBalance
340 target: cam.colorTone
342 when: cam.mode == Camera.ImageMode
343 value: settings.imageColorFilter
347 target: cam.colorTone
349 when: cam.mode == Camera.VideoMode
350 value: settings.videoColorFilter
356 when: cam.mode == Camera.ImageMode
357 value: settings.imageIso
363 when: cam.mode == Camera.ImageMode
370 manufacturer: deviceInfo.manufacturer
371 model: deviceInfo.model
383 if (cam.mode == Camera.VideoMode) {
384 replacePage("VideoPage.qml");
387 replacePage("ImagePage.qml");