PlatformSettings now gets instantiated from QML and it will initialize quill
[harmattan/cameraplus] / qml / VideoPage.qml
index ec09db0..c2dd5f8 100644 (file)
@@ -3,7 +3,7 @@
 /*!
  * This file is part of CameraPlus.
  *
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,27 +31,43 @@ CameraPage {
 
         policyMode: CameraResources.Video
 
-        controlsVisible: videoControlsVisible && !videoMode.recording
-        property bool videoControlsVisible: recording.visible && cam.running && !standbyWidget.visible
-
+        controlsVisible: cam.running && !videoMode.recording && videoMode.canCapture && !cameraMode.busy && dimmer.opacity == 0.0 && !previewAnimationRunning
         orientationLock: PageOrientation.LockLandscape
 
-        DisplayState {
-                inhibitDim: videoMode.recording
-        }
+        property Item settingsDialog: null
 
-        onBatteryLow: {
-                if (!videoMode.recording) {
+        function startRecording() {
+                if (!fileSystem.available) {
+                        showError(qsTr("Camera cannot record videos in mass storage mode."));
                         return;
                 }
 
                 if (!checkBattery()) {
-                        videoMode.stopRecording();
                         showError(qsTr("Not enough battery to record video."));
+                        return;
+                }
+
+                if (!checkDiskSpace()) {
+                        showError(qsTr("Not enough space to record video."));
+                        return;
                 }
+
+                openFileNow("RecordingPage.qml");
         }
 
-        Button {
+        ZoomCaptureButton {
+                id: zoomCapture
+                page: page
+                onReleased: page.startRecording();
+        }
+
+        ZoomCaptureCancel {
+                anchors.fill: parent
+                page: page
+                zoomCapture: zoomCapture
+        }
+
+        CaptureButton {
                 id: recording
                 anchors.right: parent.right
                 anchors.rightMargin: 20
@@ -61,137 +77,32 @@ CameraPage {
                 height: 75
                 opacity: 0.5
 
-                onClicked: buttonClicked();
-
-                function buttonClicked() {
-                        if (!fileSystem.available) {
-                                showError(qsTr("Camera cannot record videos in mass storage mode."));
-                                return;
-                        }
-
-                        // We only toggle the mode to video recording so
-                        // policy can acquire the needed resources
-
-                        if (policyMode == CameraResources.Video) {
-                                if (!checkBattery()) {
-                                        showError(qsTr("Not enough battery to record video."));
-                                        return;
-                                }
-
-                                if (!checkDiskSpace()) {
-                                        showError(qsTr("Not enough space to record video."));
-                                        return;
-                                }
-
-                                policyMode = CameraResources.Recording;
-                        }
-                        else if (videoMode.recording) {
-                                // We just ask to stop video.
-                                videoMode.stopRecording();
-                        }
-                }
+                onClicked: startRecording();
 
-                Connections {
-                        target: videoMode
-                        onRecordingChanged: {
-                                if (!videoMode.recording) {
-                                        policyMode = CameraResources.Video;
-                                }
-                        }
-                }
-
-                Connections {
-                        target: resourcePolicy
-                        onAcquiredChanged: {
-                                if (resourcePolicy.acquired && policyMode == CameraResources.Recording) {
-                                        metaData.setMetaData();
-
-                                        if (!mountProtector.lock()) {
-                                                showError(qsTr("Failed to lock images directory."));
-                                                policyMode = CameraResources.Video
-                                                return;
-                                        }
-
-
-                                        if (!videoMode.startRecording(fileNaming.videoFileName(),
-                                             fileNaming.temporaryVideoFileName())) {
-                                                showError(qsTr("Failed to record video. Please restart the camera."));
-                                                policyMode = CameraResources.Video
-}
-                                }
-                        }
-                }
-
-                visible: (videoMode.recording || videoMode.canCapture) && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
-        }
-
-        Connections {
-                target: Qt.application
-                onActiveChanged: {
-                        if (!Qt.application.active && videoMode.recording) {
-                                videoMode.stopRecording();
-                        }
-                }
+                visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
         }
 
         VideoMode {
                 id: videoMode
                 camera: cam
                 onPreviewAvailable: {
-                        if (!standbyWidget.visible) {
-                                page.setPreview(preview);
-                        }
+                        page.setPreview(preview);
                 }
-
-                onSaved: mountProtector.unlock();
         }
 
-        VideoTorchButton {
-                id: torch
-                visible: videoControlsVisible
+        Rectangle {
                 anchors.top: parent.top
-                anchors.left: parent.left
                 anchors.topMargin: 20
-                anchors.leftMargin: 20
-                opacity: 0.5
-        }
-
-        VideoSceneButton {
-                id: scene
-                visible: controlsVisible
-                anchors.top: torch.bottom
-                anchors.left: parent.left
-                anchors.topMargin: 10
-                anchors.leftMargin: 20
-        }
-
-        VideoEvCompButton {
-                id: evComp
-                visible: videoControlsVisible
-                anchors.top: scene.bottom
-                anchors.left: parent.left
-                anchors.topMargin: 10
-                anchors.leftMargin: 20
-        }
-
-        MouseArea {
-                id: indicators
-                anchors.bottom: parent.bottom
-                anchors.bottomMargin: 20
                 anchors.left: parent.left
                 anchors.leftMargin: 20
                 width: 48
                 height: col.height
-                onClicked: openFile("VideoSettingsPage.qml");
+                color: "black"
+                border.color: "gray"
+                radius: 20
+                opacity: 0.5
                 visible: controlsVisible
 
-                BorderImage {
-                        id: image
-                        anchors.fill: parent
-                        smooth: true
-                        source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
-                }
-
                 Column {
                         id: col
                         width: parent.width
@@ -204,7 +115,7 @@ CameraPage {
 
                         Indicator {
                                 id: wbIndicator
-                                source: "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen"
+                                source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
                                 visible: settings.videoWhiteBalance != WhiteBalance.Auto
                         }
 
@@ -244,84 +155,57 @@ CameraPage {
                 opacity: 0.5
                 iconSource: "image://theme/icon-m-camera-roll"
                 onClicked: openFile("PostCapturePage.qml");
-                visible: controlsVisible && !videoMode.recording
+                visible: controlsVisible
         }
 
-        Rectangle {
-                anchors.left: parent.left
+        CameraToolBar {
+                id: toolBar
                 anchors.bottom: parent.bottom
-                anchors.leftMargin: 20
                 anchors.bottomMargin: 20
-
-                visible: videoControlsVisible && videoMode.recording
-
-                color: "black"
+                anchors.left: parent.left
+                anchors.leftMargin: 20
                 opacity: 0.5
-                width: 100
-                height: 30
-
-                Timer {
-                        id: recordingDuration
-
-                        property int duration: 0
-
-                        running: cam.running && videoMode.recording
-                        triggeredOnStart: true
-                        interval: 1000
-                        repeat: true
-
-                        onTriggered: {
-                                duration = duration + 1;
-                                if (duration == 3600) {
-                                        videoMode.stopRecording();
-                                        showError(qsTr("Maximum recording time reached."));
-                                }
-                                else if (!checkDiskSpace()) {
-                                        videoMode.stopRecording();
-                                        showError(qsTr("Not enough space to continue recording."));
-                                }
-                        }
-
-                        onRunningChanged: {
-                                if (!running) {
-                                        duration = 0;
-                                }
-                        }
+                targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
+                visible: controlsVisible
+                expanded: settings.showToolBar
+                onExpandedChanged: settings.showToolBar = expanded;
+
+                items: [
+                VideoTorchButton {
+                        camera: cam
+                },
+                VideoSceneButton {
+                        onClicked: toolBar.push(items);
+                },
+                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: openSettings();
                 }
+                ]
+        }
 
-                Image {
-                        id: recordingIcon
-                        source: "image://theme/icon-m-camera-ongoing-recording"
-                        width: 20
-                        height: 20
-                        anchors.verticalCenter: parent.verticalCenter
-                        anchors.left: parent.left
-                        anchors.leftMargin: 5
-                        sourceSize.width: 20
-                        sourceSize.height: 20
+        function openSettings() {
+                if (!settingsDialog) {
+                        settingsDialog = videoSettingsDialog.createObject(page);
                 }
 
-                Label {
-                        function formatDuration(dur) {
-                                var secs = parseInt(dur);
-                                var mins = Math.floor(secs / 60);
-                                var seconds = secs - (mins * 60);
-
-                                if (mins < 10) {
-                                        mins = "0" + mins;
-                                }
+                settingsDialog.open();
+        }
 
-                                if (seconds < 10) {
-                                        seconds = "0" + seconds;
-                                }
+        Component {
+                id: videoSettingsDialog
 
-                                return mins + ":" + seconds;
-                        }
-
-                        id: durationLabel
-                        text: formatDuration(recordingDuration.duration);
-                        anchors.left: recordingIcon.right
-                        anchors.leftMargin: 5
-                }
+                VideoSettingsDialog { }
         }
 }