blob: eb5aaaba6782d2828ccdd1a16e2807f2a6936aa3 [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 net.jami.Models 1.0
26
27import "../../commoncomponents"
28
29Rectangle {
ababi6fa08612020-08-10 19:13:28 +020030 id: sipAccountViewRect
Sébastien Blin1f915762020-08-03 13:27:42 -040031 signal navigateToMainView
32 signal navigateToNewWizardView
ababia284cae2020-08-10 12:33:34 +020033 signal backArrowClicked
Sébastien Blin1f915762020-08-03 13:27:42 -040034
ababi6fa08612020-08-10 19:13:28 +020035 property int preferredColumnWidth : sipAccountViewRect.width / 2 - 50
36
Sébastien Blin1f915762020-08-03 13:27:42 -040037 function updateAccountInfoDisplayed() {
38 displaySIPNameLineEdit.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Alias()
39 usernameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_Username()
40 hostnameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_Hostname()
41 passSIPlineEdit.text = ClientWrapper.settingsAdaptor.getAccountConfig_Password()
42 proxySIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_ProxyServer()
43
44 accountSIPEnableCheckBox.checked = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_Enabled()
45
46 setAvatar()
47
48 if (advanceSIPSettingsView.visible) {
49 advanceSIPSettingsView.updateAccountInfoDisplayedAdvanceSIP()
50 }
51 }
52
53 function isPhotoBoothOpened() {
54 return currentSIPAccountAvatar.takePhotoState
55 }
56
57 function setAvatar() {
58 currentSIPAccountAvatar.setAvatarPixmap(
59 ClientWrapper.settingsAdaptor.getAvatarImage_Base64(
ababi6fa08612020-08-10 19:13:28 +020060 currentSIPAccountAvatar.boothWidth),
Sébastien Blin1f915762020-08-03 13:27:42 -040061 ClientWrapper.settingsAdaptor.getIsDefaultAvatar())
62 }
63
64 function stopBooth() {
65 currentSIPAccountAvatar.stopBooth()
66 }
67
68 // slots
69 function setAccEnableSlot(state) {
70 ClientWrapper.accountModel.setAccountEnabled(ClientWrapper.utilsAdaptor.getCurrAccId(), state)
71 }
72
73 function delAccountSlot() {
74 deleteAccountDialog_SIP.open()
75 }
76
77 DeleteAccountDialog{
78 id: deleteAccountDialog_SIP
79
80 anchors.centerIn: parent.Center
81 x: (parent.width - width) / 2
82 y: (parent.height - height) / 2
83
84 onAccepted: {
85 ClientWrapper.accountAdaptor.setSelectedAccountId()
86 ClientWrapper.accountAdaptor.setSelectedConvId()
87
88 if(ClientWrapper.utilsAdaptor.getAccountListSize() > 0){
89 navigateToMainView()
90 } else {
91 navigateToNewWizardView()
92 }
93 }
94 }
95
96 Layout.fillHeight: true
ababi6fa08612020-08-10 19:13:28 +020097 Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
98 anchors.centerIn: parent
Sébastien Blin1f915762020-08-03 13:27:42 -040099
100 ColumnLayout {
ababi6fa08612020-08-10 19:13:28 +0200101 anchors.fill: sipAccountViewRect
Sébastien Blin1f915762020-08-03 13:27:42 -0400102
103 RowLayout {
ababi6fa08612020-08-10 19:13:28 +0200104 id: sipAccountPageTitle
105 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
106 Layout.leftMargin: JamiTheme.preferredMarginSize
Sébastien Blin1f915762020-08-03 13:27:42 -0400107 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200108 Layout.maximumHeight: 64
109 Layout.minimumHeight: 64
110 Layout.preferredHeight: 64
Sébastien Blin1f915762020-08-03 13:27:42 -0400111
ababia284cae2020-08-10 12:33:34 +0200112 HoverableButton {
ababi6fa08612020-08-10 19:13:28 +0200113 id: backToSettingsMenuButton
ababia284cae2020-08-10 12:33:34 +0200114
115 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
ababi6fa08612020-08-10 19:13:28 +0200116 Layout.preferredWidth: JamiTheme.preferredFieldHeight
117 Layout.preferredHeight: JamiTheme.preferredFieldHeight
118 Layout.rightMargin: JamiTheme.preferredMarginSize
ababia284cae2020-08-10 12:33:34 +0200119
ababi6fa08612020-08-10 19:13:28 +0200120 radius: 32
ababia284cae2020-08-10 12:33:34 +0200121 source: "qrc:/images/icons/ic_arrow_back_24px.svg"
122 backgroundColor: "white"
123 onExitColor: "white"
124
125 visible: mainViewWindow.sidePanelHidden
126
127 onClicked: {
128 backArrowClicked()
129 }
130 }
131
ababi6fa08612020-08-10 19:13:28 +0200132 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400133 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200134 Layout.maximumHeight: JamiTheme.preferredFieldHeight
135 Layout.preferredHeight: JamiTheme.preferredFieldHeight
136 Layout.minimumHeight: JamiTheme.preferredFieldHeight
137
138 eText: qsTr("Account Settings")
139 fontSize: JamiTheme.titleFontSize
140 maxWidth: !backToSettingsMenuButton.visible ? sipAccountViewRect.width - 100 :
141 sipAccountViewRect.width - backToSettingsMenuButton.width - 100
142
Sébastien Blin1f915762020-08-03 13:27:42 -0400143 }
144 }
145
146 ScrollView {
ababi6fa08612020-08-10 19:13:28 +0200147 id: sipAccountScrollView
Sébastien Blin1f915762020-08-03 13:27:42 -0400148
Sébastien Blin1f915762020-08-03 13:27:42 -0400149 property ScrollBar vScrollBar: ScrollBar.vertical
150
151 Layout.fillHeight: true
152 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200153 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400154
ababi6fa08612020-08-10 19:13:28 +0200155 width: sipAccountViewRect.width
156 height: sipAccountViewRect.height - sipAccountPageTitle.height
157
158 ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
Sébastien Blin1f915762020-08-03 13:27:42 -0400159 ScrollBar.vertical.policy: ScrollBar.AsNeeded
160
Sébastien Blin1f915762020-08-03 13:27:42 -0400161 clip: true
162
163 ColumnLayout {
164 id: accountSIPLayout
165
166 Layout.fillHeight: true
ababi6fa08612020-08-10 19:13:28 +0200167 Layout.preferredWidth: sipAccountViewRect.width
168 Layout.alignment: Qt.AlignHCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400169
ababi6fa08612020-08-10 19:13:28 +0200170 spacing: 24
Sébastien Blin1f915762020-08-03 13:27:42 -0400171
ababi6fa08612020-08-10 19:13:28 +0200172 ToggleSwitch {
173 id: accountSIPEnableCheckBox
174
175 Layout.topMargin: JamiTheme.preferredMarginSize
176 Layout.leftMargin: JamiTheme.preferredMarginSize
177
178 labelText: qsTr("Enable")
179 fontPointSize: JamiTheme.headerFontSize
180
181 onSwitchToggled: {
182 setAccEnableSlot(checked)
183 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400184 }
185
186 ColumnLayout {
Sébastien Blin1f915762020-08-03 13:27:42 -0400187 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200188 Layout.fillHeight: true
189 Layout.leftMargin: JamiTheme.preferredMarginSize
190 spacing: 8
Sébastien Blin1f915762020-08-03 13:27:42 -0400191
ababi6fa08612020-08-10 19:13:28 +0200192 Label {
193 Layout.fillWidth: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400194
ababi6fa08612020-08-10 19:13:28 +0200195 Layout.maximumHeight: JamiTheme.preferredFieldHeight
196 Layout.preferredHeight: JamiTheme.preferredFieldHeight
197 Layout.minimumHeight: JamiTheme.preferredFieldHeight
Sébastien Blin1f915762020-08-03 13:27:42 -0400198
ababi6fa08612020-08-10 19:13:28 +0200199 text: qsTr("Profile")
200 font.pointSize: JamiTheme.headerFontSize
201 font.kerning: true
202
203 horizontalAlignment: Text.AlignLeft
204 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400205 }
206
ababi6fa08612020-08-10 19:13:28 +0200207 PhotoboothView {
208 id: currentSIPAccountAvatar
Sébastien Blin1f915762020-08-03 13:27:42 -0400209
ababi6fa08612020-08-10 19:13:28 +0200210 Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400211
ababi6fa08612020-08-10 19:13:28 +0200212 boothWidth: Math.min(224, sipAccountViewRect.width - 100)
213
214 Layout.maximumWidth: boothWidth+50
215 Layout.preferredWidth: boothWidth+50
216 Layout.minimumWidth: boothWidth+50
217 Layout.maximumHeight: boothWidth+50
218 Layout.preferredHeight: boothWidth+50
219 Layout.minimumHeight: boothWidth+50
220
221 onImageAcquired: {
222 ClientWrapper.settingsAdaptor.setCurrAccAvatar(imgBase64)
223 }
224
225 onImageCleared: {
226 ClientWrapper.settingsAdaptor.clearCurrentAvatar()
227 setAvatar()
Sébastien Blin1f915762020-08-03 13:27:42 -0400228 }
229 }
230
ababi6fa08612020-08-10 19:13:28 +0200231 InfoLineEdit {
232 id: displaySIPNameLineEdit
Sébastien Blin1f915762020-08-03 13:27:42 -0400233
ababi6fa08612020-08-10 19:13:28 +0200234 Layout.maximumWidth: JamiTheme.preferredButtonWidth
235 Layout.minimumHeight: JamiTheme.preferredFieldHeight
236 Layout.preferredHeight: JamiTheme.preferredFieldHeight
237 Layout.maximumHeight: JamiTheme.preferredFieldHeight
238
239 Layout.alignment: Qt.AlignHCenter
240
241 font.pointSize: JamiTheme.textFontSize
242 font.kerning: true
243
244 horizontalAlignment: Text.AlignHCenter
245 verticalAlignment: Text.AlignVCenter
246
247 onEditingFinished: {
248 ClientWrapper.accountAdaptor.setCurrAccDisplayName(
249 displaySIPNameLineEdit.text)
250 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400251 }
ababi6fa08612020-08-10 19:13:28 +0200252 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400253
ababi6fa08612020-08-10 19:13:28 +0200254
255 ColumnLayout {
256 Layout.fillWidth: true
257 Layout.alignment: Qt.AlignHCenter
258 Layout.leftMargin: JamiTheme.preferredMarginSize
259 spacing: 8
260
261 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400262 Layout.fillWidth: true
263
ababi6fa08612020-08-10 19:13:28 +0200264 Layout.maximumHeight: JamiTheme.preferredFieldHeight
265 Layout.preferredHeight: JamiTheme.preferredFieldHeight
266 Layout.minimumHeight: JamiTheme.preferredFieldHeight
267
268 eText: qsTr("Identity")
269 maxWidth: sipAccountViewRect.width - 72
270 fontSize: JamiTheme.headerFontSize
271 }
272
273
274 GridLayout {
275 rows: 4
276 columns: 2
277 flow: GridLayout.LeftToRight
278 rowSpacing: 8
279 columnSpacing: 6
280
281 Layout.fillWidth: true
282 Layout.leftMargin: JamiTheme.preferredMarginSize
283
284 // user name
285 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400286 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200287 Layout.maximumHeight: JamiTheme.preferredFieldHeight
288 Layout.preferredHeight: JamiTheme.preferredFieldHeight
289 Layout.minimumHeight: JamiTheme.preferredFieldHeight
Sébastien Blin1f915762020-08-03 13:27:42 -0400290
ababi6fa08612020-08-10 19:13:28 +0200291 eText: qsTr("Username")
292 fontSize: JamiTheme.settingsFontSize
293 maxWidth: preferredColumnWidth
294 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400295
ababi6fa08612020-08-10 19:13:28 +0200296 InfoLineEdit {
297 id: usernameSIP
298
299 fieldLayoutWidth: preferredColumnWidth
300
301 font.pointSize: JamiTheme.settingsFontSize // Albert: buttonSize?
Sébastien Blin1f915762020-08-03 13:27:42 -0400302 font.kerning: true
303
304 horizontalAlignment: Text.AlignLeft
305 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400306
ababi6fa08612020-08-10 19:13:28 +0200307 onEditingFinished: {
308 ClientWrapper.settingsAdaptor.setAccountConfig_Username(
309 usernameSIP.text)
Sébastien Blin1f915762020-08-03 13:27:42 -0400310 }
311 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400312
ababi6fa08612020-08-10 19:13:28 +0200313 // host name
314 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400315 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200316 Layout.maximumHeight: JamiTheme.preferredFieldHeight
317 Layout.preferredHeight: JamiTheme.preferredFieldHeight
318 Layout.minimumHeight: JamiTheme.preferredFieldHeight
Sébastien Blin1f915762020-08-03 13:27:42 -0400319
ababi6fa08612020-08-10 19:13:28 +0200320 eText: qsTr("Hostname")
321 fontSize: JamiTheme.settingsFontSize
322 maxWidth: preferredColumnWidth
323 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400324
ababi6fa08612020-08-10 19:13:28 +0200325 InfoLineEdit {
326 id: hostnameSIP
327
328 fieldLayoutWidth: preferredColumnWidth
329
330 font.pointSize: JamiTheme.settingsFontSize // Albert: button?
Sébastien Blin1f915762020-08-03 13:27:42 -0400331 font.kerning: true
332
333 horizontalAlignment: Text.AlignLeft
334 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400335
ababi6fa08612020-08-10 19:13:28 +0200336 onEditingFinished: {
337 ClientWrapper.settingsAdaptor.setAccountConfig_Hostname(
338 hostnameSIP.text)
Sébastien Blin1f915762020-08-03 13:27:42 -0400339 }
340 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400341
ababi6fa08612020-08-10 19:13:28 +0200342 // proxy
343 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400344 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200345 Layout.maximumHeight: JamiTheme.preferredFieldHeight
346 Layout.preferredHeight: JamiTheme.preferredFieldHeight
347 Layout.minimumHeight: JamiTheme.preferredFieldHeight
348
349 text: qsTr("Proxy")
350 font.pointSize: JamiTheme.settingsFontSize
351 maxWidth: preferredColumnWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400352 }
353
ababi6fa08612020-08-10 19:13:28 +0200354 InfoLineEdit {
355 id: proxySIP
Sébastien Blin1f915762020-08-03 13:27:42 -0400356
ababi6fa08612020-08-10 19:13:28 +0200357 fieldLayoutWidth: preferredColumnWidth
Sébastien Blin1f915762020-08-03 13:27:42 -0400358
ababi6fa08612020-08-10 19:13:28 +0200359 font.pointSize: JamiTheme.settingsFontSize // Albert
Sébastien Blin1f915762020-08-03 13:27:42 -0400360 font.kerning: true
361
ababi6fa08612020-08-10 19:13:28 +0200362 horizontalAlignment: Text.AlignLeft
363 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400364
ababi6fa08612020-08-10 19:13:28 +0200365 onEditingFinished: {
366 ClientWrapper.settingsAdaptor.setAccountConfig_ProxyServer(
367 proxySIP.text)
Sébastien Blin1f915762020-08-03 13:27:42 -0400368 }
369 }
370
ababi6fa08612020-08-10 19:13:28 +0200371 // password
372 ElidedTextLabel {
Sébastien Blin1f915762020-08-03 13:27:42 -0400373 Layout.fillWidth: true
ababi6fa08612020-08-10 19:13:28 +0200374 Layout.maximumHeight: JamiTheme.preferredFieldHeight
375 Layout.preferredHeight: JamiTheme.preferredFieldHeight
376 Layout.minimumHeight: JamiTheme.preferredFieldHeight
377
378 eText: qsTr("Password")
379 fontSize: JamiTheme.settingsFontSize
380 maxWidth: preferredColumnWidth
381 }
382
383 InfoLineEdit {
384 id: passSIPlineEdit
385
386 fieldLayoutWidth: preferredColumnWidth
387
388 font.pointSize: JamiTheme.settingsFontSize
389 font.kerning: true
390
391 echoMode: TextInput.Password
392 horizontalAlignment: Text.AlignLeft
393 verticalAlignment: Text.AlignVCenter
394
395 onEditingFinished: {
396 ClientWrapper.settingsAdaptor.setAccountConfig_Password(
397 passSIPlineEdit.text)
398 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400399 }
400 }
ababi6fa08612020-08-10 19:13:28 +0200401
402
403 HoverableButtonTextItem {
404 id: btnDeletAccount
405
406 backgroundColor: "red"
407 onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7)
408 onDisabledBackgroundColor: Qt.rgba(
409 255 / 256,
410 0, 0, 0.8)
411 onPressColor: backgroundColor
412 textColor: "white"
413
414 Layout.alignment: Qt.AlignHCenter
415 Layout.minimumWidth: JamiTheme.preferredButtonWidth
416 Layout.preferredWidth: JamiTheme.preferredButtonWidth
417 Layout.maximumWidth: JamiTheme.preferredButtonWidth
418 Layout.minimumHeight: JamiTheme.preferredFieldHeight
419 Layout.preferredHeight: JamiTheme.preferredFieldHeight
420 Layout.maximumHeight: JamiTheme.preferredFieldHeight
421
422 text: qsTr("Delete Account")
423 font.pointSize: JamiTheme.textFontSize
424 font.kerning: true
425 radius: height / 2
426
427 onClicked: {
428 delAccountSlot()
429 }
430 }
431 }
432
433 RowLayout {
434 id: rowAdvancedSettingsBtn
435 Layout.fillWidth: true
436 Layout.leftMargin: JamiTheme.preferredMarginSize
437
438 ElidedTextLabel {
439
440 id: lblAdvancedAccountSettings
441
442 Layout.fillWidth: true
443 Layout.maximumHeight: JamiTheme.preferredFieldHeight
444 Layout.preferredHeight: JamiTheme.preferredFieldHeight
445 Layout.minimumHeight: JamiTheme.preferredFieldHeight
446
447 eText: qsTr("Advanced Account Settings")
448 fontSize: JamiTheme.headerFontSize
449 maxWidth: sipAccountViewRect.width - advancedAccountSettingsSIPButton.width - 80
450 }
451
452 HoverableRadiusButton {
453 id: advancedAccountSettingsSIPButton
454
455 Layout.leftMargin: JamiTheme.preferredMarginSize
456
457 Layout.minimumWidth: JamiTheme.preferredFieldHeight
458 Layout.preferredWidth: JamiTheme.preferredFieldHeight
459 Layout.maximumWidth: JamiTheme.preferredFieldHeight
460 Layout.minimumHeight: JamiTheme.preferredFieldHeight
461 Layout.preferredHeight: JamiTheme.preferredFieldHeight
462 Layout.maximumHeight: JamiTheme.preferredFieldHeight
463
464 Layout.alignment: Qt.AlignHCenter
465
466 radius: height / 2
467
468 icon.source: {
469 if (advanceSIPSettingsView.visible) {
470 return "qrc:/images/icons/round-arrow_drop_up-24px.svg"
471 } else {
472 return "qrc:/images/icons/round-arrow_drop_down-24px.svg"
473 }
474 }
475
476 onClicked: {
477 advanceSIPSettingsView.visible = !advanceSIPSettingsView.visible
478 if(advanceSIPSettingsView.visible){
479 advanceSIPSettingsView.updateAccountInfoDisplayedAdvanceSIP()
480 sipAccountScrollView.vScrollBar.position = rowAdvancedSettingsBtn.y / accountSIPLayout.height
481 } else {
482 sipAccountScrollView.vScrollBar.position = 0
483 }
484 }
485 }
486 }
487
488 // instantiate advance setting page
489 AdvancedSIPSettingsView {
490 id: advanceSIPSettingsView
491 Layout.leftMargin: JamiTheme.preferredMarginSize
492 visible: false
Sébastien Blin1f915762020-08-03 13:27:42 -0400493 }
494
495 Item {
ababi6fa08612020-08-10 19:13:28 +0200496 Layout.preferredWidth: sipAccountViewRect.width - 32
497 Layout.minimumWidth: sipAccountViewRect.width - 32
498 Layout.maximumWidth: JamiTheme.maximumWidthSettingsView - 32
Sébastien Blin1f915762020-08-03 13:27:42 -0400499 Layout.fillHeight: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400500 }
501 }
502 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400503 }
504}