Added an option to enable using proximity sensor to capture
[harmattan/cameraplus] / qml / ImageOverlay.qml
index 1a889c9..99d9fb6 100644 (file)
@@ -42,7 +42,7 @@ Item {
         id: imageMode
         camera: cam
 
-        onCaptureEnded: cam.autoFocus.stopAutoFocus()
+        onCaptureEnded: stopAutoFocus()
 
         onPreviewAvailable: overlay.previewAvailable(preview)
 
@@ -77,12 +77,12 @@ Item {
         height: 75
         opacity: 0.5
         onClicked: captureImage()
-        visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
+        visible: controlsVisible
 
         onExited: {
             if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
                 // Release outside the button:
-                cam.autoFocus.stopAutoFocus()
+                stopAutoFocus()
             }
         }
     }
@@ -94,7 +94,7 @@ Item {
         repeat: false
         onTriggered: {
             if (cam.autoFocus.cafStatus != AutoFocus.Success) {
-                cam.autoFocus.startAutoFocus()
+                startAutoFocus()
             }
         }
     }
@@ -104,12 +104,13 @@ Item {
         onReleased: parent.captureImage()
     }
 
-    ZoomCaptureCancel {
+    CaptureCancel {
         anchors.fill: parent
-        zoomCapture: zoomCapture
-        onCanceled: {
+        enabled: zoomCapture.zoomPressed
+        onPressed: {
+            zoomCapture.zoomPressed = false
             if (!autoFocusTimer.running) {
-                cam.autoFocus.stopAutoFocus()
+                stopAutoFocus()
             }
         }
     }
@@ -128,6 +129,7 @@ Item {
         tools: CameraToolBarTools {
             FlashButton {
                 onClicked: toolBar.push(tools)
+                visible: !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
             }
 
             ImageSceneButton {
@@ -173,7 +175,7 @@ Item {
 
             Indicator {
                 id: flashIndicator
-                visible: !toolBar.expanded
+                visible: !toolBar.expanded && !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
                 source: cameraTheme.flashIcon(settings.imageFlashMode)
             }
 
@@ -184,8 +186,7 @@ Item {
                 anchors.rightMargin: 5
                 anchors.topMargin: 5
                 anchors.bottomMargin: 5
-                property string mp: imageSettings.currentResolutionMegapixel == "" ? "?" : imageSettings.currentResolutionMegapixel
-                text: qsTr("%1M").arg(mp)
+                text: imageSettings.currentResolution ? qsTr("%1M").arg(imageSettings.currentResolution.megaPixels) : qsTr("?M")
                 font.bold: true
                 verticalAlignment: Text.AlignVCenter
                 horizontalAlignment: Text.AlignHCenter
@@ -255,19 +256,19 @@ Item {
     function captureImage() {
         if (!imageMode.canCapture) {
             showError(qsTr("Camera is already capturing an image."))
-            cam.autoFocus.stopAutoFocus()
+            stopAutoFocus()
         } else if (!checkBattery()) {
             showError(qsTr("Not enough battery to capture images."))
-            cam.autoFocus.stopAutoFocus()
+            stopAutoFocus()
         } else if (!fileSystem.available) {
             showError(qsTr("Camera cannot capture images in mass storage mode."))
-            cam.autoFocus.stopAutoFocus()
+            stopAutoFocus()
         } else if (!fileSystem.hasFreeSpace(fileNaming.imagePath)) {
             showError(qsTr("Not enough space to capture images."))
-            cam.autoFocus.stopAutoFocus()
+            stopAutoFocus()
         } else if (!mountProtector.lock(fileNaming.imagePath)) {
             showError(qsTr("Failed to lock images directory."))
-            cam.autoFocus.stopAutoFocus()
+            stopAutoFocus()
         } else {
             metaData.setMetaData()
 
@@ -275,11 +276,32 @@ Item {
             if (!imageMode.capture(fileName)) {
                 showError(qsTr("Failed to capture image. Please restart the camera."))
                 mountProtector.unlock(fileNaming.imagePath)
-                cam.autoFocus.stopAutoFocus()
+                stopAutoFocus()
             } else {
                 trackerStore.storeImage(fileName)
             }
         }
     }
 
+    function startAutoFocus() {
+        if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
+            cam.autoFocus.startAutoFocus()
+        }
+    }
+
+    function stopAutoFocus() {
+        if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
+            cam.autoFocus.stopAutoFocus()
+        }
+    }
+
+    function resetToolBar() {
+        if (toolBar.depth() > 1) {
+            toolBar.pop()
+        }
+    }
+
+    function cameraDeviceChanged() {
+        resetToolBar()
+    }
 }