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()
70 mute: !settings.soundEnabled
71 volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
72 imageCaptureStart: platformSettings.imageCaptureStartedSound
73 imageCaptureEnd: platformSettings.imageCaptureEndedSound
74 videoRecordingStart: platformSettings.videoRecordingStartedSound
75 videoRecordingEnd: platformSettings.videoRecordingEndedSound
76 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
84 if (!checkBattery()) {
85 loader.item.batteryLow()
90 batteryMonitor.check()
94 batteryMonitor.check()
104 onPreviewAvailable: preview.setPreview(uri)
111 when: loader.item != null
116 property: "animationRunning"
117 value: preview.animationRunning
118 when: loader.item != null
121 onRoiChanged: roi.normalize = false
126 width: cam.renderArea.width
127 height: cam.renderArea.height
128 visible: settings.gridEnabled
134 visible: loader.item != null && loader.item.controlsVisible &&
135 cam.autoFocus.canFocus(cam.scene.value)
136 cafStatus: cam ? cam.autoFocus.cafStatus : -1
137 status: cam ? cam.autoFocus.status : -1
142 property string src: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
144 source: Qt.resolvedUrl(src)
150 when: cam.mode == Camera.ImageMode
151 value: settings.imageFlashMode
156 property: "imageFlashMode"
157 when: cam.mode == Camera.ImageMode
158 value: cam.flash.value
164 when: cam.mode == Camera.VideoMode
165 value: settings.videoSceneMode
171 when: cam.mode == Camera.ImageMode
172 value: settings.imageSceneMode
178 when: cam.mode == Camera.ImageMode
179 value: settings.imageEvComp
185 when: cam.mode == Camera.VideoMode
186 value: settings.videoEvComp
191 property: "imageEvComp"
192 when: cam.mode == Camera.ImageMode
193 value: cam.evComp.value
198 property: "videoEvComp"
199 when: cam.mode == Camera.VideoMode
200 value: cam.evComp.value
204 target: cam.whiteBalance
206 when: cam.mode == Camera.ImageMode
207 value: settings.imageWhiteBalance
211 target: cam.whiteBalance
213 when: cam.mode == Camera.VideoMode
214 value: settings.videoWhiteBalance
218 target: cam.colorTone
220 when: cam.mode == Camera.ImageMode
221 value: settings.imageColorFilter
225 target: cam.colorTone
227 when: cam.mode == Camera.VideoMode
228 value: settings.videoColorFilter
234 when: cam.mode == Camera.ImageMode
235 value: settings.imageIso
241 when: cam.mode == Camera.ImageMode
246 target: cam.videoMute
248 value: settings.videoMuted
254 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
258 if (pipelineManager.error) {
259 // Ignore any subsequent errors.
260 // Killing pulseaudio while recording will lead to an
261 // infinite supply of errors which will break the UI
262 // if we show a banner for each.
266 pipelineManager.error = true
268 loader.item.cameraError()
271 console.log("Camera error (" + code + "): " + message + " " + debug)
272 showError(qsTr("Camera error. Please restart the application."))
273 // We cannot stop camera here. Seems there is a race condition somewhere
274 // which leads to a freeze if we do so.