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
48 height: mainView.height
50 property bool pressed: false
51 property bool inhibitDim: false
52 property int policyMode: settings.mode == Camera.VideoMode ? CameraResources.Video : CameraResources.Image
58 height: mainView.height
63 property bool pressed: item ? item.pressed : false
64 property bool inhibitDim: item ? item.inhibitDim : false
65 property int policyMode: item ? item.policyMode : settings.mode == Camera.VideoMode ? CameraResources.Video : CameraResources.Image
68 height: mainView.height
74 LayoutMirroring.enabled: false
76 orientation: ListView.Horizontal
78 snapMode: ListView.SnapOneItem
79 highlightRangeMode: ListView.StrictlyEnforceRange
80 boundsBehavior: Flickable.StopAtBounds
82 interactive: !currentItem.pressed
85 settingsLoader.source = Qt.resolvedUrl("SettingsView.qml")
86 } else if (contentX == width * 2) {
87 postCaptureLoader.source = Qt.resolvedUrl("PostCaptureView.qml")
92 Component.onCompleted: {
93 platformSettings.init()
94 root.resetCamera(settings.device, settings.mode)
103 onDeviceAboutToChange: {
104 root.deviceChangeInProgress = true
108 viewfinder.cameraDeviceChanged()
110 // Reset pipeline manager error
111 pipelineManager.error = false
113 if (root.resetCamera(settings.device, settings.mode)) {
114 root.deviceChangeInProgress = false
115 pipelineManager.startCamera()
119 onImageAspectRatioChanged: {
120 if (!root.deviceChangeInProgress) {
121 imageSettings.setImageResolution()
125 onImageResolutionChanged: {
126 if (!root.deviceChangeInProgress) {
127 imageSettings.setImageResolution()
131 onVideoResolutionChanged: {
132 if (!root.deviceChangeInProgress) {
133 videoSettings.setVideoResolution()
137 onVideoAspectRatioChanged: {
138 if (!root.deviceChangeInProgress) {
139 videoSettings.setVideoResolution()
146 camera: viewfinder.camera
147 currentItem: mainView.currentItem
150 function resetCamera(deviceId, mode) {
151 if (!viewfinder.camera.reset(deviceId, mode)) {
152 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
156 if (mode == Camera.ImageMode) {
157 imageSettings.setImageResolution()
159 else if (mode == Camera.VideoMode) {
160 videoSettings.setVideoResolution()
166 function showError(msg) {
177 inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
180 CameraPositionSource {
182 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
183 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
188 camera: viewfinder.camera
189 manufacturer: deviceInfo.manufacturer
190 model: deviceInfo.model
191 country: geocode.country
193 suburb: geocode.suburb
194 longitude: positionSource.longitude
195 longitudeValid: positionSource.longitudeValid && settings.useGps
196 latitude: positionSource.latitude
197 latitudeValid: positionSource.latitudeValid && settings.useGps
198 elevation: positionSource.altitude
199 elevationValid: positionSource.altitudeValid && settings.useGps
200 orientation: orientation.orientation
201 artist: settings.creatorName
202 captureDirection: compass.direction
203 captureDirectionValid: compass.directionValid
204 horizontalError: positionSource.horizontalAccuracy
205 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
206 dateTimeEnabled: true
211 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
216 active: viewfinder.camera.running
221 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
238 imageSuffix: viewfinder.camera.imageSuffix
239 videoSuffix: viewfinder.camera.videoSuffix
240 imagePath: platformSettings.imagePath
241 videoPath: platformSettings.videoPath
242 temporaryVideoPath: platformSettings.temporaryVideoPath
252 active: viewfinder.camera.running
253 manufacturer: deviceInfo.manufacturer
254 model: deviceInfo.model
259 camera: viewfinder.camera
261 function setImageResolution() {
262 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
263 showError(qsTr("Failed to set required resolution"))
270 camera: viewfinder.camera
272 function setVideoResolution() {
273 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
274 showError(qsTr("Failed to set required resolution"))
281 cam: viewfinder.camera
286 property bool dimmed: false
290 opacity: dimmed ? 1.0 : 0.0
292 Behavior on opacity {
293 PropertyAnimation { duration: 150 }
299 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
300 repeat: !settings.zoomAsShutter
305 running: proximitySensor.close
309 if (proximitySensor.close) {
310 proximitySensor.sensorClosed = true
315 CameraProximitySensor {
317 property bool sensorClosed: false
319 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
328 policyLost: pipelineManager.state == "policyLost"
329 show: !Qt.application.active || pipelineManager.showStandBy ||
330 (inCaptureMode && !viewfinder.camera.running)