From 7961e69b8f38ed0e08fedf542fc4001801a9aebc Mon Sep 17 00:00:00 2001 From: Mohammed Sameer Date: Fri, 2 Aug 2013 23:04:26 +0300 Subject: [PATCH] post capture image now follows device orientation --- qml/MainPage.qml | 1 - qml/PostCaptureItem.qml | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 5598c0b..1b0f5d4 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -25,7 +25,6 @@ import QtCamera 1.0 import CameraPlus 1.0 // TODO: flash not ready (battery low or flash not ready message) -// TODO: rotate post capture image // TODO: front camera CameraPage { diff --git a/qml/PostCaptureItem.qml b/qml/PostCaptureItem.qml index c190075..abe6fa9 100644 --- a/qml/PostCaptureItem.qml +++ b/qml/PostCaptureItem.qml @@ -31,6 +31,7 @@ Item { property variant itemData: item property bool playing: loader.source != "" signal clicked + clip: true function startPlayback() { loader.source = Qt.resolvedUrl("VideoPlayerPage.qml") @@ -57,16 +58,41 @@ Item { onFinished: loader.source = "" } -// TODO: rotation FullScreenThumbnail { id: image source: itemData.url mimeType: itemData.mimeType - - width: parent.width - 10 - height: parent.height + 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 -- 2.25.1