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
34 cameraConfig: cam.cameraConfig
35 renderingEnabled: mainView.currentItem == viewfinder
37 Component.onDestruction: cam.stop()
40 x: viewfinder.renderArea.x
41 y: viewfinder.renderArea.y
42 width: viewfinder.renderArea.width
43 height: viewfinder.renderArea.height
44 visible: settings.gridEnabled
55 mute: !settings.soundEnabled || phoneProfile.isSilent
56 volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
57 imageCaptureStart: platformSettings.imageCaptureStartedSound
58 imageCaptureEnd: platformSettings.imageCaptureEndedSound
59 videoRecordingStart: platformSettings.videoRecordingStartedSound
60 videoRecordingEnd: platformSettings.videoRecordingEndedSound
61 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
64 onFocusChanged: focus.value = Focus.ContinuousNormal
65 onRoiChanged: roi.normalize = false
69 mountProtector.unlockAll()
74 if (pipelineManager.error) {
75 // Ignore any subsequent errors.
76 // Killing pulseaudio while recording will lead to an
77 // infinite supply of errors which will break the UI
78 // if we show a banner for each.
82 pipelineManager.error = true
84 loader.item.cameraError()
87 console.log("Camera error (" + code + "): " + message + " " + debug)
88 showError(qsTr("Camera error. Please restart the application."))
89 // We cannot stop camera here. Seems there is a race condition somewhere
90 // which leads to a freeze if we do so.
104 if (!checkBattery()) {
105 loader.item.batteryLow()
110 batteryMonitor.check()
114 batteryMonitor.check()
125 videoResolution: viewfinder.videoResolution
126 renderArea: viewfinder.renderArea
128 visible: loader.item != null && loader.item.controlsVisible &&
129 cam.autoFocus.canFocus(cam.scene.value)
130 cafStatus: cam ? cam.autoFocus.cafStatus : -1
131 status: cam ? cam.autoFocus.status : -1
136 property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
138 source: Qt.resolvedUrl(src)
143 onPreviewAvailable: preview.setPreview(uri)
150 when: loader.item != null
155 property: "animationRunning"
156 value: preview.animationRunning
157 when: loader.item != null
160 /* Camera bindings */
164 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
165 value: settings.imageFlashMode
170 property: "imageFlashMode"
171 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
172 value: cam.flash.value
178 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
179 value: settings.videoSceneMode
185 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
186 value: settings.imageSceneMode
192 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
193 value: settings.imageEvComp
199 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
200 value: settings.videoEvComp
205 property: "imageEvComp"
206 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
207 value: cam.evComp.value
212 property: "videoEvComp"
213 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
214 value: cam.evComp.value
218 target: cam.whiteBalance
220 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
221 value: settings.imageWhiteBalance
225 target: cam.whiteBalance
227 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
228 value: settings.videoWhiteBalance
232 target: cam.colorTone
234 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
235 value: settings.imageColorFilter
239 target: cam.colorTone
241 when: cam.mode == Camera.VideoMode && !root.deviceChangeInProgress
242 value: settings.videoColorFilter
248 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
249 value: settings.imageIso
255 when: cam.mode == Camera.ImageMode && !root.deviceChangeInProgress
260 target: cam.videoMute
262 value: settings.videoMuted
268 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
271 function policyLost() {
273 loader.item.policyLost()
277 function checkBattery() {
278 // We are fine if we are connected to the charger:
279 if (batteryMonitor.charging) {
283 // If we have enough battery then we are fine:
284 if (!batteryMonitor.critical) {
291 function cameraDeviceChanged() {
293 loader.item.cameraDeviceChanged()