Dekko
Loading...
Searching...
No Matches
ContactsPickerDialog.qml
1/* Copyright (C) 2025 CIT-Services <info@cit-services.eu>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program 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 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18import QtQuick 2.4
19import Lomiri.Components 1.3
20import Lomiri.Components.Popups 1.0 as Popups
21import Lomiri.Content 1.1
22
23Popups.PopupBase {
24 id: picker
25 z: 100
26 property var activeTransfer
27 signal contactsImported(var files)
28
29 Rectangle {
30 anchors.fill: parent
31
32 ContentTransferHint {
33 anchors.fill: parent
34 activeTransfer: picker.activeTransfer
35 }
36
37 ContentPeerPicker {
38 id: peerPicker
39 anchors.fill: parent
40 visible: true
41 contentType: ContentType.Contacts
42 handler: ContentHandler.Source
43
44 onPeerSelected: {
45 peer.selectionType = ContentTransfer.Multiple
46 picker.activeTransfer = peer.request()
47 stateChangeConnection.target = picker.activeTransfer
48 }
49 onCancelPressed: {
50 PopupUtils.close(picker)
51 }
52 }
53 }
54
55 Connections {
56 id: stateChangeConnection
57 ignoreUnknownSignals: true
58 onStateChanged: {
59 if (picker.activeTransfer && picker.activeTransfer.state === ContentTransfer.Charged) {
60 var files = new Array();
61 for (var i = 0; i < picker.activeTransfer.items.length; i++) {
62 files.push(picker.activeTransfer.items[i].url)
63 }
64 picker.contactsImported(files);
65 PopupUtils.close(picker);
66 }
67 }
68 }
69}