Moved FocusReticle to Camera instead of CameraPage.
authorMohammed Sameer <msameer@foolab.org>
Thu, 20 Dec 2012 17:59:55 +0000 (19:59 +0200)
committerMohammed Sameer <msameer@foolab.org>
Thu, 20 Dec 2012 17:59:55 +0000 (19:59 +0200)
This makes it simpler to manage the state between VideoPage and RecordingPage

qml/CameraPage.qml
qml/FocusReticle.qml
qml/RecordingPage.qml
qml/main.qml

index b9d5780..d8d0d94 100644 (file)
@@ -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
index 564c6f2..d2eea6c 100644 (file)
@@ -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);
index 9bd1e8c..a7e233f 100644 (file)
@@ -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
index 127c36d..a2e0f74 100644 (file)
@@ -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."));