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
53 opacity: item ? 1.0 : 0
56 NumberAnimation {duration: 200}
63 height: mainView.height
68 property bool pressed: item ? item.pressed : false
69 property bool inhibitDim: item ? item.inhibitDim : false
70 property int policyMode: item ? item.policyMode : settings.mode == Camera.VideoMode ? CameraResources.Video : CameraResources.Image
73 height: mainView.height
74 opacity: item ? 1.0 : 0
77 NumberAnimation {duration: 200}
84 LayoutMirroring.enabled: false
86 orientation: ListView.Horizontal
88 snapMode: ListView.SnapOneItem
89 highlightRangeMode: ListView.StrictlyEnforceRange
90 boundsBehavior: Flickable.StopAtBounds
92 interactive: !currentItem.pressed
95 settingsLoader.source = Qt.resolvedUrl("SettingsView.qml")
96 } else if (contentX == width) {
97 settingsLoader.source = ""
98 postCaptureLoader.source = ""
99 } else if (contentX == width * 2) {
100 postCaptureLoader.source = Qt.resolvedUrl("PostCaptureView.qml")
105 Component.onCompleted: {
106 platformSettings.init()
107 root.resetCamera(settings.device, settings.mode)
116 onDeviceAboutToChange: {
117 root.deviceChangeInProgress = true
121 viewfinder.cameraDeviceChanged()
123 // Reset pipeline manager error
124 pipelineManager.error = false
126 if (root.resetCamera(settings.device, settings.mode)) {
127 root.deviceChangeInProgress = false
128 pipelineManager.startCamera()
132 onImageAspectRatioChanged: {
133 if (!root.deviceChangeInProgress) {
134 imageSettings.setImageResolution()
138 onImageResolutionChanged: {
139 if (!root.deviceChangeInProgress) {
140 imageSettings.setImageResolution()
144 onVideoResolutionChanged: {
145 if (!root.deviceChangeInProgress) {
146 videoSettings.setVideoResolution()
150 onVideoAspectRatioChanged: {
151 if (!root.deviceChangeInProgress) {
152 videoSettings.setVideoResolution()
159 camera: viewfinder.camera
160 currentItem: mainView.currentItem
163 function resetCamera(deviceId, mode) {
164 if (!viewfinder.camera.reset(deviceId, mode)) {
165 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
169 if (mode == Camera.ImageMode) {
170 imageSettings.setImageResolution()
172 else if (mode == Camera.VideoMode) {
173 videoSettings.setVideoResolution()
179 function showError(msg) {
190 inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
193 CameraPositionSource {
195 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
196 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
201 camera: viewfinder.camera
202 manufacturer: deviceInfo.manufacturer
203 model: deviceInfo.model
204 country: geocode.country
206 suburb: geocode.suburb
207 longitude: positionSource.longitude
208 longitudeValid: positionSource.longitudeValid && settings.useGps
209 latitude: positionSource.latitude
210 latitudeValid: positionSource.latitudeValid && settings.useGps
211 elevation: positionSource.altitude
212 elevationValid: positionSource.altitudeValid && settings.useGps
213 orientation: orientation.orientation
214 artist: settings.creatorName
215 captureDirection: compass.direction
216 captureDirectionValid: compass.directionValid
217 horizontalError: positionSource.horizontalAccuracy
218 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
219 dateTimeEnabled: true
224 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
229 active: viewfinder.camera.running
234 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
251 imageSuffix: viewfinder.camera.imageSuffix
252 videoSuffix: viewfinder.camera.videoSuffix
253 imagePath: platformSettings.imagePath
254 videoPath: platformSettings.videoPath
255 temporaryVideoPath: platformSettings.temporaryVideoPath
265 active: viewfinder.camera.running
266 manufacturer: deviceInfo.manufacturer
267 model: deviceInfo.model
272 camera: viewfinder.camera
274 function setImageResolution() {
275 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
276 showError(qsTr("Failed to set required resolution"))
283 camera: viewfinder.camera
285 function setVideoResolution() {
286 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
287 showError(qsTr("Failed to set required resolution"))
294 cam: viewfinder.camera
299 property bool dimmed: false
303 opacity: dimmed ? 1.0 : 0.0
305 Behavior on opacity {
306 PropertyAnimation { duration: 150 }
312 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
313 repeat: !settings.zoomAsShutter
318 running: proximitySensor.close
322 if (proximitySensor.close) {
323 proximitySensor.sensorClosed = true
328 CameraProximitySensor {
330 property bool sensorClosed: false
332 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
341 policyLost: pipelineManager.state == "policyLost"
342 show: !Qt.application.active || pipelineManager.showStandBy ||
343 (inCaptureMode && !viewfinder.camera.running)