Switch toolbar animation to opacity
[harmattan/cameraplus] / qml / ImageOverlay.qml
index 5b08ecb..f191b35 100644 (file)
@@ -41,12 +41,12 @@ Item {
     ImageMode {
         id: imageMode
         camera: cam
-        onPreviewAvailable: {
-            overlay.previewAvailable(preview)
-            cam.autoFocus.stopAutoFocus()
-        }
 
-        onSaved: mountProtector.unlock()
+        onCaptureEnded: stopAutoFocus()
+
+        onPreviewAvailable: overlay.previewAvailable(preview)
+
+        onSaved: mountProtector.unlock(fileNaming.imagePath)
     }
 
     ZoomSlider {
@@ -72,17 +72,16 @@ Item {
         anchors.right: parent.right
         anchors.rightMargin: 20
         anchors.verticalCenter: parent.verticalCenter
-        iconId: cameraTheme.captureButtonImageIconId
+        iconSource: cameraTheme.captureButtonImageIconId
         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:
-                cam.autoFocus.stopAutoFocus()
+                captureControl.canceled = true
             }
         }
     }
@@ -90,28 +89,32 @@ Item {
     Timer {
         id: autoFocusTimer
         interval: 200
-        running: capture.pressed || zoomCapture.zoomPressed
+        running: captureControl.state == "capturing"
         repeat: false
         onTriggered: {
             if (cam.autoFocus.cafStatus != AutoFocus.Success) {
-                cam.autoFocus.startAutoFocus()
+                startAutoFocus()
             }
         }
     }
 
     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) {
-                cam.autoFocus.stopAutoFocus()
-            }
-        }
+        enabled: captureControl.showCancelBanner
+        onPressed:  captureControl.canceled = true
     }
 
     CameraToolBar {
@@ -128,6 +131,7 @@ Item {
         tools: CameraToolBarTools {
             FlashButton {
                 onClicked: toolBar.push(tools)
+                visible: !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
             }
 
             ImageSceneButton {
@@ -173,32 +177,45 @@ Item {
 
             Indicator {
                 id: flashIndicator
-                source: "image://theme/" + cameraTheme.flashIcon(settings.imageFlashMode) + "-screen"
+                visible: !toolBar.expanded && !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
+                source: cameraTheme.flashIcon(settings.imageFlashMode)
             }
 
-            Indicator {
-                id: resolutionIndicator
-                property string imageAspectRatio: settings.device == 1 ? settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio
-                property string imageResolution: settings.device == 1 ? settings.secondaryImageResolution : settings.primaryImageResolution
-                source: "image://theme/" + cameraTheme.imageIcon(imageAspectRatio, imageResolution, settings.device)
+            CameraLabel {
+                anchors.left: parent.left
+                anchors.right: parent.right
+                anchors.leftMargin: 5
+                anchors.rightMargin: 5
+                anchors.topMargin: 5
+                anchors.bottomMargin: 5
+                text: imageSettings.currentResolution ? qsTr("%1M").arg(imageSettings.currentResolution.megaPixels) : qsTr("?M")
+                font.bold: true
+                verticalAlignment: Text.AlignVCenter
+                horizontalAlignment: Text.AlignHCenter
             }
 
             Indicator {
                 id: wbIndicator
-                source: visible ? "image://theme/" + cameraTheme.whiteBalanceIcon(settings.imageWhiteBalance) + "-screen" : ""
-                visible: settings.imageWhiteBalance != WhiteBalance.Auto
+                source: visible ? cameraTheme.whiteBalanceIcon(settings.imageWhiteBalance) : ""
+                visible: settings.imageWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
             }
 
             Indicator {
                 id: cfIndicator
-                source: "image://theme/" + cameraTheme.colorFilterIcon(settings.imageColorFilter) + "-screen"
-                visible: settings.imageColorFilter != ColorTone.Normal
+                source: visible ? cameraTheme.colorFilterIcon(settings.imageColorFilter) : ""
+                visible: settings.imageColorFilter != ColorTone.Normal && !toolBar.expanded
             }
 
             Indicator {
                 id: isoIndicator
-                visible: settings.imageIso != 0
-                source: "image://theme/" + cameraTheme.isoIcon(settings.imageIso)
+                visible: settings.imageIso != 0 && !toolBar.expanded
+                source: visible ? cameraTheme.isoIcon(settings.imageIso) : ""
+            }
+
+            Indicator {
+                id: sceneIndicator
+                visible: settings.imageSceneMode != Scene.Auto && !toolBar.expanded
+                source: visible ? cameraTheme.imageSceneModeIcon(settings.imageSceneMode) : ""
             }
 
             Indicator {
@@ -227,7 +244,7 @@ Item {
     }
 
     function cameraError() {
-        mountProtector.unlock()
+        mountProtector.unlock(fileNaming.imagePath)
     }
 
     function policyLost() {
@@ -241,25 +258,54 @@ Item {
     function captureImage() {
         if (!imageMode.canCapture) {
             showError(qsTr("Camera is already capturing an image."))
+            stopAutoFocus()
         } else if (!checkBattery()) {
             showError(qsTr("Not enough battery to capture images."))
+            stopAutoFocus()
         } else if (!fileSystem.available) {
             showError(qsTr("Camera cannot capture images in mass storage mode."))
-        } else if (!checkDiskSpace()) {
+            stopAutoFocus()
+        } else if (!fileSystem.hasFreeSpace(fileNaming.imagePath)) {
             showError(qsTr("Not enough space to capture images."))
-        } else if (!mountProtector.lock()) {
+            stopAutoFocus()
+        } else if (!mountProtector.lock(fileNaming.imagePath)) {
             showError(qsTr("Failed to lock images directory."))
+            stopAutoFocus()
         } else {
             metaData.setMetaData()
 
             var fileName = fileNaming.imageFileName()
             if (!imageMode.capture(fileName)) {
                 showError(qsTr("Failed to capture image. Please restart the camera."))
-                mountProtector.unlock()
+                mountProtector.unlock(fileNaming.imagePath)
+                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)) {
+            if (!autoFocusTimer.running) {
+                cam.autoFocus.stopAutoFocus()
+            }
+        }
+    }
+
+    function resetToolBar() {
+        if (toolBar.depth() > 1) {
+            toolBar.pop()
+        }
+    }
+
+    function cameraDeviceChanged() {
+        resetToolBar()
+    }
 }