Replace @IMPORT_QT_QUICK@ with "import QtQuick 2.0"
[harmattan/cameraplus] / qml / PostCaptureItem.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 import QtQuick 2.0
24 import CameraPlus 1.0
25
26 Item {
27     id: postCaptureItem
28     property bool isVideo: itemData.type.search("nmm#Video") > 0
29     property alias error: image.error
30     property variant itemData: item
31     property bool playing: loader.source != ""
32     signal clicked
33
34     function startPlayback() {
35         loader.source = Qt.resolvedUrl("VideoPlayerPage.qml")
36         loader.item.source = itemData.url
37         if (!loader.item.play()) {
38             showError(qsTr("Error playing video. Please try again."))
39             loader.source = ""
40         }
41     }
42
43     function stopPlayback() {
44         if (loader.item) {
45             loader.item.stop()
46         }
47     }
48
49     Loader {
50         id: loader
51         anchors.fill: parent
52     }
53
54     Connections {
55         target: loader.item
56         onFinished: loader.source = ""
57     }
58
59 // TODO: rotation
60     FullScreenThumbnail {
61         id: image
62         source: itemData.url
63         mimeType: itemData.mimeType
64
65         width: parent.width - 10
66         height: parent.height
67         anchors.centerIn: parent
68         visible: loader.source == ""
69
70         MouseArea {
71             id: mouse
72             anchors.fill: parent
73             enabled: true
74             onClicked: postCaptureItem.clicked()
75         }
76
77         Column {
78             anchors.centerIn: parent
79             width: parent.width
80
81             CameraLabel {
82                 id: errorLabel
83                 width: parent.width
84                 visible: image.error
85                 text: qsTr("Failed to load preview")
86                 verticalAlignment: Text.AlignVCenter
87                 horizontalAlignment: Text.AlignHCenter
88                 font.pixelSize: 32
89             }
90
91             CameraToolIcon {
92                 id: playIcon
93                 anchors.horizontalCenter: parent.horizontalCenter
94                 iconSource: "image://theme/icon-s-music-video-play"
95                 visible: isVideo
96                 onClicked: startPlayback()
97             }
98         }
99     }
100 }