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()
153 camera: viewfinder.camera
154 currentItem: mainView.currentItem
157 function resetCamera(deviceId, mode) {
158 if (!viewfinder.camera.reset(deviceId, mode)) {
159 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
163 if (mode == Camera.ImageMode) {
164 imageSettings.setImageResolution()
166 else if (mode == Camera.VideoMode) {
167 videoSettings.setVideoResolution()
173 function showError(msg) {
184 inhibitDim: mainView.currentItem != null ? mainView.currentItem.inhibitDim : false
187 CameraPositionSource {
189 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && displayState.isOn
190 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
195 camera: viewfinder.camera
196 manufacturer: deviceInfo.manufacturer
197 model: deviceInfo.model
198 country: geocode.country
200 suburb: geocode.suburb
201 longitude: positionSource.longitude
202 longitudeValid: positionSource.longitudeValid && settings.useGps
203 latitude: positionSource.latitude
204 latitudeValid: positionSource.latitudeValid && settings.useGps
205 elevation: positionSource.altitude
206 elevationValid: positionSource.altitudeValid && settings.useGps
207 orientation: orientation.orientation
208 artist: settings.creatorName
209 captureDirection: compass.direction
210 captureDirectionValid: compass.directionValid
211 horizontalError: positionSource.horizontalAccuracy
212 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
213 dateTimeEnabled: true
218 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
223 active: viewfinder.camera.running
228 active: (viewfinder.camera.running || platformQuirks.forceOn) && settings.useGps && settings.useGeotags && displayState.isOn
245 imageSuffix: viewfinder.camera.imageSuffix
246 videoSuffix: viewfinder.camera.videoSuffix
247 imagePath: platformSettings.imagePath
248 videoPath: platformSettings.videoPath
249 temporaryVideoPath: platformSettings.temporaryVideoPath
259 active: viewfinder.camera.running
260 manufacturer: deviceInfo.manufacturer
261 model: deviceInfo.model
266 camera: viewfinder.camera
268 function setImageResolution() {
269 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
270 showError(qsTr("Failed to set required resolution"))
277 camera: viewfinder.camera
279 function setVideoResolution() {
280 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
281 showError(qsTr("Failed to set required resolution"))
288 cam: viewfinder.camera
293 property bool dimmed: false
297 opacity: dimmed ? 1.0 : 0.0
299 Behavior on opacity {
300 PropertyAnimation { duration: 150 }
306 active: Qt.application.active && pipelineManager.scaleAcquired && root.inCaptureMode && !mainView.moving
307 repeat: !settings.zoomAsShutter
312 running: proximitySensor.close
316 if (proximitySensor.close) {
317 proximitySensor.sensorClosed = true
322 CameraProximitySensor {
324 property bool sensorClosed: false
326 active: Qt.application.active && viewfinder.camera.running && settings.proximityAsShutter && root.inCaptureMode && !mainView.moving
335 policyLost: pipelineManager.state == "policyLost"
336 show: !Qt.application.active || pipelineManager.showStandBy ||
337 (inCaptureMode && !viewfinder.camera.running)