From 3c30a5ec571562a13242414c1a069adcc9e869ef Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Thu, 20 Dec 2012 19:59:55 +0200 Subject: [PATCH] Moved FocusReticle to Camera instead of CameraPage. This makes it simpler to manage the state between VideoPage and RecordingPage --- qml/CameraPage.qml | 7 ------- qml/FocusReticle.qml | 40 +++++++++++++++++++++++++++++++++------- qml/RecordingPage.qml | 1 - qml/main.qml | 15 +++++++++++---- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/qml/CameraPage.qml b/qml/CameraPage.qml index b9d5780..d8d0d94 100644 --- a/qml/CameraPage.qml +++ b/qml/CameraPage.qml @@ -59,13 +59,6 @@ Page { } } - FocusReticle { - visible: controlsVisible && focusReticleVisible && cam.autoFocus.canFocus(cam.scene.value); - id: focusReticle - cafStatus: cam.autoFocus.cafStatus - status: cam.autoFocus.status - } - Rectangle { // TODO: fade out transition // TODO: there is a toolbar visible on the first startup diff --git a/qml/FocusReticle.qml b/qml/FocusReticle.qml index 564c6f2..d2eea6c 100644 --- a/qml/FocusReticle.qml +++ b/qml/FocusReticle.qml @@ -25,9 +25,14 @@ import QtCamera 1.0 import CameraPlus 1.0 // TODO: I've seen the reticle color changing to red while dragging it but failed to reproduce :( +// TODO: animate move +// TODO: hide all controls when we are focusing +// TODO: hide all controls when we are dragging + MouseArea { property int cafStatus: AutoFocus.None property int status: AutoFocus.None + property Camera cam: null id: mouse // A 100x100 central "rectangle" @@ -35,14 +40,30 @@ MouseArea { property alias touchMode: reticle.touchMode - x: cam.renderArea.x - y: cam.renderArea.y - width: cam.renderArea.width - height: cam.renderArea.height - - // Changing mode (which implies changing pages) will not reset ROI thus we do it here - Component.onCompleted: cam.autoFocus.setRegionOfInterest(Qt.rect(0, 0, 0, 0)); + x: cam ? cam.renderArea.x : 0 + y: cam ? cam.renderArea.y : 0 + width: cam ? cam.renderArea.width : 0 + height: cam ? cam.renderArea.height : 0 + + Connections { + target: settings + // Changing mode (which implies changing pages) will not reset ROI + // thus we do it here + onModeChanged: { + moveToCenter(); + cam.autoFocus.setRegionOfInterest(Qt.rect(0, 0, 0, 0)); + } + } + Connections { + target: cam + onRunningChanged: { + if (!cam.running) { + moveToCenter(); + cam.autoFocus.setRegionOfInterest(Qt.rect(0, 0, 0, 0)); + } + } + } /* // This is for debugging Rectangle { @@ -91,6 +112,11 @@ MouseArea { } } + function moveToCenter() { + reticle.x = reticle.center.x; + reticle.y = reticle.center.y; + } + function moveReticle(x, y) { var xPos = x - ((reticle.width * 1) / 2); var yPos = y - ((reticle.height * 1) / 2); diff --git a/qml/RecordingPage.qml b/qml/RecordingPage.qml index 9bd1e8c..a7e233f 100644 --- a/qml/RecordingPage.qml +++ b/qml/RecordingPage.qml @@ -30,7 +30,6 @@ import "data.js" as Data // TODO: resources lost? // TODO: closing camera in the middle of recording will hang camera // TODO: optional resources? -// TODO: get touch focus settings from VideoPage CameraPage { id: page diff --git a/qml/main.qml b/qml/main.qml index 127c36d..a2e0f74 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -30,7 +30,6 @@ import QtMobility.location 1.2 // TODO: postcapture // TODO: flash not ready -// TODO: touch focus // TODO: portrait/landscape // TODO: stop viewfinder in settings pages ? // TODO: grid lines, face tracking, ambr @@ -214,6 +213,17 @@ PageStackWindow { } Camera { + id: cam + anchors.fill: parent + + FocusReticle { + id: focusReticle + cam: cam + visible: pageStack.currentPage && pageStack.currentPage.controlsVisible && pageStack.currentPage.focusReticleVisible && cam && cam.autoFocus.canFocus(cam.scene.value); + cafStatus: cam ? cam.autoFocus.cafStatus : -1 + status: cam ? cam.autoFocus.status : -1 + } + /* onDeviceIdChanged: { // TODO: is this needed ? @@ -222,9 +232,6 @@ PageStackWindow { } } */ - id: cam - anchors.fill: parent - onError: { console.log("Camera error (" + code + "): " + message + " " + debug); showError(qsTr("Camera error. Please restart the application.")); -- 2.25.1