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 imageSettings.setImageResolution()
105 onImageResolutionChanged: {
106 imageSettings.setImageResolution()
109 onVideoResolutionChanged: {
110 videoSettings.setVideoResolution()
116 camera: viewfinder.camera
117 currentItem: mainView.currentItem
120 function resetCamera(deviceId, mode) {
121 if (!viewfinder.camera.reset(deviceId, mode)) {
122 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
129 function showError(msg) {
134 property alias dimmer: camDimmer
135 CameraPositionSource {
137 active: settings.useGps
138 // TODO: we cannot bind to cam.running because camera will stop
139 // when the connection dialog pops up and we end up with an infinite loop
140 // active: cam.running && settings.useGps
141 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
146 camera: viewfinder.camera
147 manufacturer: deviceInfo.manufacturer
148 model: deviceInfo.model
149 country: geocode.country
151 suburb: geocode.suburb
152 longitude: positionSource.longitude
153 longitudeValid: positionSource.longitudeValid && settings.useGps
154 latitude: positionSource.latitude
155 latitudeValid: positionSource.latitudeValid && settings.useGps
156 elevation: positionSource.altitude
157 elevationValid: positionSource.altitudeValid && settings.useGps
158 orientation: orientation.orientation
159 artist: settings.creatorName
160 captureDirection: compass.direction
161 captureDirectionValid: compass.directionValid
162 horizontalError: positionSource.horizontalAccuracy
163 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
164 dateTimeEnabled: true
169 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
174 active: viewfinder.camera.running
179 active: viewfinder.camera.running && settings.useGps && settings.useGeotags
196 imageSuffix: viewfinder.camera.imageSuffix
197 videoSuffix: viewfinder.camera.videoSuffix
198 imagePath: platformSettings.imagePath
199 videoPath: platformSettings.videoPath
200 temporaryVideoPath: platformSettings.temporaryVideoPath
209 active: viewfinder.camera.running
210 manufacturer: deviceInfo.manufacturer
211 model: deviceInfo.model
216 camera: viewfinder.camera
218 function setImageResolution() {
219 if (!imageSettings.setResolution(settings.imageAspectRatio, settings.imageResolution)) {
220 showError(qsTr("Failed to set required resolution"))
226 imageSettings.setImageResolution()
233 camera: viewfinder.camera
235 function setVideoResolution() {
236 if (!videoSettings.setResolution(settings.videoAspectRatio, settings.videoResolution)) {
237 showError(qsTr("Failed to set required resolution"))
243 videoSettings.setVideoResolution()
250 cam: viewfinder.camera
255 property bool dimmed: false
259 opacity: dimmed ? 1.0 : 0.0
261 Behavior on opacity {
262 PropertyAnimation { duration: 150 }
268 active: Qt.application.active && pipelineManager.scaleAcquired
269 repeat: !settings.zoomAsShutter
273 policyLost: pipelineManager.state == "policyLost"
274 show: !Qt.application.active || pipelineManager.showStandBy ||
275 (mainView.currentIndex == 1 && !viewfinder.camera.running)