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 || (loader.item ? loader.item.pressed : false)
32 property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
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
52 mute: !settings.soundEnabled
53 volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
54 imageCaptureStart: platformSettings.imageCaptureStartedSound
55 imageCaptureEnd: platformSettings.imageCaptureEndedSound
56 videoRecordingStart: platformSettings.videoRecordingStartedSound
57 videoRecordingEnd: platformSettings.videoRecordingEndedSound
58 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
61 onRoiChanged: roi.normalize = false
65 mountProtector.unlock()
70 if (pipelineManager.error) {
71 // Ignore any subsequent errors.
72 // Killing pulseaudio while recording will lead to an
73 // infinite supply of errors which will break the UI
74 // if we show a banner for each.
78 pipelineManager.error = true
80 loader.item.cameraError()
83 console.log("Camera error (" + code + "): " + message + " " + debug)
84 showError(qsTr("Camera error. Please restart the application."))
85 // We cannot stop camera here. Seems there is a race condition somewhere
86 // which leads to a freeze if we do so.
100 if (!checkBattery()) {
101 loader.item.batteryLow()
106 batteryMonitor.check()
110 batteryMonitor.check()
121 videoResolution: viewfinder.videoResolution
122 renderArea: viewfinder.renderArea
124 visible: loader.item != null && loader.item.controlsVisible &&
125 cam.autoFocus.canFocus(cam.scene.value)
126 cafStatus: cam ? cam.autoFocus.cafStatus : -1
127 status: cam ? cam.autoFocus.status : -1
132 property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
134 source: Qt.resolvedUrl(src)
139 onPreviewAvailable: preview.setPreview(uri)
146 when: loader.item != null
151 property: "animationRunning"
152 value: preview.animationRunning
153 when: loader.item != null
156 /* Camera bindings */
160 when: cam.mode == Camera.ImageMode
161 value: settings.imageFlashMode
166 property: "imageFlashMode"
167 when: cam.mode == Camera.ImageMode
168 value: cam.flash.value
174 when: cam.mode == Camera.VideoMode
175 value: settings.videoSceneMode
181 when: cam.mode == Camera.ImageMode
182 value: settings.imageSceneMode
188 when: cam.mode == Camera.ImageMode
189 value: settings.imageEvComp
195 when: cam.mode == Camera.VideoMode
196 value: settings.videoEvComp
201 property: "imageEvComp"
202 when: cam.mode == Camera.ImageMode
203 value: cam.evComp.value
208 property: "videoEvComp"
209 when: cam.mode == Camera.VideoMode
210 value: cam.evComp.value
214 target: cam.whiteBalance
216 when: cam.mode == Camera.ImageMode
217 value: settings.imageWhiteBalance
221 target: cam.whiteBalance
223 when: cam.mode == Camera.VideoMode
224 value: settings.videoWhiteBalance
228 target: cam.colorTone
230 when: cam.mode == Camera.ImageMode
231 value: settings.imageColorFilter
235 target: cam.colorTone
237 when: cam.mode == Camera.VideoMode
238 value: settings.videoColorFilter
244 when: cam.mode == Camera.ImageMode
245 value: settings.imageIso
251 when: cam.mode == Camera.ImageMode
256 target: cam.videoMute
258 value: settings.videoMuted
264 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
267 function policyLost() {
269 loader.item.policyLost()
273 function checkBattery() {
274 // We are fine if we are connected to the charger:
275 if (batteryMonitor.charging) {
279 // If we have enough battery then we are fine:
280 if (!batteryMonitor.critical) {