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)
34 property bool deviceChangeInProgress: false
35 property bool inCaptureMode: mainView.currentIndex == 1
36 property Item dimmer: camDimmer
46 camera: viewfinder.camera
48 height: mainView.height
54 height: mainView.height
58 camera: viewfinder.camera
60 height: mainView.height
66 LayoutMirroring.enabled: false
68 orientation: ListView.Horizontal
70 snapMode: ListView.SnapOneItem
71 highlightRangeMode: ListView.StrictlyEnforceRange
72 boundsBehavior: Flickable.StopAtBounds
74 interactive: !currentItem.pressed
77 Component.onCompleted: {
78 platformSettings.init()
79 root.resetCamera(settings.device, settings.mode)
88 onDeviceAboutToChange: {
89 root.deviceChangeInProgress = true
93 viewfinder.cameraDeviceChanged()
95 // Reset pipeline manager error
96 pipelineManager.error = false
98 if (root.resetCamera(settings.device, settings.mode)) {
99 root.deviceChangeInProgress = false
100 pipelineManager.startCamera()
104 onImageAspectRatioChanged: {
105 if (!root.deviceChangeInProgress) {
106 imageSettings.setImageResolution()
110 onImageResolutionChanged: {
111 if (!root.deviceChangeInProgress) {
112 imageSettings.setImageResolution()
116 onVideoResolutionChanged: {
117 if (!root.deviceChangeInProgress) {
118 videoSettings.setVideoResolution()
122 onVideoAspectRatioChanged: {
123 if (!root.deviceChangeInProgress) {
124 videoSettings.setVideoResolution()
131 camera: viewfinder.camera
132 currentItem: mainView.currentItem
135 function resetCamera(deviceId, mode) {
136 if (!viewfinder.camera.reset(deviceId, mode)) {
137 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
141 if (mode == Camera.ImageMode) {
142 imageSettings.setImageResolution()
144 else if (mode == Camera.VideoMode) {
145 videoSettings.setVideoResolution()
151 function showError(msg) {
162 inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
165 CameraPositionSource {
167 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
168 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
173 camera: viewfinder.camera
174 manufacturer: deviceInfo.manufacturer
175 model: deviceInfo.model
176 country: geocode.country
178 suburb: geocode.suburb
179 longitude: positionSource.longitude
180 longitudeValid: positionSource.longitudeValid && settings.useGps
181 latitude: positionSource.latitude
182 latitudeValid: positionSource.latitudeValid && settings.useGps
183 elevation: positionSource.altitude
184 elevationValid: positionSource.altitudeValid && settings.useGps
185 orientation: orientation.orientation
186 artist: settings.creatorName
187 captureDirection: compass.direction
188 captureDirectionValid: compass.directionValid
189 horizontalError: positionSource.horizontalAccuracy
190 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
191 dateTimeEnabled: true
196 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
201 active: viewfinder.camera.running
206 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
223 imageSuffix: viewfinder.camera.imageSuffix
224 videoSuffix: viewfinder.camera.videoSuffix
225 imagePath: platformSettings.imagePath
226 videoPath: platformSettings.videoPath
227 temporaryVideoPath: platformSettings.temporaryVideoPath
237 active: viewfinder.camera.running
238 manufacturer: deviceInfo.manufacturer
239 model: deviceInfo.model
244 camera: viewfinder.camera
246 function setImageResolution() {
247 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
248 showError(qsTr("Failed to set required resolution"))
255 camera: viewfinder.camera
257 function setVideoResolution() {
258 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
259 showError(qsTr("Failed to set required resolution"))
266 cam: viewfinder.camera
271 property bool dimmed: false
275 opacity: dimmed ? 1.0 : 0.0
277 Behavior on opacity {
278 PropertyAnimation { duration: 150 }
284 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
285 repeat: !settings.zoomAsShutter
290 running: proximitySensor.close
294 if (proximitySensor.close) {
295 proximitySensor.sensorClosed = true
300 CameraProximitySensor {
302 property bool sensorClosed: false
304 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
313 policyLost: pipelineManager.state == "policyLost"
314 show: !Qt.application.active || pipelineManager.showStandBy ||
315 (inCaptureMode && !viewfinder.camera.running)