blob: 1d41406216bdc2128aa7e4f3695f9feecacf74a5 [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001
2/*
3 * Copyright (C) 2020 by Savoir-faire Linux
4 * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19import QtQuick 2.14
20import QtQuick.Controls 2.14
21import QtQuick.Layouts 1.14
22import QtQuick.Controls.Universal 2.12
23import net.jami.Models 1.0
24
25import "../../commoncomponents"
26
27Popup {
28 id: contactPickerPopup
29
30 property int type: ContactPicker.ContactPickerType.JAMICONFERENCE
31
32
33 /*
34 * Important to keep it one, since enum in c++ starts at one for conferences.
35 */
36 enum ContactPickerType {
37 JAMICONFERENCE = 1,
38 SIPTRANSFER
39 }
40
41 contentWidth: 250
42 contentHeight: contactPickerPopupRectColumnLayout.height + 50
43
44 padding: 0
45
46 modal: true
47
48 contentItem: Rectangle {
49 id: contactPickerPopupRect
50
51 width: 250
52
53 HoverableButton {
54 id: closeButton
55
56 anchors.top: contactPickerPopupRect.top
57 anchors.topMargin: 5
58 anchors.right: contactPickerPopupRect.right
59 anchors.rightMargin: 5
60
61 width: 30
62 height: 30
63
64 radius: 30
65 source: "qrc:/images/icons/ic_close_black_24dp.png"
66
67 onClicked: {
68 contactPickerPopup.close()
69 }
70 }
71
72 ColumnLayout {
73 id: contactPickerPopupRectColumnLayout
74
75 anchors.top: contactPickerPopupRect.top
76 anchors.topMargin: 15
77
78 Text {
79 id: contactPickerTitle
80
81 Layout.alignment: Qt.AlignCenter
82 Layout.preferredWidth: contactPickerPopupRect.width
83 Layout.preferredHeight: 30
84
85 font.pointSize: JamiTheme.textFontSize
86 font.bold: true
87
88 horizontalAlignment: Text.AlignHCenter
89 verticalAlignment: Text.AlignVCenter
90
91 text: type === ContactPicker.ContactPickerType.JAMICONFERENCE ? qsTr("Add to conference") : qsTr("Transfer this call")
92 }
93
94 ContactSearchBar {
95 id: contactPickerContactSearchBar
96
97 Layout.alignment: Qt.AlignCenter
98 Layout.topMargin: 5
99 Layout.bottomMargin: 5
100 Layout.preferredWidth: contactPickerPopupRect.width - 10
101 Layout.preferredHeight: 35
102
103 onContactSearchBarTextChanged: {
104 ContactAdapter.setSearchFilter(text)
105 }
106
107 Component.onCompleted: {
108 contactPickerContactSearchBar.setPlaceholderString(
109 qsTr("Search contacts"))
110 }
111 }
112
113 ListView {
114 id: contactPickerListView
115
116 Layout.alignment: Qt.AlignCenter
117 Layout.preferredWidth: contactPickerPopupRect.width
118 Layout.preferredHeight: 200
119
120 model: ContactAdapter.getContactSelectableModel(type)
121
122 clip: true
123
124 delegate: ContactPickerItemDelegate {
125 id: contactPickerItemDelegate
126 }
127
128 ScrollIndicator.vertical: ScrollIndicator {}
129 }
130 }
131
132 radius: 10
133 color: "white"
134 }
135
136 onAboutToShow: {
137
138
139 /*
140 * Reset the model on each show.
141 */
142 contactPickerListView.model = ContactAdapter.getContactSelectableModel(
143 type)
144 }
145
146 background: Rectangle {
147 color: "transparent"
148 }
149}