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
41 camera: viewfinder.camera
43 height: mainView.height
49 height: mainView.height
53 camera: viewfinder.camera
55 height: mainView.height
61 LayoutMirroring.enabled: false
63 orientation: ListView.Horizontal
65 snapMode: ListView.SnapOneItem
66 highlightRangeMode: ListView.StrictlyEnforceRange
67 boundsBehavior: Flickable.StopAtBounds
69 interactive: !currentItem.pressed
72 Component.onCompleted: {
73 platformSettings.init()
74 root.resetCamera(settings.device, settings.mode)
84 // Reset pipeline manager error
85 pipelineManager.error = false
87 if (root.resetCamera(settings.device, settings.mode)) {
88 pipelineManager.startCamera()
95 camera: viewfinder.camera
96 currentItem: mainView.currentItem
99 function resetCamera(deviceId, mode) {
100 if (!viewfinder.camera.reset(deviceId, mode)) {
101 showError(qsTr("Failed to set camera device and mode. Please restart the application."))
108 function showError(msg) {
113 property alias dimmer: camDimmer
114 CameraPositionSource {
116 active: settings.useGps
117 // TODO: we cannot bind to cam.running because camera will stop
118 // when the connection dialog pops up and we end up with an infinite loop
119 // active: cam.running && settings.useGps
120 onPositionChanged: geocode.search(position.coordinate.longitude, position.coordinate.latitude)
125 camera: viewfinder.camera
126 manufacturer: deviceInfo.manufacturer
127 model: deviceInfo.model
128 country: geocode.country
130 suburb: geocode.suburb
131 longitude: positionSource.longitude
132 longitudeValid: positionSource.longitudeValid && settings.useGps
133 latitude: positionSource.latitude
134 latitudeValid: positionSource.latitudeValid && settings.useGps
135 elevation: positionSource.altitude
136 elevationValid: positionSource.altitudeValid && settings.useGps
137 orientation: orientation.orientation
138 artist: settings.creatorName
139 captureDirection: compass.direction
140 captureDirectionValid: compass.directionValid
141 horizontalError: positionSource.horizontalAccuracy
142 horizontalErrorValid: positionSource.horizontalAccuracyValid && settings.useGps
143 dateTimeEnabled: true
148 active: viewfinder.camera.running || (mainView.currentIndex == 2 && Qt.application.active)
153 active: viewfinder.camera.running
158 active: viewfinder.camera.running && settings.useGps && settings.useGeotags
175 imageSuffix: viewfinder.camera.imageSuffix
176 videoSuffix: viewfinder.camera.videoSuffix
177 imagePath: platformSettings.imagePath
178 videoPath: platformSettings.videoPath
179 temporaryVideoPath: platformSettings.temporaryVideoPath
188 active: viewfinder.camera.running
189 manufacturer: deviceInfo.manufacturer
190 model: deviceInfo.model
195 camera: viewfinder.camera
197 function setImageResolution() {
198 var aspectRatio = settings.device == 1 ? settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio
199 var resolution = settings.device == 1 ? settings.secondaryImageResolution : settings.primaryImageResolution
201 if (!imageSettings.setResolution(aspectRatio, resolution)) {
202 showError(qsTr("Failed to set required resolution"))
208 imageSettings.setImageResolution()
215 camera: viewfinder.camera
217 function setVideoResolution() {
218 var aspectRatio = settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
219 var resolution = settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
221 if (!videoSettings.setResolution(aspectRatio, resolution)) {
222 showError(qsTr("Failed to set required resolution"))
228 videoSettings.setVideoResolution()
236 onPrimaryImageResolutionChanged: imageSettings.setImageResolution()
237 onPrimaryImageAspectRatioChanged: imageSettings.setImageResolution()
238 onSecondaryImageResolutionChanged: imageSettings.setImageResolution()
239 onSecondaryImageAspectRatioChanged: imageSettings.setImageResolution()
241 onPrimaryVideoResolutionChanged: videoSettings.setVideoResolution()
242 onPrimaryVideoAspectRatioChanged: videoSettings.setVideoResolution()
243 onSecondaryVideoResolutionChanged: videoSettings.setVideoResolution()
244 onSecondaryVideoAspectRatioChanged: videoSettings.setVideoResolution()
249 cam: viewfinder.camera
254 property bool dimmed: false
258 opacity: dimmed ? 1.0 : 0.0
260 Behavior on opacity {
261 PropertyAnimation { duration: 150 }
267 active: Qt.application.active && pipelineManager.scaleAcquired
268 repeat: !settings.zoomAsShutter
272 policyLost: pipelineManager.state == "policyLost"
273 show: !Qt.application.active || pipelineManager.showStandBy ||
274 (mainView.currentIndex == 1 && !viewfinder.camera.running)