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
161 inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
164 CameraPositionSource {
166 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
167 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
172 camera: viewfinder.camera
173 manufacturer: deviceInfo.manufacturer
174 model: deviceInfo.model
175 country: geocode.country
177 suburb: geocode.suburb
178 longitude: positionSource.longitude
179 longitudeValid: positionSource.longitudeValid && settings.useGps
180 latitude: positionSource.latitude
181 latitudeValid: positionSource.latitudeValid && settings.useGps
182 elevation: positionSource.altitude
183 elevationValid: positionSource.altitudeValid && settings.useGps
184 orientation: orientation.orientation
185 artist: settings.creatorName
186 captureDirection: compass.direction
187 captureDirectionValid: compass.directionValid
188 horizontalError: positionSource.horizontalAccuracy
189 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
190 dateTimeEnabled: true
195 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
200 active: viewfinder.camera.running
205 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
222 imageSuffix: viewfinder.camera.imageSuffix
223 videoSuffix: viewfinder.camera.videoSuffix
224 imagePath: platformSettings.imagePath
225 videoPath: platformSettings.videoPath
226 temporaryVideoPath: platformSettings.temporaryVideoPath
236 active: viewfinder.camera.running
237 manufacturer: deviceInfo.manufacturer
238 model: deviceInfo.model
243 camera: viewfinder.camera
245 function setImageResolution() {
246 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
247 showError(qsTr("Failed to set required resolution"))
254 camera: viewfinder.camera
256 function setVideoResolution() {
257 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
258 showError(qsTr("Failed to set required resolution"))
265 cam: viewfinder.camera
270 property bool dimmed: false
274 opacity: dimmed ? 1.0 : 0.0
276 Behavior on opacity {
277 PropertyAnimation { duration: 150 }
283 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
284 repeat: !settings.zoomAsShutter
289 running: proximitySensor.close
293 if (proximitySensor.close) {
294 proximitySensor.sensorClosed = true
299 CameraProximitySensor {
301 property bool sensorClosed: false
303 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
312 policyLost: pipelineManager.state == "policyLost"
313 show: !Qt.application.active || pipelineManager.showStandBy ||
314 (inCaptureMode && !viewfinder.camera.running)