Don't disable GPS when we are obscured by location-ui or conndlgs
[harmattan/cameraplus] / qml / ImageOverlay.qml
index 415a0c3..ec1ee83 100644 (file)
@@ -33,6 +33,7 @@ Item {
     property bool pressed: capture.pressed || zoomSlider.pressed || modeButton.pressed
     property bool controlsVisible: imageMode.canCapture && cam.running && !animationRunning
         && dimmer.opacity == 0.0 && !cameraMode.busy
+    property bool inhibitDim: false
 
     signal previewAvailable(string uri)
 
@@ -76,13 +77,12 @@ Item {
         width: 75
         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:
-                stopAutoFocus()
+                captureControl.canceled = true
             }
         }
     }
@@ -90,7 +90,7 @@ Item {
     Timer {
         id: autoFocusTimer
         interval: 200
-        running: capture.pressed || zoomCapture.zoomPressed
+        running: captureControl.state == "capturing"
         repeat: false
         onTriggered: {
             if (cam.autoFocus.cafStatus != AutoFocus.Success) {
@@ -101,17 +101,21 @@ Item {
 
     ZoomCaptureButton {
         id: zoomCapture
-        onReleased: parent.captureImage()
     }
 
-    ZoomCaptureCancel {
+    CaptureControl {
+        id: captureControl
+        capturePressed: capture.pressed
+        zoomPressed: zoomCapture.zoomPressed
+        proximityClosed: proximitySensor.close
+        onStartCapture: captureImage()
+        onCancelCapture: stopAutoFocus()
+    }
+
+    CaptureCancel {
         anchors.fill: parent
-        zoomCapture: zoomCapture
-        onCanceled: {
-            if (!autoFocusTimer.running) {
-                stopAutoFocus()
-            }
-        }
+        enabled: captureControl.showCancelBanner
+        onPressed:  captureControl.canceled = true
     }
 
     CameraToolBar {
@@ -128,6 +132,7 @@ Item {
         tools: CameraToolBarTools {
             FlashButton {
                 onClicked: toolBar.push(tools)
+                visible: !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
             }
 
             ImageSceneButton {
@@ -173,7 +178,7 @@ Item {
 
             Indicator {
                 id: flashIndicator
-                visible: !toolBar.expanded
+                visible: !toolBar.expanded && !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
                 source: cameraTheme.flashIcon(settings.imageFlashMode)
             }
 
@@ -184,8 +189,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
@@ -283,15 +287,26 @@ Item {
     }
 
     function startAutoFocus() {
-        if (cam.device == 0) {
+        if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
             cam.autoFocus.startAutoFocus()
         }
     }
 
     function stopAutoFocus() {
-        if (cam.device == 0) {
-            cam.autoFocus.stopAutoFocus()
+        if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
+            if (!autoFocusTimer.running) {
+                cam.autoFocus.stopAutoFocus()
+            }
         }
     }
 
+    function resetToolBar() {
+        if (toolBar.depth() > 1) {
+            toolBar.pop()
+        }
+    }
+
+    function cameraDeviceChanged() {
+        resetToolBar()
+    }
 }