Debian Codegraph @

qml/Viewfinder/ViewFinderExportConfirmation.qml

raw
1 /*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.12
18 import Lomiri.Components 1.3
19
20 import "../components"
21
22 Item {
23 id: viewFinderExportConfirmation
24
25 property bool isVideo
26 property string mediaPath
27 property bool waitingForPictureCapture: false
28
29 signal hideRequested()
30 signal showRequested()
31 property ViewFinderGeometry geometry
32
33 visible: false
34
35 // For videos show immediately without waiting for the preview to load,
36 // since we will show a progress indicator instead of the preview
37 onMediaPathChanged: if (mediaPath && isVideo) showRequested()
38
39 function photoCaptureStarted() {
40 controls.item.lockPictureOrientation()
41 waitingForPictureCapture = true
42 }
43
44 Loader {
45 id: controls
46 anchors.fill: parent
47 asynchronous: true
48 sourceComponent: Component {
49 Item {
50 function lockPictureOrientation() { pictureReview.lockOrientation() }
51
52 VideoReview {
53 id: videoReview
54 anchors.fill: parent
55 bottomMargin: buttons.height
56 videoPath: isVideo ? mediaPath : ""
57 visible: isVideo
58 }
59
60 PictureReview {
61 id: pictureReview
62 anchors.fill: parent
63 visible: !isVideo
64 geometry: viewFinderExportConfirmation.geometry
65 source: !isVideo ? mediaPath : ""
66
67 // Show export confirmation only when the snapshot is loaded to prevent the
68 // screen being black while the image loads
69 onLoadedChanged: {
70 if (loaded) {
71 viewFinderExportConfirmation.showRequested()
72 waitingForPictureCapture = false
73 }
74 }
75 }
76
77 Item {
78 id: buttons
79 anchors.bottom: parent.bottom
80 anchors.left: parent.left
81 anchors.right: parent.right
82 height: childrenRect.height
83
84 CircleButton {
85 id: retryButton
86 objectName: "retryButton"
87
88 anchors {
89 right: validateButton.left
90 rightMargin: units.gu(7.5)
91 bottom: parent.bottom
92 bottomMargin: units.gu(6)
93 }
94
95 iconName: "reload"
96 onClicked: hideRequested()
97 }
98
99 CircleButton {
100 id: validateButton
101 objectName: "validateButton"
102
103 width: units.gu(8)
104 anchors {
105 bottom: parent.bottom
106 bottomMargin: units.gu(5)
107 horizontalCenter: parent.horizontalCenter
108 }
109
110 iconName: "ok"
111 onClicked: {
112 hideRequested();
113 main.exportContent([mediaPath]);
114 mediaPath = "";
115 }
116 }
117
118 CircleButton {
119 id: cancelButton
120 objectName: "cancelButton"
121
122 anchors {
123 left: validateButton.right
124 leftMargin: units.gu(7.5)
125 bottom: parent.bottom
126 bottomMargin: units.gu(6)
127 }
128
129 iconName: "close"
130 onClicked: {
131 hideRequested();
132 main.cancelExport();
133 mediaPath = "";
134 }
135 }
136 }
137 }
138 }
139 }
140 }