Disable viewfinder in settings pages
[harmattan/cameraplus] / qml / CameraPage.qml
index a0620f0..98503cf 100644 (file)
@@ -29,8 +29,6 @@ import QtMobility.systeminfo 1.2
 Page {
         id: page
 
-        property alias standbyWidget: standby
-
         property bool needsPipeline: true
         property int policyMode: CameraResources.None
 
@@ -39,120 +37,63 @@ Page {
         property bool zoomVisible: true
         property bool modesVisible: true
         property bool standbyVisible: true
-
-        anchors.fill: parent
+        property bool focusReticleVisible: true
+        property bool enableViewfinder: true
 
         property alias previewAnimationRunning: preview.animationRunning
 
         signal batteryLow
 
-        function updatePolicy() {
-                if (!resourcePolicy.acquire(page.policyMode)) {
-                        cam.stop(true);
-                }
-                else {
-                        handlePipeline();
-                }
+        function cameraError() {
+                // Nothing
         }
 
-        Component.onCompleted: {
-                if (Qt.application.active && needsPipeline) {
-                        updatePolicy();
-                }
-                else if (!needsPipeline) {
-                        cam.stop();
-                }
+        function policyLost() {
+                // Nothing
         }
 
         onStatusChanged: {
-                if (Qt.application.active && status == PageStatus.Activating) {
-                        updatePolicy();
-                }
-        }
-/*
-        onStatusChanged: {
-                if (status == PageStatus.Active && !page.needsPipeline) {
-                        cam.stop();
+                if (status == PageStatus.Activating && enableViewfinder) {
+                        cam.renderingEnabled = true;
                 }
-        }
-*/
-
-        onPolicyModeChanged: {
-                if (Qt.application.active) {
-                        updatePolicy();
-                }
-        }
+                else if (status == PageStatus.Active) {
+                        focusReticle.setRegionOfInterest();
 
-        function handlePipeline() {
-                var acquired = resourcePolicy.acquired;
-                var hijacked = resourcePolicy.hijacked;
-
-                if (hijacked) {
-                        cam.stop(true);
-                        showError(qsTr("Resources lost. Stopping camera."));
-                }
-                else if (!Qt.application.active && !acquired) {
-                        // I don't think this is needed
-                        cam.stop(true);
-                }
-                else if (!Qt.application.active) {
-                        cam.stop();
-                }
-                else if (acquired && page.needsPipeline && !cam.running) {
-                        if (!cam.start()) {
-                                showError(qsTr("Failed to start camera. Please restart the application."));
+                        if (!enableViewfinder) {
+                                cam.renderingEnabled = false;
                         }
                 }
         }
 
-        Connections {
-                target: resourcePolicy
-                onHijackedChanged: handlePipeline();
-                onAcquiredChanged: handlePipeline();
-        }
-
-        Connections {
-                target: Qt.application
-                onActiveChanged: {
-                        if (!Qt.application.active) {
-                                // This is a noop if camera is not
-                                // idle so calling it will not hurt
-                                if (cam.stop()) {
-                                        resourcePolicy.acquire(CameraResources.None);
-                                }
-                        }
-                        else if (page.needsPipeline) {
-                                updatePolicy();
-                        }
-                }
-        }
-
-        Connections {
-                target: cam
-                onIdleChanged: {
-                        if (cam.idle && !Qt.application.active) {
-                                cam.stop();
-                                resourcePolicy.acquire(CameraResources.None);
-                        }
-/*
-                        else if (cam.idle && !page.needsPipeline) {
-                                cam.stop();
-                        }
-*/
-                }
-        }
-
         Rectangle {
                 // TODO: fade out transition
                 // TODO: there is a toolbar visible on the first startup
                 id: standby
                 color: "black"
                 anchors.fill: parent
-                visible: standbyVisible && page.status == PageStatus.Active && (!Qt.application.active || !cam.running || !resourcePolicy.acquired)
+                visible: standbyVisible && page.status == PageStatus.Active && pipelineManager.showStandBy
+                z: 2
+                MouseArea {
+                        anchors.fill: parent
+                        enabled: parent.visible
+                }
+
                 Image {
+                        id: icon
                         source: "image://theme/icon-l-camera-standby"
                         anchors.centerIn: parent
                 }
+
+                Label {
+                        anchors.top: icon.bottom
+                        anchors.right: parent.right
+                        anchors.left: parent.left
+                        text: qsTr("Resources lost")
+                        color: "white"
+                        font.pixelSize: 36
+                        horizontalAlignment: Text.AlignHCenter
+                        visible: pipelineManager.state == "policyLost"
+                }
         }
 
         function setPreview(image) {