4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 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
27 // TODO: flash not ready (battery low or flash not ready message)
32 property bool deviceChangeInProgress: false
33 property bool inCaptureMode: mainView.currentIndex == 1
43 camera: viewfinder.camera
45 height: mainView.height
51 height: mainView.height
55 camera: viewfinder.camera
57 height: mainView.height
63 LayoutMirroring.enabled: false
65 orientation: ListView.Horizontal
67 snapMode: ListView.SnapOneItem
68 highlightRangeMode: ListView.StrictlyEnforceRange
69 boundsBehavior: Flickable.StopAtBounds
71 interactive: !currentItem.pressed
74 Component.onCompleted: {
75 platformSettings.init()
76 root.resetCamera(settings.device, settings.mode)
85 onDeviceAboutToChange: {
86 root.deviceChangeInProgress = true
90 viewfinder.cameraDeviceChanged()
92 // Reset pipeline manager error
93 pipelineManager.error = false
95 if (root.resetCamera(settings.device, settings.mode)) {
96 root.deviceChangeInProgress = false
97 pipelineManager.startCamera()
101 onImageAspectRatioChanged: {
102 if (!root.deviceChangeInProgress) {
103 imageSettings.setImageResolution()
107 onImageResolutionChanged: {
108 if (!root.deviceChangeInProgress) {
109 imageSettings.setImageResolution()
113 onVideoResolutionChanged: {
114 if (!root.deviceChangeInProgress) {
115 videoSettings.setVideoResolution()
119 onVideoAspectRatioChanged: {
120 if (!root.deviceChangeInProgress) {
121 videoSettings.setVideoResolution()
128 camera: viewfinder.camera
129 currentItem: mainView.currentItem
132 function resetCamera(deviceId, mode) {
133 if (!viewfinder.camera.reset(deviceId, mode)) {
134 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
138 if (mode == Camera.ImageMode) {
139 imageSettings.setImageResolution()
141 else if (mode == Camera.VideoMode) {
142 videoSettings.setVideoResolution()
148 function showError(msg) {
153 property alias dimmer: camDimmer
154 CameraPositionSource {
156 active: settings.useGps
157 // TODO: we cannot bind to cam.running because camera will stop
158 // when the connection dialog pops up and we end up with an infinite loop
159 // active: cam.running && settings.useGps
160 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
165 camera: viewfinder.camera
166 manufacturer: deviceInfo.manufacturer
167 model: deviceInfo.model
168 country: geocode.country
170 suburb: geocode.suburb
171 longitude: positionSource.longitude
172 longitudeValid: positionSource.longitudeValid && settings.useGps
173 latitude: positionSource.latitude
174 latitudeValid: positionSource.latitudeValid && settings.useGps
175 elevation: positionSource.altitude
176 elevationValid: positionSource.altitudeValid && settings.useGps
177 orientation: orientation.orientation
178 artist: settings.creatorName
179 captureDirection: compass.direction
180 captureDirectionValid: compass.directionValid
181 horizontalError: positionSource.horizontalAccuracy
182 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
183 dateTimeEnabled: true
188 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
193 active: viewfinder.camera.running
198 active: viewfinder.camera.running && settings.useGps && settings.useGeotags
215 imageSuffix: viewfinder.camera.imageSuffix
216 videoSuffix: viewfinder.camera.videoSuffix
217 imagePath: platformSettings.imagePath
218 videoPath: platformSettings.videoPath
219 temporaryVideoPath: platformSettings.temporaryVideoPath
229 active: viewfinder.camera.running
230 manufacturer: deviceInfo.manufacturer
231 model: deviceInfo.model
236 camera: viewfinder.camera
238 function setImageResolution() {
239 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
240 showError(qsTr("Failed to set required resolution"))
247 camera: viewfinder.camera
249 function setVideoResolution() {
250 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
251 showError(qsTr("Failed to set required resolution"))
258 cam: viewfinder.camera
263 property bool dimmed: false
267 opacity: dimmed ? 1.0 : 0.0
269 Behavior on opacity {
270 PropertyAnimation { duration: 150 }
276 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
277 repeat: !settings.zoomAsShutter
280 CameraProximitySensor {
282 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
287 policyLost: pipelineManager.state == "policyLost"
288 show: !Qt.application.active || pipelineManager.showStandBy ||
289 (inCaptureMode && !viewfinder.camera.running)