X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FPostCaptureItem.qml;h=f648a5f6d34dd69613def746e78a8319637c0259;hp=af18fdb4193db4bd6ba09b812c766a7b2d75b84a;hb=c4d800d7ee31e65dadb24f3267660557fbb03c0f;hpb=960eb792acde51e3e0b862c19d58acaf3082c500 diff --git a/qml/PostCaptureItem.qml b/qml/PostCaptureItem.qml index af18fdb..f648a5f 100644 --- a/qml/PostCaptureItem.qml +++ b/qml/PostCaptureItem.qml @@ -20,22 +20,37 @@ * 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: postCaptureItem - property bool isVideo: itemData.type.search("nmm#Video") > 0 + + property url itemUrl: url + property string itemTitle: title + property string itemMimeType: mimeType + property string itemCreated: created + property string itemFileName: fileName + + property bool isVideo: itemMimeType.search("video/") >= 0 property alias error: image.error - property variant itemData: item property bool playing: loader.source != "" signal clicked + clip: true function startPlayback() { loader.source = Qt.resolvedUrl("VideoPlayerPage.qml") - loader.item.source = itemData.url - loader.item.play() + loader.item.source = itemUrl + if (!loader.item.play()) { + showError(qsTr("Error playing video. Please try again.")) + loader.source = "" + } + } + + function stopPlayback() { + if (loader.item) { + loader.item.stop() + } } Loader { @@ -48,21 +63,40 @@ Item { onFinished: loader.source = "" } - QuillItem { + FullScreenThumbnail { id: image - width: parent.width - 10 - height: parent.height + 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 - Component.onCompleted: initialize(itemData.url, itemData.mimetype) visible: loader.source == "" + property bool isPortrait: rotation == -90 - Label { - anchors.fill: parent - visible: image.error - text: qsTr("Failed to load preview") - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 32 + 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 { @@ -72,13 +106,27 @@ Item { onClicked: postCaptureItem.clicked() } - ToolIcon { - // TODO: this is overlapping with error. - id: playIcon + Column { anchors.centerIn: parent - iconSource: "image://theme/icon-s-music-video-play" - visible: isVideo - onClicked: startPlayback() + 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 + } + + CameraToolIcon { + id: playIcon + anchors.horizontalCenter: parent.horizontalCenter + iconSource: cameraTheme.videoPlayIconId + visible: isVideo + onClicked: startPlayback() + } } } }