Reworked CameraToolBar
[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
29     property bool isVideo: itemData.type.search("nmm#Video") > 0
30     property alias error: image.error
31     property variant itemData: item
32     property bool playing: loader.source != ""
33     signal clicked
34
35     function startPlayback() {
36         loader.source = Qt.resolvedUrl("VideoPlayerPage.qml")
37         loader.item.source = itemData.url
38         if (!loader.item.play()) {
39             showError(qsTr("Error playing video. Please try again."))
40             loader.source = ""
41         }
42     }
43
44     function stopPlayback() {
45         if (loader.item) {
46             loader.item.stop()
47         }
48     }
49
50     Loader {
51         id: loader
52         anchors.fill: parent
53     }
54
55     Connections {
56         target: loader.item
57         onFinished: loader.source = ""
58     }
59
60 // TODO: rotation
61     FullScreenThumbnail {
62         id: image
63         source: itemData.url
64         mimeType: itemData.mimeType
65
66         width: parent.width - 10
67         height: parent.height
68         anchors.centerIn: parent
69         visible: loader.source == ""
70
71         MouseArea {
72             id: mouse
73             anchors.fill: parent
74             enabled: true
75             onClicked: postCaptureItem.clicked()
76         }
77
78         Column {
79             anchors.centerIn: parent
80             width: parent.width
81
82             CameraLabel {
83                 id: errorLabel
84                 width: parent.width
85                 visible: image.error
86                 text: qsTr("Failed to load preview")
87                 verticalAlignment: Text.AlignVCenter
88                 horizontalAlignment: Text.AlignHCenter
89                 font.pixelSize: 32
90             }
91
92             CameraToolIcon {
93                 id: playIcon
94                 anchors.horizontalCenter: parent.horizontalCenter
95                 iconId: cameraTheme.videoPlayIconId
96                 visible: isVideo
97                 onClicked: startPlayback()
98             }
99         }
100     }
101 }