Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | import QtQuick 2.15 |
| 20 | import QtQuick.Window 2.14 |
| 21 | import QtQuick.Controls 2.14 |
| 22 | import QtQuick.Controls.Universal 2.12 |
| 23 | import QtQuick.Layouts 1.3 |
| 24 | import QtGraphicalEffects 1.14 |
| 25 | import QtQuick.Controls.Styles 1.4 |
| 26 | import QtQuick.Dialogs 1.3 |
| 27 | import Qt.labs.platform 1.1 |
| 28 | import net.jami.Models 1.0 |
| 29 | |
| 30 | import "../../commoncomponents" |
| 31 | |
| 32 | Rectangle { |
| 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 |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 48 | property int preferredColumnWidth : accountViewRect.width / 2 - 50 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 49 | |
| 50 | signal navigateToMainView |
| 51 | signal navigateToNewWizardView |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 52 | signal backArrowClicked |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 53 | |
| 54 | function refreshRelevantUI(){ |
| 55 | refreshVariable++ |
| 56 | refreshVariable-- |
| 57 | } |
| 58 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 59 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 60 | 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 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 98 | currentRingIDText.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 99 | |
| 100 | // update device list view |
| 101 | updateAndShowDevicesSlot() |
| 102 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 103 | 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( |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 128 | currentAccountAvatar.boothWidth), |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 129 | ClientWrapper.settingsAdaptor.getIsDefaultAvatar()) |
| 130 | } |
| 131 | |
| 132 | function stopBooth() { |
| 133 | currentAccountAvatar.stopBooth() |
| 134 | } |
| 135 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 136 | function toggleBannedContacts() { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 137 | var bannedContactsVisible = bannedContactsListWidget.visible |
| 138 | bannedContactsListWidget.visible = !bannedContactsVisible |
| 139 | updateAndShowBannedContactsSlot() |
| 140 | } |
| 141 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 142 | function unban(index) { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 143 | 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 Wang | c2ea0b1 | 2020-08-18 13:24:37 -0400 | [diff] [blame] | 264 | var isSuccessful = ClientWrapper.accountModel.exportToFile(ClientWrapper.utilsAdaptor.getCurrAccId(), exportPath,"") |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 265 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 336 | 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 |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 449 | Layout.maximumWidth: JamiTheme.maximumWidthSettingsView |
| 450 | anchors.centerIn: parent |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 451 | |
| 452 | ColumnLayout { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 453 | anchors.fill: accountViewRect |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 454 | |
| 455 | RowLayout { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 456 | id: accountPageTitle |
| 457 | Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter |
| 458 | Layout.leftMargin: JamiTheme.preferredMarginSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 459 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 460 | Layout.maximumHeight: 64 |
| 461 | Layout.minimumHeight: 64 |
| 462 | Layout.preferredHeight: 64 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 463 | |
| 464 | HoverableButton { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 465 | id: backToSettingsMenuButton |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 466 | |
| 467 | Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 468 | Layout.preferredWidth: JamiTheme.preferredFieldHeight |
| 469 | Layout.preferredHeight: JamiTheme.preferredFieldHeight |
| 470 | Layout.rightMargin: JamiTheme.preferredMarginSize |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 471 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 472 | radius: 32 |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 473 | source: "qrc:/images/icons/ic_arrow_back_24px.svg" |
| 474 | backgroundColor: "white" |
| 475 | onExitColor: "white" |
Yang Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 476 | toolTipText: qsTr("Toggle to display side panel") |
| 477 | hoverEnabled: true |
ababi | a284cae | 2020-08-10 12:33:34 +0200 | [diff] [blame] | 478 | |
| 479 | visible: mainViewWindow.sidePanelHidden |
| 480 | |
| 481 | onClicked: { |
| 482 | backArrowClicked() |
| 483 | } |
| 484 | } |
| 485 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 486 | ElidedTextLabel { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 487 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 488 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | |
| 500 | ScrollView { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 501 | id: accountScrollView |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 502 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 503 | property ScrollBar vScrollBar: ScrollBar.vertical |
| 504 | |
| 505 | Layout.fillHeight: true |
| 506 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 507 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 508 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 509 | width: accountViewRect.width |
| 510 | height: accountViewRect.height - accountPageTitle.height |
| 511 | |
| 512 | ScrollBar.horizontal.policy: ScrollBar.AlwaysOff |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 513 | ScrollBar.vertical.policy: ScrollBar.AsNeeded |
| 514 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 515 | clip: true |
| 516 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 517 | /* |
| 518 | * ScrollView Layout |
| 519 | */ |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 520 | ColumnLayout { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 521 | id: accountViewLayout |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 522 | |
| 523 | Layout.fillHeight: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 524 | Layout.preferredWidth: accountViewRect.width |
| 525 | Layout.alignment: Qt.AlignHCenter |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 526 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 527 | spacing: 24 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 528 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 529 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 541 | } |
| 542 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 543 | /* |
| 544 | * Profile |
| 545 | */ |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 546 | ColumnLayout { |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 547 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 548 | Layout.fillHeight: true |
| 549 | Layout.leftMargin: JamiTheme.preferredMarginSize |
| 550 | spacing: 8 |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 551 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 552 | Label { |
| 553 | Layout.fillWidth: true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 554 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 555 | Layout.maximumHeight: JamiTheme.preferredFieldHeight |
| 556 | Layout.preferredHeight: JamiTheme.preferredFieldHeight |
| 557 | Layout.minimumHeight: JamiTheme.preferredFieldHeight |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 558 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 559 | text: qsTr("Profile") |
| 560 | font.pointSize: JamiTheme.headerFontSize |
| 561 | font.kerning: true |
| 562 | |
| 563 | horizontalAlignment: Text.AlignLeft |
| 564 | verticalAlignment: Text.AlignVCenter |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 565 | } |
| 566 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 567 | PhotoboothView { |
| 568 | id: currentAccountAvatar |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 569 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 570 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 571 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 572 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 588 | } |
| 589 | } |
| 590 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 591 | InfoLineEdit { |
| 592 | id: displayNameLineEdit |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 593 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 594 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 611 | } |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 612 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 613 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 614 | /* |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 624 | Layout.fillWidth: true |
| 625 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 626 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 643 | Label { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 644 | id: idLabel |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 645 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 646 | Layout.minimumHeight: JamiTheme.preferredFieldHeight |
| 647 | Layout.preferredHeight: JamiTheme.preferredFieldHeight |
| 648 | Layout.maximumHeight: JamiTheme.preferredFieldHeight |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 649 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 650 | text: qsTr("Id") |
| 651 | font.pointSize: JamiTheme.settingsFontSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 652 | font.kerning: true |
| 653 | |
| 654 | horizontalAlignment: Text.AlignLeft |
| 655 | verticalAlignment: Text.AlignVCenter |
| 656 | } |
| 657 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 658 | TextField { |
| 659 | id: currentRingID |
| 660 | |
| 661 | property var backgroundColor: "transparent" |
| 662 | property var borderColor: "transparent" |
| 663 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 664 | Layout.fillWidth: true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 665 | Layout.fillHeight: true |
| 666 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 667 | font.pointSize: JamiTheme.textFontSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 668 | font.kerning: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 669 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 749 | |
| 750 | horizontalAlignment: Text.AlignLeft |
| 751 | verticalAlignment: Text.AlignVCenter |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 752 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 753 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 768 | } |
| 769 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 770 | onTextEdited: { |
| 771 | verifyRegisteredNameSlot() |
| 772 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 773 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 774 | onEditingFinished: { |
| 775 | verifyRegisteredNameSlot() |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 776 | } |
| 777 | } |
| 778 | } |
| 779 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 780 | RowLayout { |
| 781 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 782 | Layout.alignment: Qt.AlignRight |
| 783 | visible:{refreshVariable |
| 784 | var result = registeredIdNeedsSet |
| 785 | && (regNameUi |
| 786 | !== CurrentAccountSettingsScrollPage.BLANK) |
| 787 | return result} |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 788 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 789 | LookupStatusLabel { |
| 790 | id: lookupStatusLabel |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 791 | Layout.fillWidth: true |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 792 | |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 840 | } |
| 841 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 842 | HoverableButtonTextItem { |
| 843 | id: btnRegisterName |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 844 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 845 | visible: {refreshVariable |
| 846 | var result = registeredIdNeedsSet |
| 847 | && (regNameUi |
| 848 | === CurrentAccountSettingsScrollPage.FREE) |
| 849 | return result} |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 850 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 851 | 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 862 | toolTipText: qsTr("Register the name as typed") |
| 863 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 864 | 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 893 | toolTipText: ClientWrapper.accountAdaptor.hasPassword() ? qsTr("Change the current password") : qsTr("Currently no password, press this button to set a password") |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 894 | 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 917 | toolTipText: qsTr("Press this button to export account to a .gz file") |
| 918 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 919 | 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 949 | toolTipText: qsTr("Press this button to delete this account") |
| 950 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 951 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1029 | |
| 1030 | radius: height / 2 |
| 1031 | |
Yang Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 1032 | toolTipText: qsTr("Press to link one more device with this account") |
| 1033 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1034 | text: qsTr("+ Link Another Device") |
| 1035 | font.pointSize: JamiTheme.textFontSize |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1036 | font.kerning: true |
| 1037 | |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1038 | onClicked: { |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1039 | 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 1089 | toolTipText: qsTr("press to open or hide display of banned contact") |
| 1090 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1091 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1133 | } |
| 1134 | } |
| 1135 | } |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1136 | } |
| 1137 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1138 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1139 | /* |
| 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 Wang | b97bde4 | 2020-08-07 11:24:18 -0400 | [diff] [blame] | 1179 | toolTipText: qsTr("Press to display or hide advance settings") |
| 1180 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1181 | 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1197 | } |
| 1198 | } |
| 1199 | } |
| 1200 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1201 | /* |
| 1202 | * Advanced Settings |
| 1203 | */ |
| 1204 | AdvancedSettingsView { |
| 1205 | id: advanceSettingsView |
| 1206 | Layout.leftMargin: JamiTheme.preferredMarginSize |
| 1207 | visible: false |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1208 | } |
| 1209 | |
ababi | 6fa0861 | 2020-08-10 19:13:28 +0200 | [diff] [blame] | 1210 | /* |
| 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 Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1217 | Layout.fillHeight: true |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1218 | } |
| 1219 | } |
| 1220 | } |
Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1221 | } |
| 1222 | } |