summaryrefslogtreecommitdiffstats
path: root/basicsuite/Camera/CapturePreview.qml
diff options
context:
space:
mode:
authoraavit <eirik.aavitsland@digia.com>2013-10-08 16:55:15 +0200
committerEirik Aavitsland <eirik.aavitsland@digia.com>2013-10-09 11:33:52 +0300
commitbcc6a8fe80f2f31605afaae63e1b05051c0deb5f (patch)
tree408bb294cb2fb813f2b86fcf0ae90e0f9d1c3d88 /basicsuite/Camera/CapturePreview.qml
parentecd752748fd0385d6b22712663c0e1d1c87921af (diff)
Moved Media Player and Camera from experimental to basicsuite
Change-Id: I8fd2335614062e1ca09f385ad6c0ae0dd19d694c Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@digia.com>
Diffstat (limited to 'basicsuite/Camera/CapturePreview.qml')
-rw-r--r--basicsuite/Camera/CapturePreview.qml45
1 files changed, 45 insertions, 0 deletions
diff --git a/basicsuite/Camera/CapturePreview.qml b/basicsuite/Camera/CapturePreview.qml
new file mode 100644
index 0000000..611fa53
--- /dev/null
+++ b/basicsuite/Camera/CapturePreview.qml
@@ -0,0 +1,45 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ anchors.fill: parent
+ color: "black"
+ opacity: 0
+ enabled: opacity !== 0
+
+ property string previewSrc: ""
+
+ onOpacityChanged: {
+ if (opacity === 1 && previewSrc !== "") {
+ previewImage.source = previewSrc;
+ previewSrc = "";
+ }
+ }
+
+ Behavior on opacity { NumberAnimation { duration: 100 } }
+
+ function show() {
+ previewImage.source = "";
+ opacity = 1;
+ }
+
+ function setPreview(preview) {
+ if (root.opacity === 1)
+ previewImage.source = preview;
+ else
+ root.previewSrc = preview;
+ }
+
+ Image {
+ id: previewImage
+ anchors.fill: parent
+ fillMode: Image.PreserveAspectFit
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ root.opacity = 0;
+ }
+ }
+}