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
42 camera: viewfinder.camera
44 height: mainView.height
50 height: mainView.height
54 camera: viewfinder.camera
56 height: mainView.height
62 LayoutMirroring.enabled: false
64 orientation: ListView.Horizontal
66 snapMode: ListView.SnapOneItem
67 highlightRangeMode: ListView.StrictlyEnforceRange
68 boundsBehavior: Flickable.StopAtBounds
70 interactive: !currentItem.pressed
73 Component.onCompleted: {
74 platformSettings.init()
75 root.resetCamera(settings.device, settings.mode)
84 onDeviceAboutToChange: {
85 root.deviceChangeInProgress = true
89 viewfinder.cameraDeviceChanged()
91 // Reset pipeline manager error
92 pipelineManager.error = false
94 if (root.resetCamera(settings.device, settings.mode)) {
95 root.deviceChangeInProgress = false
96 pipelineManager.startCamera()
100 onImageAspectRatioChanged: {
101 if (!root.deviceChangeInProgress) {
102 imageSettings.setImageResolution()
106 onImageResolutionChanged: {
107 if (!root.deviceChangeInProgress) {
108 imageSettings.setImageResolution()
112 onVideoResolutionChanged: {
113 if (!root.deviceChangeInProgress) {
114 videoSettings.setVideoResolution()
118 onVideoAspectRatioChanged: {
119 if (!root.deviceChangeInProgress) {
120 videoSettings.setVideoResolution()
127 camera: viewfinder.camera
128 currentItem: mainView.currentItem
131 function resetCamera(deviceId, mode) {
132 if (!viewfinder.camera.reset(deviceId, mode)) {
133 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
137 if (mode == Camera.ImageMode) {
138 imageSettings.setImageResolution()
140 else if (mode == Camera.VideoMode) {
141 videoSettings.setVideoResolution()
147 function showError(msg) {
152 property alias dimmer: camDimmer
153 CameraPositionSource {
155 active: settings.useGps
156 // TODO: we cannot bind to cam.running because camera will stop
157 // when the connection dialog pops up and we end up with an infinite loop
158 // active: cam.running && settings.useGps
159 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
164 camera: viewfinder.camera
165 manufacturer: deviceInfo.manufacturer
166 model: deviceInfo.model
167 country: geocode.country
169 suburb: geocode.suburb
170 longitude: positionSource.longitude
171 longitudeValid: positionSource.longitudeValid && settings.useGps
172 latitude: positionSource.latitude
173 latitudeValid: positionSource.latitudeValid && settings.useGps
174 elevation: positionSource.altitude
175 elevationValid: positionSource.altitudeValid && settings.useGps
176 orientation: orientation.orientation
177 artist: settings.creatorName
178 captureDirection: compass.direction
179 captureDirectionValid: compass.directionValid
180 horizontalError: positionSource.horizontalAccuracy
181 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
182 dateTimeEnabled: true
187 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
192 active: viewfinder.camera.running
197 active: viewfinder.camera.running && settings.useGps && settings.useGeotags
214 imageSuffix: viewfinder.camera.imageSuffix
215 videoSuffix: viewfinder.camera.videoSuffix
216 imagePath: platformSettings.imagePath
217 videoPath: platformSettings.videoPath
218 temporaryVideoPath: platformSettings.temporaryVideoPath
227 active: viewfinder.camera.running
228 manufacturer: deviceInfo.manufacturer
229 model: deviceInfo.model
234 camera: viewfinder.camera
236 function setImageResolution() {
237 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
238 showError(qsTr("Failed to set required resolution"))
245 camera: viewfinder.camera
247 function setVideoResolution() {
248 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
249 showError(qsTr("Failed to set required resolution"))
256 cam: viewfinder.camera
261 property bool dimmed: false
265 opacity: dimmed ? 1.0 : 0.0
267 Behavior on opacity {
268 PropertyAnimation { duration: 150 }
274 active: Qt.application.active && pipelineManager.scaleAcquired
275 repeat: !settings.zoomAsShutter
279 policyLost: pipelineManager.state == "policyLost"
280 show: !Qt.application.active || pipelineManager.showStandBy ||
281 (mainView.currentIndex == 1 && !viewfinder.camera.running)