Activated the option to disable capture previews
[harmattan/cameraplus] / qml / VideoOverlay.qml
index b80b715..2d55bb7 100644 (file)
@@ -35,6 +35,7 @@ Item {
         && dimmer.opacity == 0.0 && !cameraMode.busy
     property bool pressed: overlay.recording || capture.pressed ||
         zoomSlider.pressed || modeButton.pressed
+    property bool inhibitDim: recording
 
     signal previewAvailable(string uri)
 
@@ -43,6 +44,7 @@ Item {
     VideoMode {
         id: videoMode
         camera: cam
+        enablePreview: settings.enablePreview
         onPreviewAvailable: overlay.previewAvailable(preview)
     }
 
@@ -66,12 +68,20 @@ Item {
 
     ZoomCaptureButton {
         id: zoomCapture
-        onReleased: overlay.toggleRecording()
     }
 
-    ZoomCaptureCancel {
+    CaptureControl {
+        id: captureControl
+        capturePressed: capture.pressed
+        zoomPressed: zoomCapture.zoomPressed
+        proximityClosed: proximitySensor.sensorClosed
+        onStartCapture: overlay.toggleRecording()
+    }
+
+    CaptureCancel {
         anchors.fill: parent
-        zoomCapture: zoomCapture
+        enabled: captureControl.showCancelBanner
+        onPressed: captureControl.canceled = true
     }
 
     CaptureButton {
@@ -84,9 +94,14 @@ Item {
         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 +119,12 @@ Item {
         tools: CameraToolBarTools {
             VideoTorchButton {
                 camera: cam
+                visible: overlay.cam ? !overlay.cam.quirks.hasQuirk(Quirks.NoVideoTorch) : false
             }
 
             VideoSceneButton {
-                visible: !overlay.recording
+                property bool hide: overlay.cam ? (overlay.recording && overlay.cam.quirks.hasQuirk(Quirks.NoSceneModeChangeDuringRecording)) || overlay.cam.quirks.hasQuirk(Quirks.NoNightSceneMode) : false
+                visible: !hide
                 onClicked: toolBar.push(tools)
             }
 
@@ -148,9 +165,8 @@ 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: cameraTheme.videoIcon(videoRatio, videoResolution, settings.device)
+                source: cameraTheme.videoIcon(settings.videoAspectRatio,
+                    settings.videoResolution, settings.device)
             }
 
             Indicator {
@@ -189,10 +205,6 @@ Item {
         }
     }
 
-    DisplayState {
-        inhibitDim: overlay.recording
-    }
-
     Connections {
         target: Qt.application
         onActiveChanged: {
@@ -215,7 +227,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 +240,12 @@ Item {
         duration: recordingDuration.duration
     }
 
+    function resetToolBar() {
+        if (toolBar.depth() > 1) {
+            toolBar.pop()
+        }
+    }
+
     function doStartRecording() {
         if (!overlay.recording) {
             return
@@ -241,9 +259,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
         }
 
@@ -252,16 +277,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);
 
-        if (toolBar.depth() > 1) {
-            toolBar.pop()
-        }
+        resetToolBar()
     }
 
     function startRecording() {
@@ -269,7 +292,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 +303,7 @@ Item {
 
     function stopRecording() {
         videoMode.stopRecording(true)
-        mountProtector.unlock()
+        mountProtector.unlockAll()
         overlay.recording = false
     }
 
@@ -311,4 +334,7 @@ Item {
         }
     }
 
+    function cameraDeviceChanged() {
+        resetToolBar()
+    }
 }