Reset toolbar when device gets changed
[harmattan/cameraplus] / qml / VideoOverlay.qml
index b80b715..48ce2ff 100644 (file)
@@ -104,10 +104,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)
             }
 
@@ -215,7 +217,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."))
             }
@@ -228,6 +230,12 @@ Item {
         duration: recordingDuration.duration
     }
 
+    function resetToolBar() {
+        if (toolBar.depth() > 1) {
+            toolBar.pop()
+        }
+    }
+
     function doStartRecording() {
         if (!overlay.recording) {
             return
@@ -241,27 +249,32 @@ 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
+        }
+
         var file = fileNaming.videoFileName()
         var tmpFile = fileNaming.temporaryVideoFileName()
 
         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);
 
-        if (toolBar.depth() > 1) {
-            toolBar.pop()
-        }
+        resetToolBar()
     }
 
     function startRecording() {
@@ -269,7 +282,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
@@ -280,7 +293,7 @@ Item {
 
     function stopRecording() {
         videoMode.stopRecording(true)
-        mountProtector.unlock()
+        mountProtector.unlockAll()
         overlay.recording = false
     }
 
@@ -311,4 +324,7 @@ Item {
         }
     }
 
+    function cameraDeviceChanged() {
+        resetToolBar()
+    }
 }