Added gallery integration
[harmattan/cameraplus] / qml / RecordingPage.qml
index ba6dd44..6d9f8f0 100644 (file)
@@ -26,18 +26,40 @@ import QtCamera 1.0
 import CameraPlus 1.0
 import "data.js" as Data
 
-// TODO: on error ?
-// TODO: resources lost?
-// TODO: closing camera in the middle of recording will hang camera
+// TODO: losing resources in the middle of recording will produce corrupted video
+// TODO: optional resources?
+
 CameraPage {
         id: page
         modesVisible: false
+        property bool error: false
+
+        policyMode: CameraResources.Recording
+
+        controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !error
+
+        orientationLock: PageOrientation.LockLandscape
+
+        function policyLost() {
+                page.stopRecording();
+        }
+
+        function cameraError() {
+                error = true;
+                page.stopRecording();
+        }
 
-        Component.onCompleted: startRecording();
         Component.onDestruction: videoMode.stopRecording();
 
+        onStatusChanged: {
+                if (page.status == PageStatus.Active) {
+                        startRecording();
+                }
+        }
+
         function startRecording() {
-                if (!resourcePolicy.acquired || resourcePolicy.hijacked) {
+                if (!pipelineManager.acquired || pipelineManager.hijacked) {
+                        showError(qsTr("Failed to acquire needed resources."));
                         pageStack.pop(undefined, true);
                         return;
                 }
@@ -59,20 +81,17 @@ CameraPage {
                         mountProtector.unlock();
                 }
 
+                // TODO: sometimes this fails (fast stop after start).
                 trackerStore.storeVideo(file);
         }
 
         function stopRecording() {
                 mountProtector.unlock();
-                pageStack.pop(undefined, true);
+                // Something is fishy here but if there is an error
+                // and we use immediate mode then the page never gets destroyed.
+                pageStack.pop(undefined, error ? false : true);
         }
 
-        policyMode: CameraResources.Recording
-
-        controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
-
-        orientationLock: PageOrientation.LockLandscape
-
         DisplayState {
                 inhibitDim: true
         }
@@ -84,7 +103,7 @@ CameraPage {
                 }
         }
 
-        Button {
+        CaptureButton {
                 id: recording
                 anchors.right: parent.right
                 anchors.rightMargin: 20
@@ -112,30 +131,63 @@ CameraPage {
                 camera: cam
         }
 
-        VideoTorchButton {
-                id: torch
-                camera: cam
-                visible: controlsVisible
+        Rectangle {
                 anchors.top: parent.top
-                anchors.left: parent.left
                 anchors.topMargin: 20
+                anchors.left: parent.left
                 anchors.leftMargin: 20
+                width: 48
+                height: col.height
+                color: "black"
+                border.color: "gray"
+                radius: 20
                 opacity: 0.5
-        }
-
-        VideoEvCompButton {
-                id: evComp
                 visible: controlsVisible
-                anchors.top: torch.bottom
-                anchors.left: parent.left
-                anchors.topMargin: 10
-                anchors.leftMargin: 20
+
+                Column {
+                        id: col
+                        width: parent.width
+                        spacing: 5
+
+                        Indicator {
+                                id: resolutionIndicator
+                                source: "image://theme/" + Data.videoIcon(settings.videoResolution);
+                        }
+
+                        Indicator {
+                                id: wbIndicator
+                                source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
+                                visible: settings.videoWhiteBalance != WhiteBalance.Auto
+                        }
+
+                        Indicator {
+                                id: cfIndicator
+                                source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
+                                visible: settings.videoColorFilter != ColorTone.Normal
+                        }
+
+                        Indicator {
+                                id: gpsIndicator
+                                visible: settings.useGps
+                                source: "image://theme/icon-m-camera-location"
+
+                                PropertyAnimation on opacity  {
+                                        easing.type: Easing.OutSine
+                                        loops: Animation.Infinite
+                                        from: 0.2
+                                        to: 1.0
+                                        duration: 1000
+                                        running: settings.useGps && !positionSource.position.longitudeValid
+                                        alwaysRunToEnd: true
+                                }
+                        }
+                }
         }
 
         Rectangle {
-                anchors.left: parent.left
                 anchors.bottom: parent.bottom
-                anchors.leftMargin: 20
+                anchors.right: parent.right
+                anchors.rightMargin: 20
                 anchors.bottomMargin: 20
 
                 visible: controlsVisible
@@ -197,4 +249,38 @@ CameraPage {
                         anchors.leftMargin: 5
                 }
         }
+
+        CameraToolBar {
+                id: toolBar
+                anchors.bottom: parent.bottom
+                anchors.bottomMargin: 20
+                anchors.left: parent.left
+                anchors.leftMargin: 20
+                opacity: 0.5
+                targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
+                visible: controlsVisible
+                expanded: settings.showToolBar
+                onExpandedChanged: settings.showToolBar = expanded;
+
+                items: [
+                VideoTorchButton {
+                        camera: cam
+                },
+                VideoEvCompButton {
+                        onClicked: toolBar.push(items);
+                },
+                VideoWhiteBalanceButton {
+                        onClicked: toolBar.push(items);
+                },
+                VideoColorFilterButton {
+                        onClicked: toolBar.push(items);
+                },
+                VideoMuteButton {
+                },
+                ToolIcon {
+                        iconSource: "image://theme/icon-m-toolbar-view-menu-white"
+                        onClicked: openFile("VideoSettingsPage.qml");
+                }
+                ]
+        }
 }