Switch toolbar animation to opacity
[harmattan/cameraplus] / qml / VideoOverlay.qml
index 3dbc726..164ebae 100644 (file)
@@ -66,12 +66,20 @@ Item {
 
     ZoomCaptureButton {
         id: zoomCapture
-        onReleased: overlay.toggleRecording()
     }
 
-    ZoomCaptureCancel {
+    CaptureControl {
+        id: captureControl
+        capturePressed: capture.pressed
+        zoomPressed: zoomCapture.zoomPressed
+        proximityClosed: proximitySensor.close
+        onStartCapture: overlay.toggleRecording()
+    }
+
+    CaptureCancel {
         anchors.fill: parent
-        zoomCapture: zoomCapture
+        enabled: captureControl.showCancelBanner
+        onPressed: captureControl.canceled = true
     }
 
     CaptureButton {
@@ -79,14 +87,19 @@ Item {
         anchors.right: parent.right
         anchors.rightMargin: 20
         anchors.verticalCenter: parent.verticalCenter
-        iconId: overlay.recording ? cameraTheme.captureButtonRecordingIconId : cameraTheme.captureButtonVideoIconId
+        iconSource: overlay.recording ? cameraTheme.captureButtonRecordingIconId : cameraTheme.captureButtonVideoIconId
         width: 75
         height: 75
         opacity: 0.5
 
-        onClicked: overlay.toggleRecording()
+        visible: controlsVisible
 
-        visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
+        onExited: {
+            if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
+                // Release outside the button:
+                captureControl.canceled = true
+            }
+        }
     }
 
     CameraToolBar {
@@ -104,10 +117,12 @@ Item {
         tools: CameraToolBarTools {
             VideoTorchButton {
                 camera: cam
+                visible: !overlay.cam.quirks.hasQuirk(Quirks.NoVideoTorch)
             }
 
             VideoSceneButton {
-                visible: !overlay.recording
+                property bool hide: (overlay.recording && overlay.cam.quirks.hasQuirk(Quirks.NoSceneModeChangeDuringRecording)) || overlay.cam.quirks.hasQuirk(Quirks.NoNightSceneMode)
+                visible: !hide
                 onClicked: toolBar.push(tools)
             }
 
@@ -148,21 +163,26 @@ Item {
 
             Indicator {
                 id: resolutionIndicator
-                property string videoResolution: settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
-                property string videoRatio: settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
-                source: "image://theme/" + cameraTheme.videoIcon(videoRatio, videoResolution, settings.device)
+                source: cameraTheme.videoIcon(settings.videoAspectRatio,
+                    settings.videoResolution, settings.device)
             }
 
             Indicator {
                 id: wbIndicator
-                source: visible ? "image://theme/" + cameraTheme.whiteBalanceIcon(settings.videoWhiteBalance) + "-screen" : ""
-                visible: settings.videoWhiteBalance != WhiteBalance.Auto
+                source: visible ? cameraTheme.whiteBalanceIcon(settings.videoWhiteBalance) : ""
+                visible: settings.videoWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
             }
 
             Indicator {
                 id: cfIndicator
-                source: "image://theme/" + cameraTheme.colorFilterIcon(settings.videoColorFilter) + "-screen"
-                visible: settings.videoColorFilter != ColorTone.Normal
+                source: visible ? cameraTheme.colorFilterIcon(settings.videoColorFilter) : ""
+                visible: settings.videoColorFilter != ColorTone.Normal && !toolBar.expanded
+            }
+
+            Indicator {
+                id: sceneIndicator
+                visible: settings.videoSceneMode != Scene.Auto && (!toolBar.expanded || overlay.recording)
+                source: visible ? cameraTheme.videoSceneModeIcon(settings.videoSceneMode) : ""
             }
 
             Indicator {
@@ -209,7 +229,7 @@ Item {
             if (duration == 3600) {
                 overlay.stopRecording()
                 showError(qsTr("Maximum recording time reached."))
-            } else if (!checkDiskSpace()) {
+            } else if (!fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
                 page.stopRecording()
                 showError(qsTr("Not enough space to continue recording."))
             }
@@ -222,6 +242,12 @@ Item {
         duration: recordingDuration.duration
     }
 
+    function resetToolBar() {
+        if (toolBar.depth() > 1) {
+            toolBar.pop()
+        }
+    }
+
     function doStartRecording() {
         if (!overlay.recording) {
             return
@@ -235,9 +261,16 @@ Item {
 
         metaData.setMetaData()
 
-        if (!mountProtector.lock()) {
-            showError(qsTr("Failed to lock images directory."))
+        if (!mountProtector.lock(fileNaming.temporaryVideoPath)) {
+            showError(qsTr("Failed to lock temporary videos directory."))
+            overlay.recording = false
+            return
+        }
+
+        if (!mountProtector.lock(fileNaming.videoPath)) {
+            showError(qsTr("Failed to lock videos directory."))
             overlay.recording = false
+            mountProtector.unlockAll()
             return
         }
 
@@ -246,12 +279,14 @@ Item {
 
         if (!videoMode.startRecording(file, tmpFile)) {
             showError(qsTr("Failed to record video. Please restart the camera."))
-            mountProtector.unlock()
+            mountProtector.unlockAll()
             overlay.recording = false
             return
         }
 
         trackerStore.storeVideo(file);
+
+        resetToolBar()
     }
 
     function startRecording() {
@@ -259,7 +294,7 @@ Item {
             showError(qsTr("Camera cannot record videos in mass storage mode."))
         } else if (!checkBattery()) {
             showError(qsTr("Not enough battery to record video."))
-        } else if (!checkDiskSpace()) {
+        } else if (!fileSystem.hasFreeSpace(fileNaming.videoPath) || !fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
             showError(qsTr("Not enough space to record video."))
         } else {
             recordingDuration.duration = 0
@@ -270,7 +305,7 @@ Item {
 
     function stopRecording() {
         videoMode.stopRecording(true)
-        mountProtector.unlock()
+        mountProtector.unlockAll()
         overlay.recording = false
     }
 
@@ -301,4 +336,7 @@ Item {
         }
     }
 
+    function cameraDeviceChanged() {
+        resetToolBar()
+    }
 }