X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FCameraView.qml;h=c4463df63002f8e5b23026c7228f87fd293fc0cc;hp=80d5579c0ba151418cafc9921c66d267c782310e;hb=202fb5ef933fed92358921aeecf63ef0632a8ab6;hpb=c4646c0b1d0435d710af3feea6b550bd604b2aad diff --git a/qml/CameraView.qml b/qml/CameraView.qml index 80d5579..c4463df 100644 --- a/qml/CameraView.qml +++ b/qml/CameraView.qml @@ -20,55 +20,76 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -@IMPORT_QT_QUICK@ +import QtQuick 2.0 import QtCamera 1.0 import CameraPlus 1.0 -// TODO: reset reticle and roi when we stop camera or change mode -Camera { - id: cam - - property bool pressed: focusReticle.locked || (loader.item ? loader.item.pressed : false) +Viewfinder { + id: viewfinder + property bool pressed: focusReticle.locked || preview.animationRunning + || (loader.item ? loader.item.pressed : false) property int policyMode: loader.item ? loader.item.policyMode : CameraResources.None - renderingEnabled: mainView.currentItem == cam + camera: cam + cameraConfig: cam.cameraConfig + renderingEnabled: mainView.currentItem == viewfinder - function policyLost() { - if (loader.item) { - loader.item.policyLost() - } + Component.onDestruction: cam.stop() + + GridLines { + x: viewfinder.renderArea.x + y: viewfinder.renderArea.y + width: viewfinder.renderArea.width + height: viewfinder.renderArea.height + visible: settings.gridEnabled } - function checkBattery() { - // We are fine if we are connected to the charger: - if (batteryMonitor.charging) { - return true + Camera { + id: cam + sounds: Sounds { + id: sounds + mute: !settings.soundEnabled + volume: volumeControl.fullVolume ? Sounds.VolumeHigh : Sounds.VolumeLow + imageCaptureStart: platformSettings.imageCaptureStartedSound + imageCaptureEnd: platformSettings.imageCaptureEndedSound + videoRecordingStart: platformSettings.videoRecordingStartedSound + videoRecordingEnd: platformSettings.videoRecordingEndedSound + autoFocusAcquired: platformSettings.autoFocusAcquiredSound } - // If we have enough battery then we are fine: - if (!batteryMonitor.critical) { - return true + onFocusChanged: focus.value = Focus.ContinuousNormal + onRoiChanged: roi.normalize = false + + onRunningChanged: { + if (!cam.running) { + mountProtector.unlockAll() + } } - return false - } + onError: { + if (pipelineManager.error) { + // Ignore any subsequent errors. + // Killing pulseaudio while recording will lead to an + // infinite supply of errors which will break the UI + // if we show a banner for each. + return + } - Component.onDestruction: cam.stop() + pipelineManager.error = true + if (loader.item) { + loader.item.cameraError() + } - onRunningChanged: { - if (!cam.running) { - mountProtector.unlock() + console.log("Camera error (" + code + "): " + message + " " + debug) + showError(qsTr("Camera error. Please restart the application.")) + // We cannot stop camera here. Seems there is a race condition somewhere + // which leads to a freeze if we do so. } + } - sounds: Sounds { - id: sounds - mute: !settings.soundEnabled - imageCaptureStart: platformSettings.imageCaptureStartedSound - imageCaptureEnd: platformSettings.imageCaptureEndedSound - videoRecordingStart: platformSettings.videoRecordingStartedSound - videoRecordingEnd: platformSettings.videoRecordingEndedSound - autoFocusAcquired: platformSettings.autoFocusAcquiredSound + SoundVolumeControl { + id: volumeControl } BatteryInfo { @@ -94,6 +115,25 @@ Camera { id: preview } + FocusReticle { + id: focusReticle + cam: cam + videoResolution: viewfinder.videoResolution + renderArea: viewfinder.renderArea + + visible: loader.item != null && loader.item.controlsVisible && + cam.autoFocus.canFocus(cam.scene.value) + cafStatus: cam ? cam.autoFocus.cafStatus : -1 + status: cam ? cam.autoFocus.status : -1 + } + + Loader { + id: loader + property string src: cam.mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml" + anchors.fill: parent + source: Qt.resolvedUrl(src) + } + Connections { target: loader.item onPreviewAvailable: preview.setPreview(uri) @@ -113,32 +153,7 @@ Camera { when: loader.item != null } - onRoiChanged: roi.normalize = false - - GridLines { - x: cam.renderArea.x - y: cam.renderArea.y - width: cam.renderArea.width - height: cam.renderArea.height - visible: settings.gridEnabled - } - - FocusReticle { - id: focusReticle - cam: cam - visible: loader.item != null && loader.item.controlsVisible && - cam.autoFocus.canFocus(cam.scene.value) - cafStatus: cam ? cam.autoFocus.cafStatus : -1 - status: cam ? cam.autoFocus.status : -1 - } - - Loader { - id: loader - property string src: mode == Camera.VideoMode ? "VideoOverlay.qml" : "ImageOverlay.qml" - anchors.fill: parent - source: Qt.resolvedUrl(src) - } - + /* Camera bindings */ Binding { target: cam.flash property: "value" @@ -249,24 +264,23 @@ Camera { value: settings.faceDetectionEnabled && !focusReticle.pressed && !focusReticle.touchMode && cam.mode == Camera.ImageMode } - onError: { - if (pipelineManager.error) { - // Ignore any subsequent errors. - // Killing pulseaudio while recording will lead to an - // infinite supply of errors which will break the UI - // if we show a banner for each. - return + function policyLost() { + if (loader.item) { + loader.item.policyLost() } + } - pipelineManager.error = true - if (loader.item) { - loader.item.cameraError() + function checkBattery() { + // We are fine if we are connected to the charger: + if (batteryMonitor.charging) { + return true } - console.log("Camera error (" + code + "): " + message + " " + debug) - showError(qsTr("Camera error. Please restart the application.")) - // We cannot stop camera here. Seems there is a race condition somewhere - // which leads to a freeze if we do so. - } + // If we have enough battery then we are fine: + if (!batteryMonitor.critical) { + return true + } + return false + } }