Debian Codegraph @

import/Lomiri/Content/qml6/ContentTransferHint.qml

raw
1 /*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 import QtQuick 2.4
18 import Lomiri.Components
19 import Lomiri.Components.Popups
20 import Lomiri.Content
21
22 /*!
23 \qmltype ContentTransferHint
24 \inqmlmodule Lomiri.Content
25 \brief Component that indicates that a transfer is active
26
27 This component shows that the transfer is currently running, and the source
28 application is active. It blocks all input during that time.
29 Place this component on top of your view.
30
31 See documentation for ContentHub to see an example
32 */
33 Item {
34 id: root
35
36 /*!
37 \qmlproperty ContentTransfer ContentTransferHint::activeTransfer
38 \brief The ContentTransfer to monitor the status of.
39
40 This should be set to the currently active ContentTransfer, which
41 will then cause the ContentTransferHint to become visible while
42 the transfer is in progress.
43 */
44 property var activeTransfer
45
46 opacity: internal.isTransferRunning ? 1.0 : 0.0
47
48 Component {
49 id: dialog
50 Dialog {
51 id: dialogue
52 title: i18n.dtr("lomiri-content-hub", "Transfer in progress")
53
54 ActivityIndicator {
55 id: indicator
56 anchors.top: parent.top
57 anchors.topMargin: units.gu(6)
58 running: internal.isTransferRunning
59 }
60
61 Button {
62 id: cancelTransfer
63 anchors.top: indicator.bottom
64 anchors.topMargin: units.gu(4)
65 text: i18n.dtr("lomiri-content-hub", "Cancel")
66 onClicked: {
67 root.activeTransfer.state = ContentTransfer.Aborted
68 }
69 }
70 }
71 }
72
73 QtObject {
74 id: internal
75 property bool isTransferRunning: root.activeTransfer ?
76 root.activeTransfer.state === ContentTransfer.InProgress || root.activeTransfer.state === ContentTransfer.Initiated
77 : false
78 property var dialogue
79
80 onIsTransferRunningChanged: {
81 if (isTransferRunning) {
82 dialogue = PopupUtils.open(dialog, root);
83 } else {
84 PopupUtils.close(dialogue);
85 }
86 }
87 }
88 }