X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FPostCaptureItem.qml;h=f648a5f6d34dd69613def746e78a8319637c0259;hp=b96eef587ada91ab9967f6163413928bf29f54b4;hb=c4d800d7ee31e65dadb24f3267660557fbb03c0f;hpb=d28234e38887391aaa6869d04e49fc95bfe1e2f8 diff --git a/qml/PostCaptureItem.qml b/qml/PostCaptureItem.qml index b96eef5..f648a5f 100644 --- a/qml/PostCaptureItem.qml +++ b/qml/PostCaptureItem.qml @@ -3,7 +3,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * Copyright (C) 2012-2013 Mohammed Sameer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,56 +20,113 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -import QtQuick 1.1 -import com.nokia.meego 1.1 +import QtQuick 2.0 import CameraPlus 1.0 Item { - id: item - property bool isImage: mimetype.toLowerCase().search("video") < 0 - property bool error: false + id: postCaptureItem - property bool isCurrentItem: PathView.isCurrentItem - onIsCurrentItemChanged: page.currentItem = item; + property url itemUrl: url + property string itemTitle: title + property string itemMimeType: mimeType + property string itemCreated: created + property string itemFileName: fileName - property string fileName: filename - property string creationDate: created + property bool isVideo: itemMimeType.search("video/") >= 0 + property alias error: image.error + property bool playing: loader.source != "" + signal clicked + clip: true - function startPlayback() { - openFileNow("VideoPlayerPage.qml"); - pageStack.currentPage.source = url; - pageStack.currentPage.play(); + function startPlayback() { + loader.source = Qt.resolvedUrl("VideoPlayerPage.qml") + loader.item.source = itemUrl + if (!loader.item.play()) { + showError(qsTr("Error playing video. Please try again.")) + loader.source = "" } + } - Label { - anchors.fill: parent - visible: image.error && page.status == PageStatus.Active - text: qsTr("Failed to load preview"); + function stopPlayback() { + if (loader.item) { + loader.item.stop() + } + } + + Loader { + id: loader + anchors.fill: parent + } + + Connections { + target: loader.item + onFinished: loader.source = "" + } + + FullScreenThumbnail { + id: image + source: itemUrl + mimeType: itemMimeType + rotation: calculateRotation(orientation.orientation) + width: isPortrait ? parent.height : parent.width - 10 + height: isPortrait ? parent.width - 10 : parent.height + anchors.centerIn: parent + visible: loader.source == "" + property bool isPortrait: rotation == -90 + + Behavior on width { + PropertyAnimation { duration: 100 } + } + + Behavior on height { + PropertyAnimation { duration: 100 } + } + + Behavior on rotation { + PropertyAnimation { duration: 100 } + } + + function calculateRotation(orientation) { + switch (orientation) { + case CameraOrientation.InvertedLandscape: + case CameraOrientation.Landscape: + return 0 + case CameraOrientation.InvertedPortrait: + case CameraOrientation.Portrait: + return -90 + default: + return 0 + } + } + + MouseArea { + id: mouse + anchors.fill: parent + enabled: true + onClicked: postCaptureItem.clicked() + } + + Column { + anchors.centerIn: parent + width: parent.width + + CameraLabel { + id: errorLabel + width: parent.width + visible: image.error + text: qsTr("Failed to load preview") verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter font.pixelSize: 32 - } + } - QuillItem { - id: image - anchors.fill: parent - visible: page.status == PageStatus.Activating || page.status == PageStatus.Active - - Component.onCompleted: initialize(url, mimetype); - - MouseArea { - id: mouse - anchors.fill: parent - enabled: true - onClicked: toolBar.visible = !toolBar.visible - } - - ToolIcon { - id: playIcon - anchors.centerIn: parent - iconSource: "image://theme/icon-s-music-video-play" - visible: !isImage - onClicked: startPlayback(); - } + CameraToolIcon { + id: playIcon + anchors.horizontalCenter: parent.horizontalCenter + iconSource: cameraTheme.videoPlayIconId + visible: isVideo + onClicked: startPlayback() + } } + } }