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) {
87 settingsLoader.source = ""
88 postCaptureLoader.source = ""
89 } else if (contentX == width * 2) {
90 postCaptureLoader.source = Qt.resolvedUrl("PostCaptureView.qml")
95 Component.onCompleted: {
96 platformSettings.init()
97 root.resetCamera(settings.device, settings.mode)
106 onDeviceAboutToChange: {
107 root.deviceChangeInProgress = true
111 viewfinder.cameraDeviceChanged()
113 // Reset pipeline manager error
114 pipelineManager.error = false
116 if (root.resetCamera(settings.device, settings.mode)) {
117 root.deviceChangeInProgress = false
118 pipelineManager.startCamera()
122 onImageAspectRatioChanged: {
123 if (!root.deviceChangeInProgress) {
124 imageSettings.setImageResolution()
128 onImageResolutionChanged: {
129 if (!root.deviceChangeInProgress) {
130 imageSettings.setImageResolution()
134 onVideoResolutionChanged: {
135 if (!root.deviceChangeInProgress) {
136 videoSettings.setVideoResolution()
140 onVideoAspectRatioChanged: {
141 if (!root.deviceChangeInProgress) {
142 videoSettings.setVideoResolution()
149 camera: viewfinder.camera
150 currentItem: mainView.currentItem
153 function resetCamera(deviceId, mode) {
154 if (!viewfinder.camera.reset(deviceId, mode)) {
155 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
159 if (mode == Camera.ImageMode) {
160 imageSettings.setImageResolution()
162 else if (mode == Camera.VideoMode) {
163 videoSettings.setVideoResolution()
169 function showError(msg) {
180 inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
183 CameraPositionSource {
185 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
186 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
191 camera: viewfinder.camera
192 manufacturer: deviceInfo.manufacturer
193 model: deviceInfo.model
194 country: geocode.country
196 suburb: geocode.suburb
197 longitude: positionSource.longitude
198 longitudeValid: positionSource.longitudeValid && settings.useGps
199 latitude: positionSource.latitude
200 latitudeValid: positionSource.latitudeValid && settings.useGps
201 elevation: positionSource.altitude
202 elevationValid: positionSource.altitudeValid && settings.useGps
203 orientation: orientation.orientation
204 artist: settings.creatorName
205 captureDirection: compass.direction
206 captureDirectionValid: compass.directionValid
207 horizontalError: positionSource.horizontalAccuracy
208 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
209 dateTimeEnabled: true
214 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
219 active: viewfinder.camera.running
224 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
241 imageSuffix: viewfinder.camera.imageSuffix
242 videoSuffix: viewfinder.camera.videoSuffix
243 imagePath: platformSettings.imagePath
244 videoPath: platformSettings.videoPath
245 temporaryVideoPath: platformSettings.temporaryVideoPath
255 active: viewfinder.camera.running
256 manufacturer: deviceInfo.manufacturer
257 model: deviceInfo.model
262 camera: viewfinder.camera
264 function setImageResolution() {
265 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
266 showError(qsTr("Failed to set required resolution"))
273 camera: viewfinder.camera
275 function setVideoResolution() {
276 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
277 showError(qsTr("Failed to set required resolution"))
284 cam: viewfinder.camera
289 property bool dimmed: false
293 opacity: dimmed ? 1.0 : 0.0
295 Behavior on opacity {
296 PropertyAnimation { duration: 150 }
302 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
303 repeat: !settings.zoomAsShutter
308 running: proximitySensor.close
312 if (proximitySensor.close) {
313 proximitySensor.sensorClosed = true
318 CameraProximitySensor {
320 property bool sensorClosed: false
322 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
331 policyLost: pipelineManager.state == "policyLost"
332 show: !Qt.application.active || pipelineManager.showStandBy ||
333 (inCaptureMode && !viewfinder.camera.running)