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
42 cameraConfig: cam.cameraConfig
44 renderingEnabled: mainView.currentItem == cam
47 x: viewfinder.renderArea.x
48 y: viewfinder.renderArea.y
49 width: viewfinder.renderArea.width
50 height: viewfinder.renderArea.height
51 visible: settings.gridEnabled
55 function policyLost() {
57 loader.item.policyLost()
61 function checkBattery() {
62 // We are fine if we are connected to the charger:
63 if (batteryMonitor.charging) {
67 // If we have enough battery then we are fine:
68 if (!batteryMonitor.critical) {
75 Component.onDestruction: cam.stop()
79 mountProtector.unlock()
89 mute: !settings.soundEnabled
90 volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow
91 imageCaptureStart: platformSettings.imageCaptureStartedSound
92 imageCaptureEnd: platformSettings.imageCaptureEndedSound
93 videoRecordingStart: platformSettings.videoRecordingStartedSound
94 videoRecordingEnd: platformSettings.videoRecordingEndedSound
95 autoFocusAcquired: platformSettings.autoFocusAcquiredSound
103 if (!checkBattery()) {
104 loader.item.batteryLow()
109 batteryMonitor.check()
113 batteryMonitor.check()
123 onPreviewAvailable: preview.setPreview(uri)
130 when: loader.item != null
135 property: "animationRunning"
136 value: preview.animationRunning
137 when: loader.item != null
140 onRoiChanged: roi.normalize = false
145 videoResolution: viewfinder.videoResolution
146 renderArea: viewfinder.renderArea
148 visible: loader.item != null && loader.item.controlsVisible &&
149 cam.autoFocus.canFocus(cam.scene.value)
150 cafStatus: cam ? cam.autoFocus.cafStatus : -1
151 status: cam ? cam.autoFocus.status : -1
156 property string src: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml"
158 source: Qt.resolvedUrl(src)
164 when: cam.mode == Camera.ImageMode
165 value: settings.imageFlashMode
170 property: "imageFlashMode"
171 when: cam.mode == Camera.ImageMode
172 value: cam.flash.value
178 when: cam.mode == Camera.VideoMode
179 value: settings.videoSceneMode
185 when: cam.mode == Camera.ImageMode
186 value: settings.imageSceneMode
192 when: cam.mode == Camera.ImageMode
193 value: settings.imageEvComp
199 when: cam.mode == Camera.VideoMode
200 value: settings.videoEvComp
205 property: "imageEvComp"
206 when: cam.mode == Camera.ImageMode
207 value: cam.evComp.value
212 property: "videoEvComp"
213 when: cam.mode == Camera.VideoMode
214 value: cam.evComp.value
218 target: cam.whiteBalance
220 when: cam.mode == Camera.ImageMode
221 value: settings.imageWhiteBalance
225 target: cam.whiteBalance
227 when: cam.mode == Camera.VideoMode
228 value: settings.videoWhiteBalance
232 target: cam.colorTone
234 when: cam.mode == Camera.ImageMode
235 value: settings.imageColorFilter
239 target: cam.colorTone
241 when: cam.mode == Camera.VideoMode
242 value: settings.videoColorFilter
248 when: cam.mode == Camera.ImageMode
249 value: settings.imageIso
255 when: cam.mode == Camera.ImageMode
260 target: cam.videoMute
262 value: settings.videoMuted
268 value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode
272 if (pipelineManager.error) {
273 // Ignore any subsequent errors.
274 // Killing pulseaudio while recording will lead to an
275 // infinite supply of errors which will break the UI
276 // if we show a banner for each.
280 pipelineManager.error = true
282 loader.item.cameraError()
285 console.log("Camera error (" + code + "): " + message + " " + debug)
286 showError(qsTr("Camera error. Please restart the application."))
287 // We cannot stop camera here. Seems there is a race condition somewhere
288 // which leads to a freeze if we do so.