blob: 3a08cbf36348f244eee656e3533029f0aa828b95 [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.14
21import QtQuick.Controls 2.14
22import QtQuick.Controls.Universal 2.12
23import QtQuick.Layouts 1.3
24import QtGraphicalEffects 1.14
25import QtQuick.Controls.Styles 1.4
26import QtQuick.Dialogs 1.3
27import Qt.labs.platform 1.1
28import net.jami.Models 1.0
29
30import "../../commoncomponents"
31
32Rectangle {
33 id: accountViewRect
34
35 enum RegName {
36 BLANK,
37 INVALIDFORM,
38 TAKEN,
39 FREE,
40 SEARCHING
41 }
42
43 property int regNameUi: CurrentAccountSettingsScrollPage.BLANK
44 property string registeredName: ""
45 property bool registeredIdNeedsSet: false
46
47 property int refreshVariable : 0
ababi6fa08612020-08-10 19:13:28 +020048 property int preferredColumnWidth : accountViewRect.width / 2 - 50
Sébastien Blin1f915762020-08-03 13:27:42 -040049
50 signal navigateToMainView
51 signal navigateToNewWizardView
ababia284cae2020-08-10 12:33:34 +020052 signal backArrowClicked
Sébastien Blin1f915762020-08-03 13:27:42 -040053
54 function refreshRelevantUI(){
55 refreshVariable++
56 refreshVariable--
57 }
58
ababi6fa08612020-08-10 19:13:28 +020059
Sébastien Blin1f915762020-08-03 13:27:42 -040060 Connections {
61 id: btnRegisterNameClickConnection
62 target: btnRegisterName
63
64 enabled: {
65 refreshVariable
66 switch (regNameUi) {
67 case CurrentAccountSettingsScrollPage.FREE:
68 return true
69 default:
70 return false
71 }
72 }
73
74 function onClicked() {
75 slotRegisterName()
76 }
77 }
78
79 function updateAccountInfoDisplayed() {
80 setAvatar()
81
82 accountEnableCheckBox.checked = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_Enabled()
83 displayNameLineEdit.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Alias()
84
85 var showLocalAccountConfig = (ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === "")
86 passwdPushButton.visible = showLocalAccountConfig
87 btnExportAccount.visible = showLocalAccountConfig
88 linkDevPushButton.visible = showLocalAccountConfig
89
90 registeredIdNeedsSet = (ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName() === "")
91
92 if(!registeredIdNeedsSet){
93 currentRegisteredID.text = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName()
94 } else {
95 currentRegisteredID.text = ""
96 }
97
ababi6fa08612020-08-10 19:13:28 +020098 currentRingIDText.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri()
Sébastien Blin1f915762020-08-03 13:27:42 -040099
100 // update device list view
101 updateAndShowDevicesSlot()
102
Sébastien Blin1f915762020-08-03 13:27:42 -0400103 bannedContactsLayoutWidget.visible = (bannedListModel.rowCount() > 0)
104
105 if (advanceSettingsView.visible) {
106 advanceSettingsView.updateAccountInfoDisplayedAdvance()
107 }
108 refreshRelevantUI()
109 }
110
111 function connectCurrentAccount() {
112 accountConnections_ContactModel.enabled = true
113 accountConnections_DeviceModel.enabled = true
114 }
115
116 function disconnectAccountConnections() {
117 accountConnections_ContactModel.enabled = false
118 accountConnections_DeviceModel.enabled = false
119 }
120
121 function isPhotoBoothOpened() {
122 return currentAccountAvatar.takePhotoState
123 }
124
125 function setAvatar() {
126 currentAccountAvatar.setAvatarPixmap(
127 ClientWrapper.settingsAdaptor.getAvatarImage_Base64(
ababi6fa08612020-08-10 19:13:28 +0200128 currentAccountAvatar.boothWidth),
Sébastien Blin1f915762020-08-03 13:27:42 -0400129 ClientWrapper.settingsAdaptor.getIsDefaultAvatar())
130 }
131
132 function stopBooth() {
133 currentAccountAvatar.stopBooth()
134 }
135
ababi6fa08612020-08-10 19:13:28 +0200136 function toggleBannedContacts() {
Sébastien Blin1f915762020-08-03 13:27:42 -0400137 var bannedContactsVisible = bannedContactsListWidget.visible
138 bannedContactsListWidget.visible = !bannedContactsVisible
139 updateAndShowBannedContactsSlot()
140 }
141
ababi6fa08612020-08-10 19:13:28 +0200142 function unban(index) {
Sébastien Blin1f915762020-08-03 13:27:42 -0400143 ClientWrapper.settingsAdaptor.unbanContact(index)
144 updateAndShowBannedContactsSlot()
145 }
146
147 Connections {
148 id: accountConnections_ContactModel
149 target: ClientWrapper.contactModel
150
151 function onModelUpdated(uri, needsSorted) {
152 updateAndShowBannedContactsSlot()
153 }
154
155 function onContactAdded(contactUri){
156 updateAndShowBannedContactsSlot()
157 }
158
159 function onContactRemoved(contactUri){
160 updateAndShowBannedContactsSlot()
161 }
162 }
163
164 Connections {
165 id: accountConnections_DeviceModel
166 target: ClientWrapper.deviceModel
167
168 function onDeviceAdded(id) {
169 updateAndShowDevicesSlot()
170 }
171
172 function onDeviceRevoked(id, status) {
173 updateAndShowDevicesSlot()
174 }
175
176 function onDeviceUpdated(id) {
177 updateAndShowDevicesSlot()
178 }
179 }
180
181 // slots
182 function verifyRegisteredNameSlot() {
183 if (ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName() !== "") {
184 regNameUi = CurrentAccountSettingsScrollPage.BLANK
185 } else {
186 registeredName = ClientWrapper.utilsAdaptor.stringSimplifier(
187 currentRegisteredID.text)
188 if (registeredName !== "") {
189 if (ClientWrapper.utilsAdaptor.validateRegNameForm(registeredName)) {
190 regNameUi = CurrentAccountSettingsScrollPage.SEARCHING
191 lookUpLabelTimer.restart()
192 } else {
193 regNameUi = CurrentAccountSettingsScrollPage.INVALIDFORM
194 }
195 } else {
196 regNameUi = CurrentAccountSettingsScrollPage.BLANK
197 }
198 }
199 }
200
201 Timer {
202 id: lookUpLabelTimer
203
204 interval: 300
205 onTriggered: {
206 beforeNameLookup()
207 }
208 }
209
210 function beforeNameLookup() {
211 ClientWrapper.nameDirectory.lookupName("", registeredName)
212 }
213
214 Connections {
215 target: ClientWrapper.nameDirectory
216 enabled: true
217
218 function onRegisteredNameFound(status, address, name) {
219 afterNameLookup(status, name)
220 }
221 }
222
223 function afterNameLookup(status, regName) {
224 if (registeredName === regName && regName.length > 2) {
225 switch (status) {
226 case NameDirectory.LookupStatus.NOT_FOUND:
227 regNameUi = CurrentAccountSettingsScrollPage.FREE
228 break
229 default:
230 regNameUi = CurrentAccountSettingsScrollPage.TAKEN
231 break
232 }
233 } else {
234 regNameUi = CurrentAccountSettingsScrollPage.BLANK
235 }
236 }
237
238 function setAccEnableSlot(state) {
239 ClientWrapper.accountModel.setAccountEnabled(ClientWrapper.utilsAdaptor.getCurrAccId(), state)
240 }
241
242 /*
243 * JamiFileDialog for exporting account
244 */
245 JamiFileDialog {
246 id: exportBtn_Dialog
247
248 mode: JamiFileDialog.SaveFile
249
250 title: qsTr("Export Account Here")
251 folder: StandardPaths.writableLocation(StandardPaths.DesktopLocation)
252
253 nameFilters: [qsTr("Jami archive files") + " (*.gz)", qsTr(
254 "All files") + " (*)"]
255
256 onAccepted: {
257 // is there password? If so, go to password dialog, else, go to following directly
258 var exportPath = ClientWrapper.utilsAdaptor.getAbsPath(file.toString())
259 if (ClientWrapper.accountAdaptor.hasPassword()) {
260 passwordDialog.openDialog(PasswordDialog.ExportAccount,exportPath)
261 return
262 } else {
263 if (exportPath.length > 0) {
Yang Wangc2ea0b12020-08-18 13:24:37 -0400264 var isSuccessful = ClientWrapper.accountModel.exportToFile(ClientWrapper.utilsAdaptor.getCurrAccId(), exportPath,"")
Sébastien Blin1f915762020-08-03 13:27:42 -0400265 var title = isSuccessful ? qsTr("Success") : qsTr("Error")
266 var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical
267 var info = isSuccessful ? qsTr("Export Successful") : qsTr("Export Failed")
268 msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok)
269 }
270 }
271 }
272
273 onRejected: {}
274
275 onVisibleChanged: {
276 if (!visible) {
277 rejected()
278 }
279 }
280 }
281
282 function exportAccountSlot() {
283 exportBtn_Dialog.open()
284 }
285
286 PasswordDialog {
287 id: passwordDialog
288
289 onDoneSignal: {
290 var success = (code === successCode)
291 var title = success ? qsTr("Success") : qsTr("Error")
292 var iconMode = success ? StandardIcon.Information : StandardIcon.Critical
293
294 var info
295 switch(currentPurpose){
296 case PasswordDialog.ExportAccount:
297 info = success ? qsTr("Export Successful") : qsTr("Export Failed")
298 break
299 case PasswordDialog.ChangePassword:
300 info = success ? qsTr("Password Changed Successfully") : qsTr("Password Change Failed")
301 break
302 case PasswordDialog.SetPassword:
303 info = success ? qsTr("Password Set Successfully") : qsTr("Password Set Failed")
304 passwdPushButton.text = success ? qsTr("Change Password") : qsTr("Set Password")
305 break
306 }
307
308 msgDialog.openWithParameters(title,info, iconMode, StandardButton.Ok)
309 }
310 }
311
312 MessageBox {
313 id: msgDialog
314 }
315
316 function passwordClicked() {
317 if (ClientWrapper.accountAdaptor.hasPassword()){
318 passwordDialog.openDialog(PasswordDialog.ChangePassword)
319 } else {
320 passwordDialog.openDialog(PasswordDialog.SetPassword)
321 }
322 }
323
324 function delAccountSlot() {
325 deleteAccountDialog.open()
326 }
327
328 DeleteAccountDialog{
329 id: deleteAccountDialog
330
331 anchors.centerIn: parent.Center
332 x: (parent.width - width) / 2
333 y: (parent.height - height) / 2
334
335 onAccepted: {
Sébastien Blin1f915762020-08-03 13:27:42 -0400336 ClientWrapper.accountAdaptor.setSelectedConvId()
337
338 if(ClientWrapper.utilsAdaptor.getAccountListSize() > 0){
339 navigateToMainView()
340 } else {
341 navigateToNewWizardView()
342 }
343 }
344 }
345
346 NameRegistrationDialog{
347 id : nameRegistrationDialog
348
349 onAccepted: {
350 registeredIdNeedsSet = false
351 }
352 }
353
354 function slotRegisterName() {
355 refreshRelevantUI()
356 nameRegistrationDialog.openNameRegistrationDialog(registeredName)
357 }
358
359 LinkDeviceDialog{
360 id: linkDeviceDialog
361
362 onAccepted: {
363 updateAndShowDevicesSlot()
364 }
365 }
366
367 function showLinkDevSlot() {
368 linkDeviceDialog.openLinkDeviceDialog()
369 }
370
371 RevokeDevicePasswordDialog{
372 id: revokeDevicePasswordDialog
373
374 onRevokeDeviceWithPassword:{
375 revokeDeviceWithIDAndPassword(idOfDevice, password)
376 }
377 }
378
379 MessageBox{
380 id: revokeDeviceMessageBox
381
382 property string idOfDev: ""
383
384 title:qsTr("Remove Device")
385 text :qsTr("Are you sure you wish to remove this device?")
386 icon :StandardIcon.Information
387 standardButtons: StandardButton.Ok | StandardButton.Cancel
388
389 onYes: {
390 accepted()
391 }
392
393 onNo:{
394 rejected()
395 }
396
397 onDiscard: {
398 rejected()
399 }
400
401 onAccepted: {
402 revokeDeviceWithIDAndPassword(idOfDev,"")
403 }
404
405 onRejected: {}
406 }
407
408 function removeDeviceSlot(index){
409 var idOfDevice = deviceItemListModel.data(deviceItemListModel.index(index,0), DeviceItemListModel.DeviceID)
410 if(ClientWrapper.accountAdaptor.hasPassword()){
411 revokeDevicePasswordDialog.openRevokeDeviceDialog(idOfDevice)
412 } else {
413 revokeDeviceMessageBox.idOfDev = idOfDevice
414 revokeDeviceMessageBox.open()
415 }
416 }
417
418 function revokeDeviceWithIDAndPassword(idDevice, password){
419 ClientWrapper.deviceModel.revokeDevice(idDevice, password)
420 updateAndShowDevicesSlot()
421 }
422
423 function updateAndShowBannedContactsSlot() {
424 if(bannedListModel.rowCount() <= 0){
425 bannedContactsLayoutWidget.visible = false
426 return
427 }
428
429 bannedListModel.reset()
430 }
431
432 function updateAndShowDevicesSlot() {
433 if(ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === ""){
434 linkDevPushButton.visible = true
435 }
436
437 deviceItemListModel.reset()
438 }
439
440 DeviceItemListModel {
441 id: deviceItemListModel
442 }
443
444 BannedListModel{
445 id: bannedListModel
446 }
447
448 Layout.fillHeight: true
ababi6fa08612020-08-10 19:13:28 +0200449 Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
450 anchors.centerIn: parent
Sébastien Blin1f915762020-08-03 13:27:42 -0400451
452 ColumnLayout {
ababi6fa08612020-08-10 19:13:28 +0200453 anchors.fill: accountViewRect
Sébastien Blin1f915762020-08-03 13:27:42 -0400454
455 RowLayout {
ababi6fa08612020-08-10 19:13:28 +0200456 id: accountPageTitle
457 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
458 Layout.leftMargin: JamiTheme.preferredMarginSize
Sébastien Blin1f915762020-08-03 13:27:42 -0400459 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200460 Layout.maximumHeight: 64
461 Layout.minimumHeight: 64
462 Layout.preferredHeight: 64
ababia284cae2020-08-10 12:33:34 +0200463
464 HoverableButton {
ababi6fa08612020-08-10 19:13:28 +0200465 id: backToSettingsMenuButton
ababia284cae2020-08-10 12:33:34 +0200466
467 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
ababi6fa08612020-08-10 19:13:28 +0200468 Layout.preferredWidth: JamiTheme.preferredFieldHeight
469 Layout.preferredHeight: JamiTheme.preferredFieldHeight
470 Layout.rightMargin: JamiTheme.preferredMarginSize
ababia284cae2020-08-10 12:33:34 +0200471
ababi6fa08612020-08-10 19:13:28 +0200472 radius: 32
ababia284cae2020-08-10 12:33:34 +0200473 source: "qrc:/images/icons/ic_arrow_back_24px.svg"
474 backgroundColor: "white"
475 onExitColor: "white"
Yang Wangb97bde42020-08-07 11:24:18 -0400476 toolTipText: qsTr("Toggle to display side panel")
477 hoverEnabled: true
ababia284cae2020-08-10 12:33:34 +0200478
479 visible: mainViewWindow.sidePanelHidden
480
481 onClicked: {
482 backArrowClicked()
483 }
484 }
485
ababi6fa08612020-08-10 19:13:28 +0200486 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400487 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200488 Layout.maximumHeight: JamiTheme.preferredFieldHeight
489 Layout.preferredHeight: JamiTheme.preferredFieldHeight
490 Layout.minimumHeight: JamiTheme.preferredFieldHeight
491
492 eText: qsTr("Account Settings")
493 fontSize: JamiTheme.titleFontSize
494 maxWidth: !backToSettingsMenuButton.visible ? accountViewRect.width - 100 :
495 accountViewRect.width - backToSettingsMenuButton.width - 100
496
Sébastien Blin1f915762020-08-03 13:27:42 -0400497 }
498 }
499
500 ScrollView {
ababi6fa08612020-08-10 19:13:28 +0200501 id: accountScrollView
Sébastien Blin1f915762020-08-03 13:27:42 -0400502
Sébastien Blin1f915762020-08-03 13:27:42 -0400503 property ScrollBar vScrollBar: ScrollBar.vertical
504
505 Layout.fillHeight: true
506 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200507 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400508
ababi6fa08612020-08-10 19:13:28 +0200509 width: accountViewRect.width
510 height: accountViewRect.height - accountPageTitle.height
511
512 ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
Sébastien Blin1f915762020-08-03 13:27:42 -0400513 ScrollBar.vertical.policy: ScrollBar.AsNeeded
514
Sébastien Blin1f915762020-08-03 13:27:42 -0400515 clip: true
516
ababi6fa08612020-08-10 19:13:28 +0200517 /*
518 * ScrollView Layout
519 */
Sébastien Blin1f915762020-08-03 13:27:42 -0400520 ColumnLayout {
ababi6fa08612020-08-10 19:13:28 +0200521 id: accountViewLayout
Sébastien Blin1f915762020-08-03 13:27:42 -0400522
523 Layout.fillHeight: true
ababi6fa08612020-08-10 19:13:28 +0200524 Layout.preferredWidth: accountViewRect.width
525 Layout.alignment: Qt.AlignHCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400526
ababi6fa08612020-08-10 19:13:28 +0200527 spacing: 24
Sébastien Blin1f915762020-08-03 13:27:42 -0400528
ababi6fa08612020-08-10 19:13:28 +0200529 ToggleSwitch {
530 id: accountEnableCheckBox
531
532 Layout.topMargin: JamiTheme.preferredMarginSize
533 Layout.leftMargin: JamiTheme.preferredMarginSize
534
535 labelText: qsTr("Enable")
536 fontPointSize: JamiTheme.headerFontSize
537
538 onSwitchToggled: {
539 setAccEnableSlot(checked)
540 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400541 }
542
ababi6fa08612020-08-10 19:13:28 +0200543 /*
544 * Profile
545 */
Sébastien Blin1f915762020-08-03 13:27:42 -0400546 ColumnLayout {
Sébastien Blin1f915762020-08-03 13:27:42 -0400547 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200548 Layout.fillHeight: true
549 Layout.leftMargin: JamiTheme.preferredMarginSize
550 spacing: 8
Sébastien Blin1f915762020-08-03 13:27:42 -0400551
ababi6fa08612020-08-10 19:13:28 +0200552 Label {
553 Layout.fillWidth: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400554
ababi6fa08612020-08-10 19:13:28 +0200555 Layout.maximumHeight: JamiTheme.preferredFieldHeight
556 Layout.preferredHeight: JamiTheme.preferredFieldHeight
557 Layout.minimumHeight: JamiTheme.preferredFieldHeight
Sébastien Blin1f915762020-08-03 13:27:42 -0400558
ababi6fa08612020-08-10 19:13:28 +0200559 text: qsTr("Profile")
560 font.pointSize: JamiTheme.headerFontSize
561 font.kerning: true
562
563 horizontalAlignment: Text.AlignLeft
564 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400565 }
566
ababi6fa08612020-08-10 19:13:28 +0200567 PhotoboothView {
568 id: currentAccountAvatar
Sébastien Blin1f915762020-08-03 13:27:42 -0400569
ababi6fa08612020-08-10 19:13:28 +0200570 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400571
ababi6fa08612020-08-10 19:13:28 +0200572 boothWidth: Math.min(224, accountViewRect.width - 100)
573
574 Layout.maximumWidth: boothWidth+50
575 Layout.preferredWidth: boothWidth+50
576 Layout.minimumWidth: boothWidth+50
577 Layout.maximumHeight: boothWidth+50
578 Layout.preferredHeight: boothWidth+50
579 Layout.minimumHeight: boothWidth+50
580
581 onImageAcquired: {
582 ClientWrapper.settingsAdaptor.setCurrAccAvatar(imgBase64)
583 }
584
585 onImageCleared: {
586 ClientWrapper.settingsAdaptor.clearCurrentAvatar()
587 setAvatar()
Sébastien Blin1f915762020-08-03 13:27:42 -0400588 }
589 }
590
ababi6fa08612020-08-10 19:13:28 +0200591 InfoLineEdit {
592 id: displayNameLineEdit
Sébastien Blin1f915762020-08-03 13:27:42 -0400593
ababi6fa08612020-08-10 19:13:28 +0200594 Layout.maximumWidth: JamiTheme.preferredButtonWidth
595 Layout.minimumHeight: JamiTheme.preferredFieldHeight
596 Layout.preferredHeight: JamiTheme.preferredFieldHeight
597 Layout.maximumHeight: JamiTheme.preferredFieldHeight
598
599 Layout.alignment: Qt.AlignHCenter
600
601 font.pointSize: JamiTheme.textFontSize
602 font.kerning: true
603
604 horizontalAlignment: Text.AlignHCenter
605 verticalAlignment: Text.AlignVCenter
606
607 onEditingFinished: {
608 ClientWrapper.accountAdaptor.setCurrAccDisplayName(
609 displayNameLineEdit.text)
610 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400611 }
ababi6fa08612020-08-10 19:13:28 +0200612 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400613
ababi6fa08612020-08-10 19:13:28 +0200614 /*
615 * Identity
616 */
617 ColumnLayout {
618 Layout.fillWidth: true
619 Layout.alignment: Qt.AlignHCenter
620 Layout.leftMargin: JamiTheme.preferredMarginSize
621 spacing: 8
622
623 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400624 Layout.fillWidth: true
625
ababi6fa08612020-08-10 19:13:28 +0200626 Layout.maximumHeight: JamiTheme.preferredFieldHeight
627 Layout.preferredHeight: JamiTheme.preferredFieldHeight
628 Layout.minimumHeight: JamiTheme.preferredFieldHeight
629
630 eText: qsTr("Identity")
631 maxWidth: accountViewRect.width - 72
632 fontSize: JamiTheme.headerFontSize
633 }
634
635 RowLayout {
636 spacing: 8
637 Layout.fillWidth: true
638 Layout.minimumHeight: JamiTheme.preferredFieldHeight
639 Layout.preferredHeight: JamiTheme.preferredFieldHeight
640 Layout.maximumHeight: JamiTheme.preferredFieldHeight
641 Layout.leftMargin: JamiTheme.preferredMarginSize
642
Sébastien Blin1f915762020-08-03 13:27:42 -0400643 Label {
ababi6fa08612020-08-10 19:13:28 +0200644 id: idLabel
Sébastien Blin1f915762020-08-03 13:27:42 -0400645 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200646 Layout.minimumHeight: JamiTheme.preferredFieldHeight
647 Layout.preferredHeight: JamiTheme.preferredFieldHeight
648 Layout.maximumHeight: JamiTheme.preferredFieldHeight
Sébastien Blin1f915762020-08-03 13:27:42 -0400649
ababi6fa08612020-08-10 19:13:28 +0200650 text: qsTr("Id")
651 font.pointSize: JamiTheme.settingsFontSize
Sébastien Blin1f915762020-08-03 13:27:42 -0400652 font.kerning: true
653
654 horizontalAlignment: Text.AlignLeft
655 verticalAlignment: Text.AlignVCenter
656 }
657
ababi6fa08612020-08-10 19:13:28 +0200658 TextField {
659 id: currentRingID
660
661 property var backgroundColor: "transparent"
662 property var borderColor: "transparent"
663
Sébastien Blin1f915762020-08-03 13:27:42 -0400664 Layout.fillWidth: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400665 Layout.fillHeight: true
666
ababi6fa08612020-08-10 19:13:28 +0200667 font.pointSize: JamiTheme.textFontSize
Sébastien Blin1f915762020-08-03 13:27:42 -0400668 font.kerning: true
ababi6fa08612020-08-10 19:13:28 +0200669 font.bold: true
670
671 readOnly: true
672 selectByMouse: true
673
674 text: { currentRingIDText.elidedText }
675
676 horizontalAlignment: Text.AlignRight
677 verticalAlignment: Text.AlignVCenter
678
679 background: Rectangle {
680 anchors.fill: parent
681 radius: 0
682 border.color: currentRingID.borderColor
683 border.width: 0
684 color: currentRingID.backgroundColor
685 }
686
687 TextMetrics {
688 id: currentRingIDText
689
690 elide: Text.ElideRight
691 elideWidth: accountViewRect.width - idLabel.width -JamiTheme.preferredMarginSize*3
692
693 text: { refreshVariable
694 return ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri()
695 }
696 }
697 }
698 }
699
700 RowLayout {
701 spacing: 8
702 Layout.fillWidth: true
703 Layout.minimumHeight: JamiTheme.preferredFieldHeight
704 Layout.preferredHeight: JamiTheme.preferredFieldHeight
705 Layout.maximumHeight: JamiTheme.preferredFieldHeight
706 Layout.leftMargin: JamiTheme.preferredMarginSize
707
708 ElidedTextLabel {
709 id: lblRegisteredName
710 Layout.fillWidth: true
711 Layout.minimumHeight: JamiTheme.preferredFieldHeight
712 Layout.preferredHeight: JamiTheme.preferredFieldHeight
713 Layout.maximumHeight: JamiTheme.preferredFieldHeight
714
715 eText: qsTr("Registered name")
716 fontSize: JamiTheme.settingsFontSize
717 maxWidth: 160
718 }
719
720 TextField {
721 id: currentRegisteredID
722 Layout.minimumWidth: preferredColumnWidth
723 Layout.preferredWidth: preferredColumnWidth
724 Layout.maximumWidth: preferredColumnWidth
725 Layout.minimumHeight: JamiTheme.preferredFieldHeight
726 Layout.preferredHeight: JamiTheme.preferredFieldHeight
727 Layout.maximumHeight: JamiTheme.preferredFieldHeight
728
729 placeholderText: { refreshVariable
730 var result = registeredIdNeedsSet ? qsTr("Type here to register a username") : ""
731 return result}
732
733 text: {
734 refreshVariable
735 if (!registeredIdNeedsSet){
736 return ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName()
737 } else {
738 return ""
739 }
740 }
741 selectByMouse: true
742 readOnly: { refreshVariable
743 return !registeredIdNeedsSet}
744
745 font.pointSize: JamiTheme.settingsFontSize
746 font.kerning: true
747 font.bold: { refreshVariable
748 return !registeredIdNeedsSet}
Sébastien Blin1f915762020-08-03 13:27:42 -0400749
750 horizontalAlignment: Text.AlignLeft
751 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400752
ababi6fa08612020-08-10 19:13:28 +0200753 background: Rectangle {
754 anchors.fill: parent
755 radius: {refreshVariable
756 var result = registeredIdNeedsSet ? height / 2 : 0
757 return result}
758 border.color: "transparent"
759 border.width: {refreshVariable
760 var result = registeredIdNeedsSet ? 2 : 0
761 return result}
762 color: {refreshVariable
763 var result = registeredIdNeedsSet ? Qt.rgba(
764 240 / 256, 240 / 256,
765 240 / 256,
766 1.0) : "transparent"
767 return result}
Sébastien Blin1f915762020-08-03 13:27:42 -0400768 }
769
ababi6fa08612020-08-10 19:13:28 +0200770 onTextEdited: {
771 verifyRegisteredNameSlot()
772 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400773
ababi6fa08612020-08-10 19:13:28 +0200774 onEditingFinished: {
775 verifyRegisteredNameSlot()
Sébastien Blin1f915762020-08-03 13:27:42 -0400776 }
777 }
778 }
779
Sébastien Blin1f915762020-08-03 13:27:42 -0400780 RowLayout {
781 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200782 Layout.alignment: Qt.AlignRight
783 visible:{refreshVariable
784 var result = registeredIdNeedsSet
785 && (regNameUi
786 !== CurrentAccountSettingsScrollPage.BLANK)
787 return result}
Sébastien Blin1f915762020-08-03 13:27:42 -0400788
ababi6fa08612020-08-10 19:13:28 +0200789 LookupStatusLabel {
790 id: lookupStatusLabel
Sébastien Blin1f915762020-08-03 13:27:42 -0400791 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200792
793
794
795 MouseArea {
796 id: lookupStatusLabelArea
797 anchors.fill: parent
798 property bool isHovering: false
799
800 onEntered: isHovering = true
801 onExited: isHovering = false
802
803 hoverEnabled: true
804 }
805
806 ToolTip.visible: lookupStatusLabelArea.isHovering
807 ToolTip.text: {
808 switch (regNameUi) {
809 case CurrentAccountSettingsScrollPage.BLANK:
810 return qsTr("")
811 case CurrentAccountSettingsScrollPage.INVALIDFORM:
812 return qsTr("A registered name should not have any spaces and must be at least three letters long")
813 case CurrentAccountSettingsScrollPage.TAKEN:
814 return qsTr("This name is already taken")
815 case CurrentAccountSettingsScrollPage.FREE:
816 return qsTr("Register this name")
817 case CurrentAccountSettingsScrollPage.SEARCHING:
818 return qsTr("")
819 default:
820 return qsTr("")
821 }
822 }
823
824 lookupStatusState: {
825 switch (regNameUi) {
826 case CurrentAccountSettingsScrollPage.BLANK:
827 return "Blank"
828 case CurrentAccountSettingsScrollPage.INVALIDFORM:
829 return "Invalid"
830 case CurrentAccountSettingsScrollPage.TAKEN:
831 return "Taken"
832 case CurrentAccountSettingsScrollPage.FREE:
833 return "Free"
834 case CurrentAccountSettingsScrollPage.SEARCHING:
835 return "Searching"
836 default:
837 return "Blank"
838 }
839 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400840 }
841
ababi6fa08612020-08-10 19:13:28 +0200842 HoverableButtonTextItem {
843 id: btnRegisterName
Sébastien Blin1f915762020-08-03 13:27:42 -0400844
ababi6fa08612020-08-10 19:13:28 +0200845 visible: {refreshVariable
846 var result = registeredIdNeedsSet
847 && (regNameUi
848 === CurrentAccountSettingsScrollPage.FREE)
849 return result}
Sébastien Blin1f915762020-08-03 13:27:42 -0400850
ababi6fa08612020-08-10 19:13:28 +0200851 Layout.minimumWidth: preferredColumnWidth
852 Layout.preferredWidth: preferredColumnWidth
853 Layout.maximumWidth: preferredColumnWidth
854 Layout.minimumHeight: JamiTheme.preferredFieldHeight
855 Layout.preferredHeight: JamiTheme.preferredFieldHeight
856 Layout.maximumHeight: JamiTheme.preferredFieldHeight
857
858 text: qsTr("Register")
859 font.pointSize: JamiTheme.buttonFontSize
860 font.kerning: true
861
Yang Wangb97bde42020-08-07 11:24:18 -0400862 toolTipText: qsTr("Register the name as typed")
863
ababi6fa08612020-08-10 19:13:28 +0200864 radius: height / 2
865 }
866 }
867 }
868
869 /*
870 * Buttons Pwd, Export, Delete
871 */
872 ColumnLayout {
873 Layout.fillWidth: true
874 Layout.alignment: Qt.AlignHCenter
875 Layout.leftMargin: JamiTheme.preferredMarginSize
876 spacing: 8
877
878 HoverableButtonTextItem {
879 id: passwdPushButton
880
881 visible: ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === ""
882
883 Layout.alignment: Qt.AlignHCenter
884 Layout.minimumWidth: JamiTheme.preferredButtonWidth
885 Layout.preferredWidth: JamiTheme.preferredButtonWidth
886 Layout.maximumWidth: JamiTheme.preferredButtonWidth
887 Layout.minimumHeight: JamiTheme.preferredFieldHeight
888 Layout.preferredHeight: JamiTheme.preferredFieldHeight
889 Layout.maximumHeight: JamiTheme.preferredFieldHeight
890
891 text: ClientWrapper.accountAdaptor.hasPassword() ? qsTr("Change Password") : qsTr("Set Password")
892
Yang Wangb97bde42020-08-07 11:24:18 -0400893 toolTipText: ClientWrapper.accountAdaptor.hasPassword() ? qsTr("Change the current password") : qsTr("Currently no password, press this button to set a password")
ababi6fa08612020-08-10 19:13:28 +0200894 font.pointSize: JamiTheme.textFontSize
895 font.kerning: true
896
897 radius: height / 2
898
899 onClicked: {
900 passwordClicked()
901 }
902 }
903
904 HoverableButtonTextItem {
905 id: btnExportAccount
906
907 visible: ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === ""
908
909 Layout.alignment: Qt.AlignHCenter
910 Layout.minimumWidth: JamiTheme.preferredButtonWidth
911 Layout.preferredWidth: JamiTheme.preferredButtonWidth
912 Layout.maximumWidth: JamiTheme.preferredButtonWidth
913 Layout.minimumHeight: JamiTheme.preferredFieldHeight
914 Layout.preferredHeight: JamiTheme.preferredFieldHeight
915 Layout.maximumHeight: JamiTheme.preferredFieldHeight
916
Yang Wangb97bde42020-08-07 11:24:18 -0400917 toolTipText: qsTr("Press this button to export account to a .gz file")
918
ababi6fa08612020-08-10 19:13:28 +0200919 text: qsTr("Export Account")
920 font.pointSize: JamiTheme.textFontSize
921 font.kerning: true
922
923 radius: height / 2
924
925 onClicked: {
926 exportAccountSlot()
927 }
928 }
929
930 HoverableButtonTextItem {
931 id: btnDeletAccount
932
933 backgroundColor: "red"
934 onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7)
935 onDisabledBackgroundColor: Qt.rgba(
936 255 / 256,
937 0, 0, 0.8)
938 onPressColor: backgroundColor
939 textColor: "white"
940
941 Layout.alignment: Qt.AlignHCenter
942 Layout.minimumWidth: JamiTheme.preferredButtonWidth
943 Layout.preferredWidth: JamiTheme.preferredButtonWidth
944 Layout.maximumWidth: JamiTheme.preferredButtonWidth
945 Layout.minimumHeight: JamiTheme.preferredFieldHeight
946 Layout.preferredHeight: JamiTheme.preferredFieldHeight
947 Layout.maximumHeight: JamiTheme.preferredFieldHeight
948
Yang Wangb97bde42020-08-07 11:24:18 -0400949 toolTipText: qsTr("Press this button to delete this account")
950
ababi6fa08612020-08-10 19:13:28 +0200951 text: qsTr("Delete Account")
952 font.pointSize: JamiTheme.textFontSize
953 font.kerning: true
954
955 radius: height / 2
956
957 onClicked: {
958 delAccountSlot()
959 }
960 }
961 }
962
963 /*
964 Linked devices
965 */
966 ColumnLayout {
967 Layout.fillWidth: true
968 Layout.leftMargin: JamiTheme.preferredMarginSize
969
970 Label {
971 Layout.minimumHeight: JamiTheme.preferredFieldHeight
972 Layout.preferredHeight: JamiTheme.preferredFieldHeight
973 Layout.maximumHeight: JamiTheme.preferredFieldHeight
974
975 text: qsTr("Linked Devices")
976
977 font.pointSize: JamiTheme.headerFontSize
978 font.kerning: true
979 }
980
981 ColumnLayout {
982 id: linkedDevicesLayout
983 Layout.fillWidth: true
984
985 ListViewJami {
986 id: settingsListView
987
988 Layout.fillWidth: true
989
990 Layout.minimumHeight: 160
991 Layout.preferredHeight: 160
992 Layout.maximumHeight: 160
993
994 model: deviceItemListModel
995
996 delegate: DeviceItemDelegate{
997 id: settingsListDelegate
998
999 width: settingsListView.width
1000 height: 72
1001
1002 deviceName : DeviceName
1003 deviceId: DeviceID
1004 isCurrent: IsCurrent
1005
1006 onClicked: {
1007 settingsListView.currentIndex = index
1008 }
1009
1010 onBtnRemoveDeviceClicked:{
1011 removeDeviceSlot(index)
1012 }
1013 }
1014 }
1015
1016 HoverableButtonTextItem {
1017 id: linkDevPushButton
1018
1019 visible: ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === ""
1020
1021 Layout.maximumWidth: JamiTheme.preferredButtonWidth
1022 Layout.preferredWidth: JamiTheme.preferredButtonWidth
1023 Layout.minimumWidth: JamiTheme.preferredButtonWidth
1024
1025 Layout.maximumHeight: JamiTheme.preferredFieldHeight
1026 Layout.preferredHeight: JamiTheme.preferredFieldHeight
1027 Layout.minimumHeight: JamiTheme.preferredFieldHeight
1028 Layout.alignment: Qt.AlignHCenter
Sébastien Blin1f915762020-08-03 13:27:42 -04001029
1030 radius: height / 2
1031
Yang Wangb97bde42020-08-07 11:24:18 -04001032 toolTipText: qsTr("Press to link one more device with this account")
1033
ababi6fa08612020-08-10 19:13:28 +02001034 text: qsTr("+ Link Another Device")
1035 font.pointSize: JamiTheme.textFontSize
Sébastien Blin1f915762020-08-03 13:27:42 -04001036 font.kerning: true
1037
Sébastien Blin1f915762020-08-03 13:27:42 -04001038 onClicked: {
ababi6fa08612020-08-10 19:13:28 +02001039 showLinkDevSlot()
1040 }
1041 }
1042 }
1043 }
1044
1045 /*
1046 * Banned contacts
1047 */
1048 ColumnLayout {
1049 id: bannedContactsLayoutWidget
1050
1051 Layout.fillWidth: true
1052 Layout.leftMargin: JamiTheme.preferredMarginSize
1053 Layout.alignment: Qt.AlignHCenter
1054
1055 spacing: 8
1056
1057 RowLayout {
1058 Layout.fillWidth: true
1059
1060 ElidedTextLabel {
1061
1062 id: lblBannedContacts
1063
1064 Layout.fillWidth: true
1065 Layout.maximumHeight: JamiTheme.preferredFieldHeight
1066 Layout.preferredHeight: JamiTheme.preferredFieldHeight
1067 Layout.minimumHeight: JamiTheme.preferredFieldHeight
1068
1069 eText: qsTr("Banned Contacts")
1070 fontSize: JamiTheme.headerFontSize
1071 maxWidth: accountViewRect.width - bannedContactsBtn.width -JamiTheme.preferredMarginSize*4
1072 }
1073
1074 HoverableButtonTextItem {
1075 id: bannedContactsBtn
1076
1077 Layout.alignment: Qt.AlignRight
1078
1079 Layout.maximumWidth: JamiTheme.preferredFieldHeight
1080 Layout.preferredWidth: JamiTheme.preferredFieldHeight
1081 Layout.minimumWidth: JamiTheme.preferredFieldHeight
1082
1083 Layout.minimumHeight: JamiTheme.preferredFieldHeight
1084 Layout.preferredHeight: JamiTheme.preferredFieldHeight
1085 Layout.maximumHeight: JamiTheme.preferredFieldHeight
1086
1087 radius: height / 2
1088
Yang Wangb97bde42020-08-07 11:24:18 -04001089 toolTipText: qsTr("press to open or hide display of banned contact")
1090
ababi6fa08612020-08-10 19:13:28 +02001091 source: bannedContactsListWidget.visible? "qrc:/images/icons/round-arrow_drop_up-24px.svg" :
1092 "qrc:/images/icons/round-arrow_drop_down-24px.svg"
1093 onClicked: {
1094 toggleBannedContacts()
1095 }
1096 }
1097 }
1098
1099
1100 ColumnLayout {
1101 id: bannedContactsListWidget
1102
1103 spacing: 8
1104 visible: false
1105
1106 ListViewJami {
1107 id: bannedListWidget
1108
1109 Layout.fillWidth: true
1110
1111 Layout.minimumHeight: 160
1112 Layout.preferredHeight: 160
1113 Layout.maximumHeight: 160
1114
1115 model: bannedListModel
1116
1117 delegate: BannedItemDelegate{
1118 id: bannedListDelegate
1119
1120 width: bannedListWidget.width
1121 height: 74
1122
1123 contactName : ContactName
1124 contactID: ContactID
1125 contactPicture_base64: ContactPicture
1126
1127 onClicked: {
1128 bannedListWidget.currentIndex = index
1129 }
1130
1131 onBtnReAddContactClicked: {
1132 unban(index)
Sébastien Blin1f915762020-08-03 13:27:42 -04001133 }
1134 }
1135 }
ababi6fa08612020-08-10 19:13:28 +02001136 }
1137 }
Sébastien Blin1f915762020-08-03 13:27:42 -04001138
ababi6fa08612020-08-10 19:13:28 +02001139 /*
1140 * Advanced Settigs Button
1141 */
1142
1143 RowLayout {
1144 id: rowAdvancedSettingsBtn
1145 Layout.fillWidth: true
1146 Layout.leftMargin: JamiTheme.preferredMarginSize
1147
1148 ElidedTextLabel {
1149
1150 id: lblAdvancedAccountSettings
1151
1152 Layout.fillWidth: true
1153 Layout.maximumHeight: JamiTheme.preferredFieldHeight
1154 Layout.preferredHeight: JamiTheme.preferredFieldHeight
1155 Layout.minimumHeight: JamiTheme.preferredFieldHeight
1156
1157 eText: qsTr("Advanced Account Settings")
1158
1159 fontSize: JamiTheme.headerFontSize
1160 maxWidth: accountViewRect.width - advancedAccountSettingsPButton.width -JamiTheme.preferredMarginSize*4
1161 }
1162
1163 HoverableButtonTextItem {
1164 id: advancedAccountSettingsPButton
1165
1166 Layout.leftMargin: JamiTheme.preferredMarginSize
1167
1168 Layout.minimumWidth: JamiTheme.preferredFieldHeight
1169 Layout.preferredWidth: JamiTheme.preferredFieldHeight
1170 Layout.maximumWidth: JamiTheme.preferredFieldHeight
1171 Layout.minimumHeight: JamiTheme.preferredFieldHeight
1172 Layout.preferredHeight: JamiTheme.preferredFieldHeight
1173 Layout.maximumHeight: JamiTheme.preferredFieldHeight
1174
1175 Layout.alignment: Qt.AlignHCenter
1176
1177 radius: height / 2
1178
Yang Wangb97bde42020-08-07 11:24:18 -04001179 toolTipText: qsTr("Press to display or hide advance settings")
1180
ababi6fa08612020-08-10 19:13:28 +02001181 source: {
1182 if (advanceSettingsView.visible) {
1183 return "qrc:/images/icons/round-arrow_drop_up-24px.svg"
1184 } else {
1185 return "qrc:/images/icons/round-arrow_drop_down-24px.svg"
1186 }
1187 }
1188
1189 onClicked: {
1190 advanceSettingsView.visible = !advanceSettingsView.visible
1191 if (advanceSettingsView.visible) {
1192 advanceSettingsView.updateAccountInfoDisplayedAdvance()
1193 accountScrollView.vScrollBar.position = rowAdvancedSettingsBtn.y / accountViewLayout.height
1194 } else {
1195 accountScrollView.vScrollBar.position = 0
1196 }
Sébastien Blin1f915762020-08-03 13:27:42 -04001197 }
1198 }
1199 }
1200
ababi6fa08612020-08-10 19:13:28 +02001201 /*
1202 * Advanced Settings
1203 */
1204 AdvancedSettingsView {
1205 id: advanceSettingsView
1206 Layout.leftMargin: JamiTheme.preferredMarginSize
1207 visible: false
Sébastien Blin1f915762020-08-03 13:27:42 -04001208 }
1209
ababi6fa08612020-08-10 19:13:28 +02001210 /*
1211 * To keep max width
1212 */
1213 Item {
1214 Layout.preferredWidth: accountViewRect.width - 32
1215 Layout.minimumWidth: accountViewRect.width - 32
1216 Layout.maximumWidth: JamiTheme.maximumWidthSettingsView - 32
Sébastien Blin1f915762020-08-03 13:27:42 -04001217 Layout.fillHeight: true
Sébastien Blin1f915762020-08-03 13:27:42 -04001218 }
1219 }
1220 }
Sébastien Blin1f915762020-08-03 13:27:42 -04001221 }
1222}