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
29 property bool pressed: focusReticle.locked || preview.animationRunning
30 || (loader.item ? loader.item.pressed : false)
31 property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
32 property bool inhibitDim: loader.item ? loader.item.inhibitDim : false
35 cameraConfig: cam.cameraConfig
36 renderingEnabled: mainView.currentItem == viewfinder
38 Component.onDestruction: cam.stop()
41 x: viewfinder.renderArea.x
42 y: viewfinder.renderArea.y
43 width: viewfinder.renderArea.width
44 height: viewfinder.renderArea.height
45 visible: settings.gridEnabled
56 mute: !settings.soundEnabled || phoneProfile.isSilent
57 volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
58 imageCaptureStart: platformSettings.imageCaptureStartedSound
59 imageCaptureEnd: platformSettings.imageCaptureEndedSound
60 videoRecordingStart: platformSettings.videoRecordingStartedSound
61 videoRecordingEnd: platformSettings.videoRecordingEndedSound
62 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
65 onFocusChanged: focus.value = Focus.ContinuousNormal
66 onRoiChanged: roi.normalize = false
70 mountProtector.unlockAll()
75 if (pipelineManager.error) {
76 // Ignore any subsequent errors.
77 // Killing pulseaudio while recording will lead to an
78 // infinite supply of errors which will break the UI
79 // if we show a banner for each.
83 pipelineManager.error = true
85 loader.item.cameraError()
88 console.log("Camera error (" + code + "): " + message + " " + debug)
89 showError(qsTr("Camera error. Please restart the application."))
90 // We cannot stop camera here. Seems there is a race condition somewhere
91 // which leads to a freeze if we do so.
105 if (!checkBattery()) {
106 loader.item.batteryLow()
111 batteryMonitor.check()
115 batteryMonitor.check()
126 videoResolution: viewfinder.videoResolution
127 renderArea: viewfinder.renderArea
129 visible: loader.item != null && loader.item.controlsVisible &&
130 cam.autoFocus.canFocus(cam.scene.value)
131 cafStatus: cam ? cam.autoFocus.cafStatus : -1
132 status: cam ? cam.autoFocus.status : -1
137 property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
139 source: Qt.resolvedUrl(src)
144 onPreviewAvailable: preview.setPreview(uri)
151 when: loader.item != null
156 property: "animationRunning"
157 value: preview.animationRunning
158 when: loader.item != null
161 /* Camera bindings */
165 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
166 value: settings.imageFlashMode
171 property: "imageFlashMode"
172 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
173 value: cam.flash.value
179 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
180 value: settings.videoSceneMode
186 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
187 value: settings.imageSceneMode
193 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
194 value: settings.imageEvComp
200 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
201 value: settings.videoEvComp
206 property: "imageEvComp"
207 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
208 value: cam.evComp.value
213 property: "videoEvComp"
214 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
215 value: cam.evComp.value
219 target: cam.whiteBalance
221 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
222 value: settings.imageWhiteBalance
226 target: cam.whiteBalance
228 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
229 value: settings.videoWhiteBalance
233 target: cam.colorTone
235 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
236 value: settings.imageColorFilter
240 target: cam.colorTone
242 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
243 value: settings.videoColorFilter
249 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
250 value: settings.imageIso
256 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
261 target: cam.videoMute
263 value: settings.videoMuted
269 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
272 function policyLost() {
274 loader.item.policyLost()
278 function checkBattery() {
279 // We are fine if we are connected to the charger:
280 if (batteryMonitor.charging) {
284 // If we have enough battery then we are fine:
285 if (!batteryMonitor.critical) {
292 function cameraDeviceChanged() {
294 loader.item.cameraDeviceChanged()