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()
101 onImageAspectRatioChanged: {
102 if (!root.deviceChangeInProgress) {
103 imageSettings.setImageResolution()
107 onImageResolutionChanged: {
108 if (!root.deviceChangeInProgress) {
109 imageSettings.setImageResolution()
113 onVideoResolutionChanged: {
114 if (!root.deviceChangeInProgress) {
115 videoSettings.setVideoResolution()
122 camera: viewfinder.camera
123 currentItem: mainView.currentItem
126 function resetCamera(deviceId, mode) {
127 if (!viewfinder.camera.reset(deviceId, mode)) {
128 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
132 if (mode == Camera.ImageMode) {
133 imageSettings.setImageResolution()
135 else if (mode == Camera.VideoMode) {
136 videoSettings.setVideoResolution()
142 function showError(msg) {
147 property alias dimmer: camDimmer
148 CameraPositionSource {
150 active: settings.useGps
151 // TODO: we cannot bind to cam.running because camera will stop
152 // when the connection dialog pops up and we end up with an infinite loop
153 // active: cam.running && settings.useGps
154 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
159 camera: viewfinder.camera
160 manufacturer: deviceInfo.manufacturer
161 model: deviceInfo.model
162 country: geocode.country
164 suburb: geocode.suburb
165 longitude: positionSource.longitude
166 longitudeValid: positionSource.longitudeValid && settings.useGps
167 latitude: positionSource.latitude
168 latitudeValid: positionSource.latitudeValid && settings.useGps
169 elevation: positionSource.altitude
170 elevationValid: positionSource.altitudeValid && settings.useGps
171 orientation: orientation.orientation
172 artist: settings.creatorName
173 captureDirection: compass.direction
174 captureDirectionValid: compass.directionValid
175 horizontalError: positionSource.horizontalAccuracy
176 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
177 dateTimeEnabled: true
182 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
187 active: viewfinder.camera.running
192 active: viewfinder.camera.running && settings.useGps && settings.useGeotags
209 imageSuffix: viewfinder.camera.imageSuffix
210 videoSuffix: viewfinder.camera.videoSuffix
211 imagePath: platformSettings.imagePath
212 videoPath: platformSettings.videoPath
213 temporaryVideoPath: platformSettings.temporaryVideoPath
222 active: viewfinder.camera.running
223 manufacturer: deviceInfo.manufacturer
224 model: deviceInfo.model
229 camera: viewfinder.camera
231 function setImageResolution() {
232 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
233 showError(qsTr("Failed to set required resolution"))
240 camera: viewfinder.camera
242 function setVideoResolution() {
243 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
244 showError(qsTr("Failed to set required resolution"))
251 cam: viewfinder.camera
256 property bool dimmed: false
260 opacity: dimmed ? 1.0 : 0.0
262 Behavior on opacity {
263 PropertyAnimation { duration: 150 }
269 active: Qt.application.active && pipelineManager.scaleAcquired
270 repeat: !settings.zoomAsShutter
274 policyLost: pipelineManager.state == "policyLost"
275 show: !Qt.application.active || pipelineManager.showStandBy ||
276 (mainView.currentIndex == 1 && !viewfinder.camera.running)