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
34 renderingEnabled: mainView.currentItem == cam
36 function policyLost() {
38 loader.item.policyLost()
42 function checkBattery() {
43 // We are fine if we are connected to the charger:
44 if (batteryMonitor.charging) {
48 // If we have enough battery then we are fine:
49 if (!batteryMonitor.critical) {
56 Component.onDestruction: cam.stop()
60 mountProtector.unlock()
66 mute: !settings.soundEnabled
67 imageCaptureStart: platformSettings.imageCaptureStartedSound
68 imageCaptureEnd: platformSettings.imageCaptureEndedSound
69 videoRecordingStart: platformSettings.videoRecordingStartedSound
70 videoRecordingEnd: platformSettings.videoRecordingEndedSound
71 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
79 if (!checkBattery()) {
80 loader.item.batteryLow()
85 batteryMonitor.check()
89 batteryMonitor.check()
99 onPreviewAvailable: preview.setPreview(uri)
106 when: loader.item != null
111 property: "animationRunning"
112 value: preview.animationRunning
113 when: loader.item != null
116 onRoiChanged: roi.normalize = false
121 width: cam.renderArea.width
122 height: cam.renderArea.height
123 visible: settings.gridEnabled
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: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
139 source: Qt.resolvedUrl(src)
145 when: cam.mode == Camera.ImageMode
146 value: settings.imageFlashMode
151 property: "imageFlashMode"
152 when: cam.mode == Camera.ImageMode
153 value: cam.flash.value
159 when: cam.mode == Camera.VideoMode
160 value: settings.videoSceneMode
166 when: cam.mode == Camera.ImageMode
167 value: settings.imageSceneMode
173 when: cam.mode == Camera.ImageMode
174 value: settings.imageEvComp
180 when: cam.mode == Camera.VideoMode
181 value: settings.videoEvComp
186 property: "imageEvComp"
187 when: cam.mode == Camera.ImageMode
188 value: cam.evComp.value
193 property: "videoEvComp"
194 when: cam.mode == Camera.VideoMode
195 value: cam.evComp.value
199 target: cam.whiteBalance
201 when: cam.mode == Camera.ImageMode
202 value: settings.imageWhiteBalance
206 target: cam.whiteBalance
208 when: cam.mode == Camera.VideoMode
209 value: settings.videoWhiteBalance
213 target: cam.colorTone
215 when: cam.mode == Camera.ImageMode
216 value: settings.imageColorFilter
220 target: cam.colorTone
222 when: cam.mode == Camera.VideoMode
223 value: settings.videoColorFilter
229 when: cam.mode == Camera.ImageMode
230 value: settings.imageIso
236 when: cam.mode == Camera.ImageMode
241 target: cam.videoMute
243 value: settings.videoMuted
249 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
253 if (pipelineManager.error) {
254 // Ignore any subsequent errors.
255 // Killing pulseaudio while recording will lead to an
256 // infinite supply of errors which will break the UI
257 // if we show a banner for each.
261 pipelineManager.error = true
263 loader.item.cameraError()
266 console.log("Camera error (" + code + "): " + message + " " + debug)
267 showError(qsTr("Camera error. Please restart the application."))
268 // We cannot stop camera here. Seems there is a race condition somewhere
269 // which leads to a freeze if we do so.