X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FPostCaptureView.qml;h=4aabbb81953601e2ec7014b06f6a21b18fbf7af5;hp=a34e43144828cde5e40eab3971554cef4b392ff4;hb=c5ecf23d0f96976948626ba51275419067fdd4ee;hpb=a4ac92426b10141d2e6b50aabeed36ab3940827f diff --git a/qml/PostCaptureView.qml b/qml/PostCaptureView.qml index a34e431..4aabbb8 100644 --- a/qml/PostCaptureView.qml +++ b/qml/PostCaptureView.qml @@ -24,18 +24,30 @@ import QtQuick 2.0 import CameraPlus 1.0 import QtCamera 1.0 -// TODO: qrc:/qml/PostCaptureView.qml:104:5: QML CameraToolBar: Binding loop detected for property "height" -// TODO: try to reload the preview thumbnail when the picture becomes available -// TODO: prevent flicking to this view while preview animation is running Item { id: postCaptureView - property Camera camera: null + property Camera camera: viewfinder.camera property bool pressed: view.currentItem ? view.currentItem.playing : false 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 + property bool inhibitDim: pressed + + property bool isCurrent: mainView.currentIndex == 2 && !mainView.moving + property bool inCameraMode: root.inCaptureMode && !mainView.moving + + onIsCurrentChanged: { + if (isCurrent) { + postCaptureModel.reload() + } + } + + onInCameraModeChanged: { + if (inCameraMode) { + postCaptureModel.clear() + } + } Connections { target: view.currentItem @@ -78,33 +90,10 @@ Item { } } - 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")) - } - } - } + PostCaptureModel { + id: postCaptureModel + imagePath: platformSettings.imagePath + videoPath: platformSettings.videoPath } Timer { @@ -118,34 +107,25 @@ Item { expanded: true hideBack: true anchors.bottom: parent.bottom - anchors.bottomMargin: show ? 20 : -1 * (height + 20) + anchors.bottomMargin: 20 anchors.left: parent.left anchors.leftMargin: 20 anchors.right: parent.right anchors.rightMargin: 20 - opacity: 0.8 - + opacity: show ? 0.8 : 0.0 + visible: opacity > 0 property bool show: deleteDialog.isOpen || deleteDialog.isOpening || hideTimer.running || - (view.currentItem && view.currentItem.error) && !view.currentItem.playing + (view.currentItem != null && view.currentItem.error) && !view.currentItem.playing - Behavior on anchors.bottomMargin { + Behavior on opacity { PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 } } tools: CameraToolBarTools { CameraToolIcon { - iconId: available && view.currentItem.itemData.favorite ? cameraTheme.favoriteMarkIconId : cameraTheme.favoriteUnmarkIconId - opacity: available ? 1.0 : 0.4 - onClicked: { - addOrRemoveFavorite() - restartTimer() - } - } - - CameraToolIcon { - iconId: cameraTheme.shareIconId - opacity: available ? 1.0 : 0.4 + iconSource: cameraTheme.shareIconId + enabled: view.currentItem != null onClicked: { shareCurrentItem() restartTimer() @@ -153,8 +133,8 @@ Item { } CameraToolIcon { - iconId: cameraTheme.deleteIconId - opacity: available ? 1.0 : 0.4 + iconSource: cameraTheme.deleteIconId + enabled: view.currentItem != null onClicked: { deleteCurrentItem() restartTimer() @@ -162,7 +142,7 @@ Item { } CameraToolIcon { - iconId: cameraTheme.galleryIconId + iconSource: cameraTheme.galleryIconId onClicked: { launchGallery() restartTimer() @@ -180,10 +160,10 @@ Item { onStatusChanged: restartTimer() onAccepted: { - if (!remove.remove(view.currentItem.itemData.url)) { + if (!remove.remove(view.currentItem.itemUrl)) { showError(qsTr("Failed to delete item")) } else { - postCaptureModel.remove(view.currentItem.itemData); + view.model.remove(view.currentItem.itemUrl) } } @@ -195,7 +175,7 @@ Item { Rectangle { opacity: toolBar.opacity anchors.top: parent.top - anchors.topMargin: toolBar.show ? 20 : -1 * (height + 20) + anchors.topMargin: 20 anchors.left: parent.left anchors.leftMargin: 20 anchors.right: parent.right @@ -206,17 +186,13 @@ Item { border.color: toolBar.border.color radius: toolBar.radius - Behavior on anchors.topMargin { - PropertyAnimation { duration: view.currentItem && view.currentItem.playing ? 0 : 200 } - } - Flow { width: parent.width - 40 x: 20 height: parent.height CameraLabel { - text: view.currentItem ? view.currentItem.itemData.title : "" + text: view.currentItem ? view.currentItem.itemTitle : "" width: parent.width / 2 height: parent.height font.bold: true @@ -225,7 +201,7 @@ Item { } CameraLabel { - text: view.currentItem ? view.currentItem.itemData.created : "" + text: view.currentItem ? view.currentItem.itemCreated : "" width: parent.width / 2 height: parent.height font.bold: true @@ -242,44 +218,20 @@ Item { } function deleteCurrentItem() { - if (!available) { + if (view.currentItem == null) { return } - deleteDialog.message = view.currentItem.itemData.fileName + deleteDialog.message = view.currentItem.itemFileName deleteDialog.open() } function shareCurrentItem() { - if (!available) { - return - } - - if (!share.share(view.currentItem.itemData.url)) { + if (view.currentItem != null && !share.share(view.currentItem.itemUrl)) { showError(qsTr("Failed to launch share service")) } } - function addOrRemoveFavorite() { - if (!available) { - return - } - - if (view.currentItem.itemData.favorite) { - if (!trackerStore.removeFromFavorites(view.currentItem.itemData.url)) { - showError(qsTr("Failed to remove favorite")) - } else { - view.currentItem.itemData.favorite = false - } - } else { - if (!trackerStore.addToFavorites(view.currentItem.itemData.url)) { - showError(qsTr("Failed to add favorite")) - } else { - view.currentItem.itemData.favorite = true - } - } - } - function restartTimer() { hideTimer.restart() }