blob: 980d539a8a9d3956155deafc413247c56f17587f [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
2 * Copyright (C) 2019-2020 by Savoir-faire Linux
3 * Author: Yang Wang <yang.wang@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
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 */
18
19import QtQuick 2.15
20import QtQuick.Window 2.15
21import QtQuick.Controls 2.15
22import QtQuick.Controls.Universal 2.12
23import QtQuick.Layouts 1.3
24import QtGraphicalEffects 1.14
25import QtQuick.Controls.Styles 1.4
26import net.jami.Models 1.0
27
28import "../../commoncomponents"
29
30ItemDelegate {
31 id: deviceItemDelegate
32
33 property string contactName : ""
34 property string contactID: ""
35 property string contactPicture_base64:""
36
37 signal btnReAddContactClicked
38
39 function btnReAddContactEnter(){
40 btnReAddContact.enterBtn()
41 }
42
43 function btnReAddContactExit(){
44 btnReAddContact.exitBtn()
45 }
46
47 function btnReAddContactPress(){
48 btnReAddContact.pressBtn()
49 }
50
51 function btnReAddContactRelease(){
52 btnReAddContact.releaseBtn()
53 }
54
55 highlighted: ListView.isCurrentItem
56
57 RowLayout{
58 anchors.fill: parent
59
60 spacing: 7
61
62 Label{
63 id: labelContactAvatar
64
65 Layout.alignment: Qt.AlignVCenter
66
67 Layout.leftMargin: 7
68 Layout.topMargin: 7
69 Layout.bottomMargin: 7
70
71 Layout.minimumWidth: 48
72 Layout.preferredWidth: 48
73 Layout.maximumWidth: 48
74
75 Layout.minimumHeight: 48
76 Layout.preferredHeight: 48
77 Layout.maximumHeight: 48
78
79 background: Rectangle{
80 anchors.fill: parent
81 color: "transparent"
82 Image {
83 id: avatarImg
84
85 anchors.fill: parent
86 source: "data:image/png;base64," + contactPicture_base64
87 fillMode: Image.PreserveAspectCrop
88 layer.enabled: true
89 layer.effect: OpacityMask {
90 maskSource: Rectangle{
91 width: avatarImg.width
92 height: avatarImg.height
93 radius: {
94 var size = ((avatarImg.width <= avatarImg.height)? avatarImg.width:avatarImg.height)
95 return size /2
96 }
97 }
98 }
99 }
100 }
101 }
102
103 Item{
104 Layout.minimumWidth: 8
105 Layout.preferredWidth: 8
106 Layout.maximumWidth: 8
107
108 Layout.minimumHeight: 20
109 Layout.preferredHeight: 20
110 Layout.maximumHeight: 20
111 }
112
113 ColumnLayout{
114 Layout.fillWidth: true
115 Layout.fillHeight: true
116
117 Layout.topMargin: 7
118 Layout.bottomMargin: 7
119
120 Layout.alignment: Qt.AlignVCenter
121
122 spacing: 7
123
124 Label{
125 id: labelContactName
126
127 Layout.fillWidth: true
128 Layout.minimumWidth: 0
129 Layout.maximumWidth: 16777215
130
131 Layout.minimumHeight: 30
132 Layout.preferredHeight: 30
133 Layout.maximumHeight: 30
134
135 font.pointSize: 8
136 font.kerning: true
137
138 horizontalAlignment: Text.AlignLeft
139 verticalAlignment: Text.AlignVCenter
140
141 text: contactName === "" ? qsTr("name") : contactName
142 }
143
144 Label{
145 id: labelContactId
146
147 Layout.fillWidth: true
148 Layout.minimumWidth: 0
149 Layout.maximumWidth: 16777215
150
151 Layout.minimumHeight: 30
152 Layout.preferredHeight: 30
153 Layout.maximumHeight: 30
154
155 font.pointSize: 8
156 font.kerning: true
157
158 horizontalAlignment: Qt.AlignLeft
159 verticalAlignment: Qt.AlignVCenter
160
161 text: contactID === "" ? qsTr("id") : contactID
162 }
163 }
164
165 HoverableRadiusButton{
166 id: btnReAddContact
167
168 Layout.topMargin: 7
169 Layout.bottomMargin: 7
170
171 Layout.minimumWidth: 30
172 Layout.preferredWidth: 30
173 Layout.maximumWidth: 30
174
175 Layout.minimumHeight: 30
176 Layout.preferredHeight: 30
177 Layout.maximumHeight: 30
178
179 font.pointSize: 8
180 font.kerning: true
181
182 buttonImageHeight: height
183 buttonImageWidth: height
184
185 source:"qrc:/images/icons/ic_person_add_black_24dp_2x.png"
186
187 ToolTip.visible: isHovering
188 ToolTip.text: qsTr("Add as contact")
189
190 onClicked: {
191 btnReAddContactClicked()
192 }
193 }
194
195 Item{
196 Layout.rightMargin: 7
197
198 Layout.minimumWidth: 8
199 Layout.preferredWidth: 8
200 Layout.maximumWidth: 8
201
202 Layout.minimumHeight: 20
203 }
204 }
205}
206