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: reset reticle and roi when we stop camera or change mode
31 property bool pressed: focusReticle.locked || preview.animationRunning
32 || (loader.item ? loader.item.pressed : false)
33 property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
36 cameraConfig: cam.cameraConfig
37 renderingEnabled: mainView.currentItem == viewfinder
39 Component.onDestruction: cam.stop()
42 x: viewfinder.renderArea.x
43 y: viewfinder.renderArea.y
44 width: viewfinder.renderArea.width
45 height: viewfinder.renderArea.height
46 visible: settings.gridEnabled
53 mute: !settings.soundEnabled
54 volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
55 imageCaptureStart: platformSettings.imageCaptureStartedSound
56 imageCaptureEnd: platformSettings.imageCaptureEndedSound
57 videoRecordingStart: platformSettings.videoRecordingStartedSound
58 videoRecordingEnd: platformSettings.videoRecordingEndedSound
59 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
62 onRoiChanged: roi.normalize = false
66 mountProtector.unlock()
71 if (pipelineManager.error) {
72 // Ignore any subsequent errors.
73 // Killing pulseaudio while recording will lead to an
74 // infinite supply of errors which will break the UI
75 // if we show a banner for each.
79 pipelineManager.error = true
81 loader.item.cameraError()
84 console.log("Camera error (" + code + "): " + message + " " + debug)
85 showError(qsTr("Camera error. Please restart the application."))
86 // We cannot stop camera here. Seems there is a race condition somewhere
87 // which leads to a freeze if we do so.
101 if (!checkBattery()) {
102 loader.item.batteryLow()
107 batteryMonitor.check()
111 batteryMonitor.check()
122 videoResolution: viewfinder.videoResolution
123 renderArea: viewfinder.renderArea
125 visible: loader.item != null && loader.item.controlsVisible &&
126 cam.autoFocus.canFocus(cam.scene.value)
127 cafStatus: cam ? cam.autoFocus.cafStatus : -1
128 status: cam ? cam.autoFocus.status : -1
133 property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
135 source: Qt.resolvedUrl(src)
140 onPreviewAvailable: preview.setPreview(uri)
147 when: loader.item != null
152 property: "animationRunning"
153 value: preview.animationRunning
154 when: loader.item != null
157 /* Camera bindings */
161 when: cam.mode == Camera.ImageMode
162 value: settings.imageFlashMode
167 property: "imageFlashMode"
168 when: cam.mode == Camera.ImageMode
169 value: cam.flash.value
175 when: cam.mode == Camera.VideoMode
176 value: settings.videoSceneMode
182 when: cam.mode == Camera.ImageMode
183 value: settings.imageSceneMode
189 when: cam.mode == Camera.ImageMode
190 value: settings.imageEvComp
196 when: cam.mode == Camera.VideoMode
197 value: settings.videoEvComp
202 property: "imageEvComp"
203 when: cam.mode == Camera.ImageMode
204 value: cam.evComp.value
209 property: "videoEvComp"
210 when: cam.mode == Camera.VideoMode
211 value: cam.evComp.value
215 target: cam.whiteBalance
217 when: cam.mode == Camera.ImageMode
218 value: settings.imageWhiteBalance
222 target: cam.whiteBalance
224 when: cam.mode == Camera.VideoMode
225 value: settings.videoWhiteBalance
229 target: cam.colorTone
231 when: cam.mode == Camera.ImageMode
232 value: settings.imageColorFilter
236 target: cam.colorTone
238 when: cam.mode == Camera.VideoMode
239 value: settings.videoColorFilter
245 when: cam.mode == Camera.ImageMode
246 value: settings.imageIso
252 when: cam.mode == Camera.ImageMode
257 target: cam.videoMute
259 value: settings.videoMuted
265 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
268 function policyLost() {
270 loader.item.policyLost()
274 function checkBattery() {
275 // We are fine if we are connected to the charger:
276 if (batteryMonitor.charging) {
280 // If we have enough battery then we are fine:
281 if (!batteryMonitor.critical) {