Debian Codegraph @

qml/Components/PageHubExport.qml

raw
1 /*
2 * This file is part of the 2FA Manager App for Ubuntu Touch
3 * Copyright (C) 2019 Joan CiberSheep
4 *
5 * This App is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 *
10 * This App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 import QtQuick 2.9
21 import Lomiri.Components 1.3
22 import Lomiri.Content 1.3
23
24 Page {
25 id: exportPage
26 objectName: "exportHubPage"
27 anchors.fill: parent
28
29 property var activeTransfer
30 property var path
31
32 signal close()
33 signal deleteCacheFile()
34
35 header: HeaderBase {
36 title: i18n.tr("Export json file to")
37 }
38
39 Rectangle {
40 anchors.fill: parent
41 anchors.topMargin: exportPage.header.height
42
43 ContentTransferHint {
44 anchors.fill: parent
45 activeTransfer: exportPage.activeTransfer
46 }
47
48 ContentItem {
49 id: exportItem
50 }
51
52 ContentPeerPicker {
53 visible: exportPage.visible
54 showTitle: false
55 handler: ContentHandler.Destination
56 contentType: ContentType.Documents
57
58 onPeerSelected: {
59 activeTransfer = peer.request();
60 stateChangeConnection.target = activeTransfer
61 console.log("APP",activeTransfer.destination)
62 console.log("Store",activeTransfer.store)
63 console.log("DownID",activeTransfer.downloadId)
64 var items = [];
65 exportItem.url = path;
66 console.log("1",JSON.stringify(exportItem))
67 console.log("Export path:",path);
68 items.push(exportItem);
69 console.log("2",JSON.stringify(items))
70 activeTransfer.items = items;
71 activeTransfer.state = ContentTransfer.Charged;
72 }
73
74 onCancelPressed: {
75 close();
76 }
77 }
78 }
79
80 Connections {
81 id: stateChangeConnection
82 target: null
83
84 onStateChanged: {
85 var statesForDebug = ["Created","Initiated","InProgress","Charged","Collected","Aborted","Finalized","Downloading","Downloaded"]
86 console.log("DEBUG: activeTrasfer State is", statesForDebug[activeTransfer.state])
87
88 switch (activeTransfer.state) {
89 case ContentTransfer.Aborted:
90 console.log("Aborted")
91 break;
92 case ContentTransfer.Collected:
93 console.log("Collected: Now finalize and close")
94 activeTransfer.finalize();
95 break;
96 case ContentTransfer.Finalized:
97 console.log("Finalized")
98 deleteCacheFile();
99 close();
100 break;
101 case ContentTransfer.InProgress:
102 console.log("InProgress")
103 break;
104 case ContentTransfer.Charged:
105 console.log("Charged")
106 break;
107 default:
108 console.log("Other state?",activeTransfer.state)
109 }
110 }
111 }
112 }