blob: b5d1d2c0020c8de3cd4c365aa039ffc9416daaf3 [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 {
30 signal navigateToMainView
31 signal navigateToNewWizardView
32
33 function updateAccountInfoDisplayed() {
34 displaySIPNameLineEdit.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Alias()
35 usernameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_Username()
36 hostnameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_Hostname()
37 passSIPlineEdit.text = ClientWrapper.settingsAdaptor.getAccountConfig_Password()
38 proxySIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_ProxyServer()
39
40 accountSIPEnableCheckBox.checked = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_Enabled()
41
42 setAvatar()
43
44 if (advanceSIPSettingsView.visible) {
45 advanceSIPSettingsView.updateAccountInfoDisplayedAdvanceSIP()
46 }
47 }
48
49 function isPhotoBoothOpened() {
50 return currentSIPAccountAvatar.takePhotoState
51 }
52
53 function setAvatar() {
54 currentSIPAccountAvatar.setAvatarPixmap(
55 ClientWrapper.settingsAdaptor.getAvatarImage_Base64(
56 currentSIPAccountAvatar.boothWidht),
57 ClientWrapper.settingsAdaptor.getIsDefaultAvatar())
58 }
59
60 function stopBooth() {
61 currentSIPAccountAvatar.stopBooth()
62 }
63
64 // slots
65 function setAccEnableSlot(state) {
66 ClientWrapper.accountModel.setAccountEnabled(ClientWrapper.utilsAdaptor.getCurrAccId(), state)
67 }
68
69 function delAccountSlot() {
70 deleteAccountDialog_SIP.open()
71 }
72
73 DeleteAccountDialog{
74 id: deleteAccountDialog_SIP
75
76 anchors.centerIn: parent.Center
77 x: (parent.width - width) / 2
78 y: (parent.height - height) / 2
79
80 onAccepted: {
81 ClientWrapper.accountAdaptor.setSelectedAccountId()
82 ClientWrapper.accountAdaptor.setSelectedConvId()
83
84 if(ClientWrapper.utilsAdaptor.getAccountListSize() > 0){
85 navigateToMainView()
86 } else {
87 navigateToNewWizardView()
88 }
89 }
90 }
91
92 Layout.fillHeight: true
93 Layout.fillWidth: true
94
95 ColumnLayout {
96 anchors.fill: parent
97 spacing: 0
98
99 Item {
100 Layout.fillWidth: true
101
102 Layout.maximumHeight: 10
103 Layout.minimumHeight: 10
104 Layout.preferredHeight: 10
105
106 Layout.alignment: Qt.AlignTop
107 }
108
109 RowLayout {
110 spacing: 6
111
112 Layout.alignment: Qt.AlignTop
113
114 Layout.fillWidth: true
115 Layout.maximumHeight: 31
116 Layout.minimumHeight: 0
117 Layout.preferredHeight: accountPageTitleSIP.height
118
119 Item {
120 Layout.fillHeight: true
121
122 Layout.maximumWidth: 48
123 Layout.preferredWidth: 48
124 Layout.minimumWidth: 48
125 }
126
127 Label {
128 id: accountPageTitleSIP
129
130 Layout.preferredWidth: 133
131
132 Layout.preferredHeight: 31
133 Layout.minimumHeight: 25
134
135 text: qsTr("SIP Account")
136
137 font.pointSize: 15
138 font.kerning: true
139
140 horizontalAlignment: Text.AlignLeft
141 verticalAlignment: Text.AlignVCenter
142 }
143
144 Item {
145 Layout.fillWidth: true
146 Layout.fillHeight: true
147 }
148 }
149
150 ScrollView {
151 id: accountSIPScrollView
152
153 property ScrollBar hScrollBar: ScrollBar.horizontal
154 property ScrollBar vScrollBar: ScrollBar.vertical
155
156 Layout.fillHeight: true
157 Layout.fillWidth: true
158
159 ScrollBar.horizontal.policy: ScrollBar.AsNeeded
160 ScrollBar.vertical.policy: ScrollBar.AsNeeded
161
162 font.pointSize: 8
163 font.kerning: true
164 clip: true
165
166 ColumnLayout {
167 id: accountSIPLayout
168
169 Layout.fillHeight: true
170 Layout.maximumWidth: 598
171
172 Item {
173 Layout.fillHeight: true
174
175 Layout.maximumWidth: 30
176 Layout.preferredWidth: 30
177 Layout.minimumWidth: 30
178 }
179
180 ColumnLayout {
181 spacing: 6
182 Layout.fillHeight: true
183 Layout.fillWidth: true
184
185 Layout.leftMargin: 48
186
187 Item {
188 Layout.fillHeight: true
189
190 Layout.maximumWidth: 24
191 Layout.preferredWidth: 24
192 Layout.minimumWidth: 24
193 }
194
195 ToggleSwitch {
196 id: accountSIPEnableCheckBox
197
198 labelText: qsTr("Enable")
199 fontPointSize: 10
200
201 onSwitchToggled: {
202 setAccEnableSlot(checked)
203 }
204 }
205
206 Item {
207 Layout.fillHeight: true
208
209 Layout.maximumWidth: 20
210 Layout.preferredWidth: 20
211 Layout.minimumWidth: 20
212 }
213
214 ColumnLayout {
215 Layout.fillWidth: true
216
217 Label {
218 Layout.fillWidth: true
219
220 Layout.maximumHeight: 21
221 Layout.preferredHeight: 21
222 Layout.minimumHeight: 21
223
224 text: qsTr("Profile")
225 font.pointSize: 13
226 font.kerning: true
227
228 horizontalAlignment: Text.AlignLeft
229 verticalAlignment: Text.AlignVCenter
230 }
231
232 Item {
233 Layout.fillWidth: true
234
235 Layout.maximumHeight: 10
236 Layout.preferredHeight: 10
237 Layout.minimumHeight: 10
238 }
239
240 ColumnLayout {
241 Layout.fillWidth: true
242 layoutDirection: Qt.LeftToRight
243
244 spacing: 6
245
246 PhotoboothView {
247 id: currentSIPAccountAvatar
248
249 Layout.alignment: Qt.AlignHCenter
250
251 Layout.maximumWidth: 261
252 Layout.preferredWidth: 261
253 Layout.minimumWidth: 261
254 Layout.maximumHeight: 261
255 Layout.preferredHeight: 261
256 Layout.minimumHeight: 261
257
258 Layout.leftMargin: 20
259
260 onImageAcquired: {
261 ClientWrapper.settingsAdaptor.setCurrAccAvatar(imgBase64)
262 }
263
264 onImageCleared: {
265 ClientWrapper.settingsAdaptor.clearCurrentAvatar()
266 setAvatar()
267 }
268 }
269
270 InfoLineEdit {
271 id: displaySIPNameLineEdit
272
273 fieldLayoutWidth: 261
274
275 Layout.leftMargin: 20
276
277 font.pointSize: 10
278 font.kerning: true
279
280 horizontalAlignment: Text.AlignHCenter
281 verticalAlignment: Text.AlignVCenter
282
283 onEditingFinished: {
284 ClientWrapper.accountAdaptor.setCurrAccDisplayName(
285 displaySIPNameLineEdit.text)
286 }
287 }
288 }
289 }
290
291 Item {
292 Layout.fillWidth: true
293
294 Layout.maximumHeight: 20
295 Layout.preferredHeight: 20
296 Layout.minimumHeight: 20
297 }
298
299 ColumnLayout {
300 Layout.fillWidth: true
301 spacing: 6
302
303 Label {
304 Layout.fillWidth: true
305
306 Layout.maximumHeight: 27
307 Layout.preferredHeight: 27
308 Layout.minimumHeight: 27
309
310 text: qsTr("Identity")
311 font.pointSize: 13
312 font.kerning: true
313
314 horizontalAlignment: Text.AlignLeft
315 verticalAlignment: Text.AlignVCenter
316 }
317
318 Item {
319 Layout.fillWidth: true
320
321 Layout.maximumHeight: 10
322 Layout.preferredHeight: 10
323 Layout.minimumHeight: 10
324 }
325
326 ColumnLayout {
327 Layout.fillWidth: true
328 spacing: 6
329
330 GridLayout {
331 rows: 4
332 columns: 2
333 flow: GridLayout.LeftToRight
334 rowSpacing: 14
335 columnSpacing: 6
336
337 Layout.fillWidth: true
338
339 Layout.leftMargin: 20
340
341 // user name
342 Label {
343 Layout.maximumWidth: 76
344 Layout.preferredWidth: 76
345 Layout.minimumWidth: 76
346
347 Layout.maximumHeight: 30
348 Layout.preferredHeight: 30
349 Layout.minimumHeight: 30
350
351 text: qsTr("Username")
352 font.pointSize: 10
353 font.kerning: true
354
355 horizontalAlignment: Text.AlignLeft
356 verticalAlignment: Text.AlignVCenter
357 }
358
359 InfoLineEdit {
360 id: usernameSIP
361
362 fieldLayoutWidth: 300
363
364 font.pointSize: 10
365 font.kerning: true
366
367 horizontalAlignment: Text.AlignLeft
368 verticalAlignment: Text.AlignVCenter
369
370 onEditingFinished: {
371 ClientWrapper.settingsAdaptor.setAccountConfig_Username(
372 usernameSIP.text)
373 }
374 }
375
376 // host name
377 Label {
378 Layout.maximumWidth: 76
379 Layout.preferredWidth: 76
380 Layout.minimumWidth: 76
381
382 Layout.maximumHeight: 30
383 Layout.preferredHeight: 30
384 Layout.minimumHeight: 30
385
386 text: qsTr("Hostname")
387 font.pointSize: 10
388 font.kerning: true
389
390 horizontalAlignment: Text.AlignLeft
391 verticalAlignment: Text.AlignVCenter
392 }
393
394 InfoLineEdit {
395 id: hostnameSIP
396
397 fieldLayoutWidth: 300
398
399 font.pointSize: 10
400 font.kerning: true
401
402 horizontalAlignment: Text.AlignLeft
403 verticalAlignment: Text.AlignVCenter
404
405 onEditingFinished: {
406 ClientWrapper.settingsAdaptor.setAccountConfig_Hostname(
407 hostnameSIP.text)
408 }
409 }
410
411 // proxy
412 Label {
413 Layout.maximumWidth: 76
414 Layout.preferredWidth: 76
415 Layout.minimumWidth: 76
416
417 Layout.maximumHeight: 30
418 Layout.preferredHeight: 30
419 Layout.minimumHeight: 30
420
421 text: qsTr("Proxy")
422 font.pointSize: 10
423 font.kerning: true
424
425 horizontalAlignment: Text.AlignLeft
426 verticalAlignment: Text.AlignVCenter
427 }
428
429 InfoLineEdit {
430 id: proxySIP
431
432 fieldLayoutWidth: 300
433
434 font.pointSize: 10
435 font.kerning: true
436
437 horizontalAlignment: Text.AlignLeft
438 verticalAlignment: Text.AlignVCenter
439
440 onEditingFinished: {
441 ClientWrapper.settingsAdaptor.setAccountConfig_ProxyServer(
442 proxySIP.text)
443 }
444 }
445
446 // password
447 Label {
448 Layout.maximumWidth: 76
449 Layout.preferredWidth: 76
450 Layout.minimumWidth: 76
451
452 Layout.maximumHeight: 30
453 Layout.preferredHeight: 30
454 Layout.minimumHeight: 30
455
456 text: qsTr("Password")
457 font.pointSize: 10
458 font.kerning: true
459
460 horizontalAlignment: Text.AlignLeft
461 verticalAlignment: Text.AlignVCenter
462 }
463
464 InfoLineEdit {
465 id: passSIPlineEdit
466
467 fieldLayoutWidth: 300
468
469 font.pointSize: 10
470 font.kerning: true
471
472 echoMode: TextInput.Password
473 horizontalAlignment: Text.AlignLeft
474 verticalAlignment: Text.AlignVCenter
475
476 onEditingFinished: {
477 ClientWrapper.settingsAdaptor.setAccountConfig_Password(
478 passSIPlineEdit.text)
479 }
480 }
481 }
482
483 Item {
484 Layout.fillWidth: true
485
486 Layout.maximumHeight: 10
487 Layout.preferredHeight: 10
488 Layout.minimumHeight: 10
489 }
490
491 RowLayout {
492 Layout.fillWidth: true
493 Layout.maximumHeight: 30
494 Layout.leftMargin: 20
495
496 HoverableButtonTextItem {
497 id: btnSIPDeletAccount
498
499 backgroundColor: "red"
500 onEnterColor: Qt.rgba(150 / 256, 0, 0, 0.7)
501 onDisabledBackgroundColor: Qt.rgba(
502 255 / 256,
503 0, 0, 0.8)
504 onPressColor: backgroundColor
505 textColor: "white"
506
507 Layout.maximumWidth: 261
508 Layout.preferredWidth: 261
509 Layout.minimumWidth: 261
510
511 Layout.maximumHeight: 30
512 Layout.preferredHeight: 30
513 Layout.minimumHeight: 30
514
515 radius: height / 2
516
517 text: qsTr("Delete Account")
518 font.pointSize: 10
519 font.kerning: true
520
521 onClicked: {
522 delAccountSlot()
523 }
524 }
525
526 Item {
527 Layout.fillHeight: true
528 Layout.fillWidth: true
529 }
530 }
531 }
532 }
533
534 Item {
535 Layout.fillWidth: true
536
537 Layout.maximumHeight: 40
538 Layout.preferredHeight: 40
539 Layout.minimumHeight: 40
540 }
541
542 RowLayout {
543 Layout.fillWidth: true
544
545 Layout.minimumHeight: 30
546 Layout.preferredHeight: 30
547 Layout.maximumHeight: 30
548
549 Layout.minimumWidth: 598
550 Layout.preferredWidth: 598
551
552 Item {
553 Layout.fillWidth: true
554 Layout.fillHeight: true
555 }
556
557 HoverableRadiusButton {
558 id: advancedAccountSettingsSIPButton
559
560 Layout.minimumWidth: 180
561
562 Layout.minimumHeight: 30
563 Layout.preferredHeight: 30
564 Layout.maximumHeight: 30
565
566 radius: height / 2
567
568 text: qsTr("Advanced Account Settings")
569 font.pointSize: 10
570 font.kerning: true
571
572 icon.source: {
573 if (advanceSIPSettingsView.visible) {
574 return "qrc:/images/icons/round-arrow_drop_up-24px.svg"
575 } else {
576 return "qrc:/images/icons/round-arrow_drop_down-24px.svg"
577 }
578 }
579
580 icon.height: 24
581 icon.width: 24
582
583 onClicked: {
584 advanceSIPSettingsView.visible = !advanceSIPSettingsView.visible
585 if(advanceSIPSettingsView.visible){
586 advanceSIPSettingsView.updateAccountInfoDisplayedAdvanceSIP()
587 var coor = advancedAccountSettingsSIPButton.mapToItem(accountSIPLayout,advancedAccountSettingsSIPButton.x,advancedAccountSettingsSIPButton.y)
588 accountSIPScrollView.vScrollBar.position = coor.y / accountSIPLayout.height
589 } else {
590 accountSIPScrollView.vScrollBar.position = 0
591 }
592 }
593 }
594
595 Item {
596 Layout.fillWidth: true
597 Layout.fillHeight: true
598 }
599 }
600 }
601
602 Item {
603 Layout.fillWidth: true
604
605 Layout.minimumHeight: 48
606 Layout.preferredHeight: 48
607 Layout.maximumHeight: 48
608 }
609
610 ColumnLayout {
611 spacing: 6
612 Layout.fillHeight: true
613 Layout.fillWidth: true
614
615 Layout.leftMargin: 30
616
617 // instantiate advance setting page
618 AdvancedSIPSettingsView {
619 id: advanceSIPSettingsView
620
621 Layout.leftMargin: 10
622 visible: false
623 }
624 }
625 }
626 }
627
628 Item {
629 Layout.fillHeight: true
630 Layout.fillWidth: true
631 }
632 }
633}