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: {
145 if (settings.enablePreview) {
146 preview.setPreview(uri)
155 when: loader.item != null
160 property: "animationRunning"
161 value: preview.animationRunning
162 when: loader.item != null
165 /* Camera bindings */
169 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
170 value: settings.imageFlashMode
175 property: "imageFlashMode"
176 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
177 value: cam.flash.value
183 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
184 value: settings.videoSceneMode
190 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
191 value: settings.imageSceneMode
197 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
198 value: settings.imageEvComp
204 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
205 value: settings.videoEvComp
210 property: "imageEvComp"
211 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
212 value: cam.evComp.value
217 property: "videoEvComp"
218 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
219 value: cam.evComp.value
223 target: cam.whiteBalance
225 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
226 value: settings.imageWhiteBalance
230 target: cam.whiteBalance
232 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
233 value: settings.videoWhiteBalance
237 target: cam.colorTone
239 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
240 value: settings.imageColorFilter
244 target: cam.colorTone
246 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
247 value: settings.videoColorFilter
253 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
254 value: settings.imageIso
260 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
265 target: cam.videoMute
267 value: settings.videoMuted
273 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
276 function policyLost() {
278 loader.item.policyLost()
282 function checkBattery() {
283 // We are fine if we are connected to the charger:
284 if (batteryMonitor.charging) {
288 // If we have enough battery then we are fine:
289 if (!batteryMonitor.critical) {
296 function cameraDeviceChanged() {
298 loader.item.cameraDeviceChanged()