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: 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()
64 notifications: Sounds {
66 mute: !settings.soundEnabled
74 if (!checkBattery()) {
75 loader.item.batteryLow()
80 batteryMonitor.check()
84 batteryMonitor.check()
94 onPreviewAvailable: preview.setPreview(uri)
101 when: loader.item != null
106 property: "animationRunning"
107 value: preview.animationRunning
108 when: loader.item != null
111 onRoiChanged: roi.normalize = false
116 width: cam.renderArea.width
117 height: cam.renderArea.height
118 visible: settings.gridEnabled
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: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
134 source: Qt.resolvedUrl(src)
140 when: cam.mode == Camera.ImageMode
141 value: settings.imageFlashMode
146 property: "imageFlashMode"
147 when: cam.mode == Camera.ImageMode
148 value: cam.flash.value
154 when: cam.mode == Camera.VideoMode
155 value: settings.videoSceneMode
161 when: cam.mode == Camera.ImageMode
162 value: settings.imageSceneMode
168 when: cam.mode == Camera.ImageMode
169 value: settings.imageEvComp
175 when: cam.mode == Camera.VideoMode
176 value: settings.videoEvComp
181 property: "imageEvComp"
182 when: cam.mode == Camera.ImageMode
183 value: cam.evComp.value
188 property: "videoEvComp"
189 when: cam.mode == Camera.VideoMode
190 value: cam.evComp.value
194 target: cam.whiteBalance
196 when: cam.mode == Camera.ImageMode
197 value: settings.imageWhiteBalance
201 target: cam.whiteBalance
203 when: cam.mode == Camera.VideoMode
204 value: settings.videoWhiteBalance
208 target: cam.colorTone
210 when: cam.mode == Camera.ImageMode
211 value: settings.imageColorFilter
215 target: cam.colorTone
217 when: cam.mode == Camera.VideoMode
218 value: settings.videoColorFilter
224 when: cam.mode == Camera.ImageMode
225 value: settings.imageIso
231 when: cam.mode == Camera.ImageMode
236 target: cam.videoMute
238 value: settings.videoMuted
244 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
248 if (pipelineManager.error) {
249 // Ignore any subsequent errors.
250 // Killing pulseaudio while recording will lead to an
251 // infinite supply of errors which will break the UI
252 // if we show a banner for each.
256 pipelineManager.error = true
258 loader.item.cameraError()
261 console.log("Camera error (" + code + "): " + message + " " + debug)
262 showError(qsTr("Camera error. Please restart the application."))
263 // We cannot stop camera here. Seems there is a race condition somewhere
264 // which leads to a freeze if we do so.