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
30 property bool pressed: loader.item ? loader.item.pressed : false
31 property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None
33 renderingEnabled: mainView.currentItem == cam
35 function policyLost() {
37 loader.item.policyLost()
41 function checkBattery() {
42 // We are fine if we are connected to the charger:
43 if (batteryMonitor.charging) {
47 // If we have enough battery then we are fine:
48 if (!batteryMonitor.critical) {
55 Component.onDestruction: cam.stop()
59 mountProtector.unlock()
63 notifications: Sounds {
65 mute: !settings.soundEnabled
73 if (!checkBattery()) {
74 loader.item.batteryLow()
79 batteryMonitor.check()
83 batteryMonitor.check()
93 onPreviewAvailable: preview.setPreview(uri)
100 when: loader.item != null
105 property: "animationRunning"
106 value: preview.animationRunning
107 when: loader.item != null
110 onRoiChanged: roi.normalize = false
115 width: cam.renderArea.width
116 height: cam.renderArea.height
117 visible: settings.gridEnabled
123 visible: loader.item != null && loader.item.controlsVisible &&
124 cam.autoFocus.canFocus(cam.scene.value)
125 cafStatus: cam ? cam.autoFocus.cafStatus : -1
126 status: cam ? cam.autoFocus.status : -1
131 property string src: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
133 source: Qt.resolvedUrl(src)
139 when: cam.mode == Camera.ImageMode
140 value: settings.imageFlashMode
145 property: "imageFlashMode"
146 when: cam.mode == Camera.ImageMode
147 value: cam.flash.value
153 when: cam.mode == Camera.VideoMode
154 value: settings.videoSceneMode
160 when: cam.mode == Camera.ImageMode
161 value: settings.imageSceneMode
167 when: cam.mode == Camera.ImageMode
168 value: settings.imageEvComp
174 when: cam.mode == Camera.VideoMode
175 value: settings.videoEvComp
180 property: "imageEvComp"
181 when: cam.mode == Camera.ImageMode
182 value: cam.evComp.value
187 property: "videoEvComp"
188 when: cam.mode == Camera.VideoMode
189 value: cam.evComp.value
193 target: cam.whiteBalance
195 when: cam.mode == Camera.ImageMode
196 value: settings.imageWhiteBalance
200 target: cam.whiteBalance
202 when: cam.mode == Camera.VideoMode
203 value: settings.videoWhiteBalance
207 target: cam.colorTone
209 when: cam.mode == Camera.ImageMode
210 value: settings.imageColorFilter
214 target: cam.colorTone
216 when: cam.mode == Camera.VideoMode
217 value: settings.videoColorFilter
223 when: cam.mode == Camera.ImageMode
224 value: settings.imageIso
230 when: cam.mode == Camera.ImageMode
235 target: cam.videoMute
237 value: settings.videoMuted
243 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
247 if (pipelineManager.error) {
248 // Ignore any subsequent errors.
249 // Killing pulseaudio while recording will lead to an
250 // infinite supply of errors which will break the UI
251 // if we show a banner for each.
255 pipelineManager.error = true
257 loader.item.cameraError()
260 console.log("Camera error (" + code + "): " + message + " " + debug)
261 showError(qsTr("Camera error. Please restart the application."))
262 // We cannot stop camera here. Seems there is a race condition somewhere
263 // which leads to a freeze if we do so.