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 onFocusChanged: focus.value = Focus.ContinuousNormal
63 onRoiChanged: roi.normalize = false
67 mountProtector.unlockAll()
72 if (pipelineManager.error) {
73 // Ignore any subsequent errors.
74 // Killing pulseaudio while recording will lead to an
75 // infinite supply of errors which will break the UI
76 // if we show a banner for each.
80 pipelineManager.error = true
82 loader.item.cameraError()
85 console.log("Camera error (" + code + "): " + message + " " + debug)
86 showError(qsTr("Camera error. Please restart the application."))
87 // We cannot stop camera here. Seems there is a race condition somewhere
88 // which leads to a freeze if we do so.
102 if (!checkBattery()) {
103 loader.item.batteryLow()
108 batteryMonitor.check()
112 batteryMonitor.check()
123 videoResolution: viewfinder.videoResolution
124 renderArea: viewfinder.renderArea
126 visible: loader.item != null && loader.item.controlsVisible &&
127 cam.autoFocus.canFocus(cam.scene.value)
128 cafStatus: cam ? cam.autoFocus.cafStatus : -1
129 status: cam ? cam.autoFocus.status : -1
134 property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
136 source: Qt.resolvedUrl(src)
141 onPreviewAvailable: preview.setPreview(uri)
148 when: loader.item != null
153 property: "animationRunning"
154 value: preview.animationRunning
155 when: loader.item != null
158 /* Camera bindings */
162 when: cam.mode == Camera.ImageMode
163 value: settings.imageFlashMode
168 property: "imageFlashMode"
169 when: cam.mode == Camera.ImageMode
170 value: cam.flash.value
176 when: cam.mode == Camera.VideoMode
177 value: settings.videoSceneMode
183 when: cam.mode == Camera.ImageMode
184 value: settings.imageSceneMode
190 when: cam.mode == Camera.ImageMode
191 value: settings.imageEvComp
197 when: cam.mode == Camera.VideoMode
198 value: settings.videoEvComp
203 property: "imageEvComp"
204 when: cam.mode == Camera.ImageMode
205 value: cam.evComp.value
210 property: "videoEvComp"
211 when: cam.mode == Camera.VideoMode
212 value: cam.evComp.value
216 target: cam.whiteBalance
218 when: cam.mode == Camera.ImageMode
219 value: settings.imageWhiteBalance
223 target: cam.whiteBalance
225 when: cam.mode == Camera.VideoMode
226 value: settings.videoWhiteBalance
230 target: cam.colorTone
232 when: cam.mode == Camera.ImageMode
233 value: settings.imageColorFilter
237 target: cam.colorTone
239 when: cam.mode == Camera.VideoMode
240 value: settings.videoColorFilter
246 when: cam.mode == Camera.ImageMode
247 value: settings.imageIso
253 when: cam.mode == Camera.ImageMode
258 target: cam.videoMute
260 value: settings.videoMuted
266 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
269 function policyLost() {
271 loader.item.policyLost()
275 function checkBattery() {
276 // We are fine if we are connected to the charger:
277 if (batteryMonitor.charging) {
281 // If we have enough battery then we are fine:
282 if (!batteryMonitor.critical) {