Fixed VideoPlayerPage.qml failure to set cameraConfig
[harmattan/cameraplus] / qml / PostCaptureView.qml
index 2cae714..d979a49 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-import QtQuick 1.1
+import QtQuick 2.0
 import CameraPlus 1.0
-import com.nokia.meego 1.1
 import QtCamera 1.0
 
 Item {
+    property Camera camera: null
     property bool pressed: view.currentItem ? view.currentItem.playing : false
-    property int policyMode: view.currentItem && view.currentItem.playing ? CameraResources.None :
-        settings.mode == Camera.VideoMode ? CameraResources.Video
-        CameraResources.Image
+    property int policyMode: view.currentItem && view.currentItem.playing ?
+        CameraResources.Player : settings.mode == Camera.VideoMode ? CameraResources.Video :
+        CameraResources.Image
     property bool available: view.currentItem ? view.currentItem.itemData.available : false
 
-    Component.onCompleted: postCaptureModel.reload()
-
     ShareHelper {
         id: share
         settings: platformSettings
@@ -65,14 +63,32 @@ Item {
         }
     }
 
-    PostCaptureModel {
-        // TODO: this should not be active all the time
-        id: postCaptureModel
-        manufacturer: deviceInfo.manufacturer
-        model: deviceInfo.model
-        onError: {
-            console.log("Error populating model " + msg)
-            showError(qsTr("Failed to load captures"))
+    property variant postCaptureModel: postCaptureModelLoader.item ?
+        postCaptureModelLoader.item.model : null
+    property bool loadModel: mainView.currentIndex == 2 && Qt.application.active
+
+    Loader {
+        id: postCaptureModelLoader
+        sourceComponent: loadModel ? postCaptureModelComponent : undefined
+    }
+
+    // We have to do it that way because Loader does not support non-visual elements.
+    Component {
+        id: postCaptureModelComponent
+
+        Item {
+            property alias model: postCaptureModel
+
+            PostCaptureModel {
+                id: postCaptureModel
+                manufacturer: deviceInfo.manufacturer
+                model: deviceInfo.model
+                Component.onCompleted: reload()
+                onError: {
+                    console.log("Error populating model " + msg)
+                    showError(qsTr("Failed to load captures"))
+                }
+            }
         }
     }
 
@@ -85,49 +101,44 @@ Item {
     CameraToolBar {
         id: toolBar
         expanded: true
-        manualBack: true
+        hideBack: true
         anchors.bottom: parent.bottom
         anchors.bottomMargin: show ? 20 : -1 * (height + 20)
         anchors.left: parent.left
         anchors.leftMargin: 20
         opacity: 0.8
-// TODO: hide back button
-        property bool show: deleteDialog.status == DialogStatus.Open ||
-            deleteDialog.status == DialogStatus.Opening ||
-            hideTimer.running || menu.status == DialogStatus.Open ||
-            menu.status == DialogStatus.Opening ||
-            (view.currentItem && view.currentItem.error) && !view.currentItem.playing
 
-// TODO:
-//        onClicked: pageStack.pop()
+        property bool show: deleteDialog.isOpen || deleteDialog.isOpening ||
+            hideTimer.running || menu.isOpen || menu.isOpening ||
+            (view.currentItem && view.currentItem.error) && !view.currentItem.playing
 
         Behavior on anchors.bottomMargin {
             PropertyAnimation { duration: 200; }
         }
 
         items: [
-            ToolIcon {
+            CameraToolIcon {
                 iconId: !available ? "icon-m-toolbar-favorite-mark-dimmed-white" : view.currentItem.itemData.favorite ? "icon-m-toolbar-favorite-mark-white" : "icon-m-toolbar-favorite-unmark-white"
                 onClicked: {
                     addOrRemoveFavorite()
                     restartTimer()
                 }
             },
-            ToolIcon {
+            CameraToolIcon {
                 iconId: available ? "icon-m-toolbar-share-white" : "icon-m-toolbar-share-dimmed-white"
                 onClicked: {
                     shareCurrentItem()
                     restartTimer()
                 }
             },
-            ToolIcon {
+            CameraToolIcon {
                 iconId: available ? "icon-m-toolbar-delete-white" : "icon-m-toolbar-delete-dimmed-white"
                 onClicked: {
                     deleteCurrentItem()
                     restartTimer()
                 }
             },
-            ToolIcon {
+            CameraToolIcon {
                 iconId: "icon-m-toolbar-view-menu-white"
                 onClicked: {
                     menu.open()
@@ -137,7 +148,7 @@ Item {
         ]
     }
 
-    QueryDialog {
+    CameraQueryDialog {
         id: deleteDialog
         titleText: qsTr("Delete item?");
         acceptButtonText: qsTr("Yes");
@@ -158,22 +169,22 @@ Item {
         }
     }
 
-    Menu {
+    CameraMenu {
         id: menu
         onStatusChanged: restartTimer()
 
-        MenuLayout {
-            MenuItem {
+        actions: [
+            CameraMenuAction {
                 text: qsTr("Captures in gallery")
                 onClicked: launchGallery()
-            }
-
-            MenuItem {
+            },
+            CameraMenuAction {
+                // TODO: this is not working...
                 text: qsTr("View in gallery")
                 enabled: available
                 onClicked: showInGallery()
             }
-        }
+        ]
     }
 
     Rectangle {
@@ -199,7 +210,7 @@ Item {
             x: 20
             height: parent.height
 
-            Label {
+            CameraLabel {
                 text: view.currentItem ? view.currentItem.itemData.title : ""
                 width: parent.width / 2
                 height: parent.height
@@ -208,7 +219,7 @@ Item {
                 horizontalAlignment: Text.AlignLeft
             }
 
-            Label {
+            CameraLabel {
                 text: view.currentItem ? view.currentItem.itemData.created : ""
                 width: parent.width / 2
                 height: parent.height
@@ -277,4 +288,10 @@ Item {
     function restartTimer() {
         hideTimer.restart()
     }
+
+    function policyLost() {
+        if (view.currentItem && view.currentItem.playing) {
+            view.currentItem.stopPlayback()
+        }
+    }
 }