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