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)
28 // TODO: front camera night mode
33 property bool deviceChangeInProgress: false
43 camera: viewfinder.camera
45 height: mainView.height
51 height: mainView.height
55 camera: viewfinder.camera
57 height: mainView.height
63 LayoutMirroring.enabled: false
65 orientation: ListView.Horizontal
67 snapMode: ListView.SnapOneItem
68 highlightRangeMode: ListView.StrictlyEnforceRange
69 boundsBehavior: Flickable.StopAtBounds
71 interactive: !currentItem.pressed
74 Component.onCompleted: {
75 platformSettings.init()
76 root.resetCamera(settings.device, settings.mode)
85 onDeviceAboutToChange: {
86 root.deviceChangeInProgress = true
90 viewfinder.cameraDeviceChanged()
92 // Reset pipeline manager error
93 pipelineManager.error = false
95 if (root.resetCamera(settings.device, settings.mode)) {
96 root.deviceChangeInProgress = false
97 pipelineManager.startCamera()
104 camera: viewfinder.camera
105 currentItem: mainView.currentItem
108 function resetCamera(deviceId, mode) {
109 if (!viewfinder.camera.reset(deviceId, mode)) {
110 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
117 function showError(msg) {
122 property alias dimmer: camDimmer
123 CameraPositionSource {
125 active: settings.useGps
126 // TODO: we cannot bind to cam.running because camera will stop
127 // when the connection dialog pops up and we end up with an infinite loop
128 // active: cam.running && settings.useGps
129 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
134 camera: viewfinder.camera
135 manufacturer: deviceInfo.manufacturer
136 model: deviceInfo.model
137 country: geocode.country
139 suburb: geocode.suburb
140 longitude: positionSource.longitude
141 longitudeValid: positionSource.longitudeValid && settings.useGps
142 latitude: positionSource.latitude
143 latitudeValid: positionSource.latitudeValid && settings.useGps
144 elevation: positionSource.altitude
145 elevationValid: positionSource.altitudeValid && settings.useGps
146 orientation: orientation.orientation
147 artist: settings.creatorName
148 captureDirection: compass.direction
149 captureDirectionValid: compass.directionValid
150 horizontalError: positionSource.horizontalAccuracy
151 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
152 dateTimeEnabled: true
157 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
162 active: viewfinder.camera.running
167 active: viewfinder.camera.running && settings.useGps && settings.useGeotags
184 imageSuffix: viewfinder.camera.imageSuffix
185 videoSuffix: viewfinder.camera.videoSuffix
186 imagePath: platformSettings.imagePath
187 videoPath: platformSettings.videoPath
188 temporaryVideoPath: platformSettings.temporaryVideoPath
197 active: viewfinder.camera.running
198 manufacturer: deviceInfo.manufacturer
199 model: deviceInfo.model
204 camera: viewfinder.camera
206 function setImageResolution() {
207 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
208 showError(qsTr("Failed to set required resolution"))
214 imageSettings.setImageResolution()
221 camera: viewfinder.camera
223 function setVideoResolution() {
224 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
225 showError(qsTr("Failed to set required resolution"))
231 videoSettings.setVideoResolution()
239 onImageAspectRatioChanged: {
240 imageSettings.setImageResolution()
243 onImageResolutionChanged: {
244 imageSettings.setImageResolution()
247 onVideoResolutionChanged: {
248 videoSettings.setVideoResolution()
254 cam: viewfinder.camera
259 property bool dimmed: false
263 opacity: dimmed ? 1.0 : 0.0
265 Behavior on opacity {
266 PropertyAnimation { duration: 150 }
272 active: Qt.application.active && pipelineManager.scaleAcquired
273 repeat: !settings.zoomAsShutter
277 policyLost: pipelineManager.state == "policyLost"
278 show: !Qt.application.active || pipelineManager.showStandBy ||
279 (mainView.currentIndex == 1 && !viewfinder.camera.running)