blob: 50895fbeb999db13ca6cad7242fe0f16523ae68f [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 Qt.labs.platform 1.1
25import QtGraphicalEffects 1.14
26import net.jami.Models 1.0
27import "../../commoncomponents"
28
29Rectangle {
30 id: generalSettingsRect
31
32 function populateGeneralSettings(){
33 // settings
34 closeOrMinCheckBox.checked = ClientWrapper.settingsAdaptor.getSettingsValue_CloseOrMinimized()
35 applicationOnStartUpCheckBox.checked = ClientWrapper.utilsAdaptor.checkStartupLink()
36 notificationCheckBox.checked = ClientWrapper.settingsAdaptor.getSettingsValue_EnableNotifications()
37
38 alwaysRecordingCheckBox.checked = ClientWrapper.avmodel.getAlwaysRecord()
39 recordPreviewCheckBox.checked = ClientWrapper.avmodel.getRecordPreview()
40 recordQualityValueLabel.text = ClientWrapper.utilsAdaptor.getRecordQualityString(ClientWrapper.avmodel.getRecordQuality() / 100)
41 recordQualitySlider.value = ClientWrapper.avmodel.getRecordQuality() / 100
42
43 ClientWrapper.avmodel.setRecordPath(ClientWrapper.settingsAdaptor.getDir_Document())
44
45 autoUpdateCheckBox.checked = ClientWrapper.settingsAdaptor.getSettingsValue_AutoUpdate()
46 }
47
48 function slotSetNotifications(state){
49 ClientWrapper.settingsAdaptor.setNotifications(state)
50 }
51
52 function slotSetClosedOrMin(state){
53 ClientWrapper.settingsAdaptor.setClosedOrMin(state)
54 }
55
56 function slotSetRunOnStartUp(state){
57 ClientWrapper.settingsAdaptor.setRunOnStartUp(state)
58 }
59
60 function slotSetUpdateAutomatic(state){
61 ClientWrapper.settingsAdaptor.setUpdateAutomatic(state)
62 }
63
64 function slotAlwaysRecordingClicked(state){
65 ClientWrapper.avmodel.setAlwaysRecord(state)
66 }
67
68 function slotRecordPreviewClicked(state){
69 ClientWrapper.avmodel.setRecordPreview(state)
70 }
71
72 function slotRecordQualitySliderValueChanged(value){
73 recordQualityValueLabel.text = ClientWrapper.utilsAdaptor.getRecordQualityString(value)
74 updateRecordQualityTimer.restart()
75 }
76
ababia284cae2020-08-10 12:33:34 +020077 Timer {
Sébastien Blin1f915762020-08-03 13:27:42 -040078 id: updateRecordQualityTimer
79
80 interval: 500
81
82 onTriggered: {
83 slotRecordQualitySliderSliderReleased()
84 }
85 }
86
87 function slotRecordQualitySliderSliderReleased(){
88 var value = recordQualitySlider.value
89 ClientWrapper.avmodel.setRecordQuality(value * 100)
90 }
91
92 function openDownloadFolderSlot(){
93 downloadPathDialog.open()
94 }
95
96 FolderDialog {
97 id: downloadPathDialog
98
99 title: qsTr("Select A Folder For Your Downloads")
100 currentFolder: StandardPaths.writableLocation(StandardPaths.DownloadLocation)
101
102 onAccepted: {
103 var dir = ClientWrapper.utilsAdaptor.getAbsPath(folder.toString())
104 downloadPath = dir
105 }
106
107 onRejected: {}
108
109 onVisibleChanged: {
110 if (!visible) {
111 rejected()
112 }
113 }
114 }
115
116 function openRecordFolderSlot(){
117 recordPathDialog.open()
118 }
119
120 FolderDialog {
121 id: recordPathDialog
122
123 title: qsTr("Select A Folder For Your Recordings")
124 currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation)
125
126 onAccepted: {
127 var dir = ClientWrapper.utilsAdaptor.getAbsPath(folder.toString())
128 recordPath = dir
129 }
130
131 onRejected: {}
132
133 onVisibleChanged: {
134 if (!visible) {
135 rejected()
136 }
137 }
138 }
139
140 //TODO: complete check for update and check for Beta slot functions
141 function checkForUpdateSlot(){}
142 function installBetaSlot(){}
143
144 // settings
145 property string downloadPath: ClientWrapper.settingsAdaptor.getDir_Download()
146
147 // recording
148 //property AVModel avmodel: ClientWrapper.accountAdaptor.avModel()
149 property string recordPath: ClientWrapper.settingsAdaptor.getDir_Document()
150
ababia284cae2020-08-10 12:33:34 +0200151 signal backArrowClicked
152
Sébastien Blin1f915762020-08-03 13:27:42 -0400153 onDownloadPathChanged: {
154 if(downloadPath === "") return
155 ClientWrapper.settingsAdaptor.setDownloadPath(downloadPath)
156 }
157
158 onRecordPathChanged: {
159 if(recordPath === "") return
160
161 if(ClientWrapper.avmodel){
162 ClientWrapper.avmodel.setRecordPath(recordPath)
163 }
164 }
165
166 Layout.fillHeight: true
167 Layout.fillWidth: true
168
ababia284cae2020-08-10 12:33:34 +0200169 ScrollView {
Sébastien Blin1f915762020-08-03 13:27:42 -0400170 anchors.fill: parent
171 clip: true
172
ababia284cae2020-08-10 12:33:34 +0200173 ColumnLayout {
174 spacing: 8
Sébastien Blin1f915762020-08-03 13:27:42 -0400175
ababia284cae2020-08-10 12:33:34 +0200176 Layout.fillHeight: true
177 Layout.maximumWidth: 580
178 Layout.preferredWidth: 580
179 Layout.minimumWidth: 580
Sébastien Blin1f915762020-08-03 13:27:42 -0400180
ababia284cae2020-08-10 12:33:34 +0200181 RowLayout {
Sébastien Blin1f915762020-08-03 13:27:42 -0400182
ababia284cae2020-08-10 12:33:34 +0200183 Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
184 Layout.leftMargin: 16
185 Layout.fillWidth: true
186 Layout.maximumHeight: 64
187 Layout.minimumHeight: 64
188 Layout.preferredHeight: 64
Sébastien Blin1f915762020-08-03 13:27:42 -0400189
ababia284cae2020-08-10 12:33:34 +0200190 HoverableButton {
191 id: backToSettingsMenuButton
Sébastien Blin1f915762020-08-03 13:27:42 -0400192
ababia284cae2020-08-10 12:33:34 +0200193 Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
194 Layout.preferredWidth: 30
195 Layout.preferredHeight: 30
196
197 radius: 30
198 source: "qrc:/images/icons/ic_arrow_back_24px.svg"
199 backgroundColor: "white"
200 onExitColor: "white"
201
202 visible: mainViewWindow.sidePanelHidden
203
204 onClicked: {
205 backArrowClicked()
206 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400207 }
208
209 Label {
210 Layout.fillWidth: true
ababia284cae2020-08-10 12:33:34 +0200211 Layout.minimumHeight: 64
212 Layout.preferredHeight: 64
213 Layout.maximumHeight: 64
Sébastien Blin1f915762020-08-03 13:27:42 -0400214
215 text: qsTr("General")
ababia284cae2020-08-10 12:33:34 +0200216 font.pointSize: JamiTheme.titleFontSize
217 font.kerning: true
218
219 horizontalAlignment: Text.AlignLeft
220 verticalAlignment: Text.AlignVCenter
221 }
222 }
223
224 // system setting panel
225 ColumnLayout {
226 spacing: 6
227 Layout.fillWidth: true
228
229 Label {
230 Layout.fillWidth: true
231 Layout.minimumHeight: 21
232 Layout.preferredHeight: 21
233 Layout.maximumHeight: 21
234
235 text: qsTr("System")
236 font.pointSize: 13
Sébastien Blin1f915762020-08-03 13:27:42 -0400237 font.kerning: true
238
239 horizontalAlignment: Text.AlignLeft
240 verticalAlignment: Text.AlignVCenter
241 }
242
243 Item {
244 Layout.fillWidth: true
ababia284cae2020-08-10 12:33:34 +0200245
246 Layout.minimumHeight: 10
247 Layout.preferredHeight: 10
248 Layout.maximumHeight: 10
Sébastien Blin1f915762020-08-03 13:27:42 -0400249 }
250
Sébastien Blin1f915762020-08-03 13:27:42 -0400251 ColumnLayout {
252 spacing: 6
253 Layout.fillWidth: true
254
ababia284cae2020-08-10 12:33:34 +0200255 ToggleSwitch {
256 id: notificationCheckBox
Sébastien Blin1f915762020-08-03 13:27:42 -0400257
ababia284cae2020-08-10 12:33:34 +0200258 Layout.leftMargin: 20
Sébastien Blin1f915762020-08-03 13:27:42 -0400259
ababia284cae2020-08-10 12:33:34 +0200260 labelText: "Enable desktop notifications"
261 fontPointSize: 11
262
263 onSwitchToggled: {
264 slotSetNotifications(checked)
265 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400266 }
267
ababia284cae2020-08-10 12:33:34 +0200268 ToggleSwitch {
269 id: closeOrMinCheckBox
Sébastien Blin1f915762020-08-03 13:27:42 -0400270
ababia284cae2020-08-10 12:33:34 +0200271 Layout.leftMargin: 20
272
273 labelText: "Keep minimize on close"
274 fontPointSize: 11
275
276 onSwitchToggled: {
277 slotSetClosedOrMin(checked)
278 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400279 }
280
ababia284cae2020-08-10 12:33:34 +0200281 ToggleSwitch {
282 id: applicationOnStartUpCheckBox
283
284 Layout.leftMargin: 20
285
286 labelText: "Run on Startup"
287 fontPointSize: 11
288
289 onSwitchToggled: {
290 slotSetRunOnStartUp(checked)
291 }
292 }
293
294 RowLayout {
Sébastien Blin1f915762020-08-03 13:27:42 -0400295 spacing: 6
ababia284cae2020-08-10 12:33:34 +0200296
297 Layout.leftMargin: 20
Sébastien Blin1f915762020-08-03 13:27:42 -0400298 Layout.fillWidth: true
ababia284cae2020-08-10 12:33:34 +0200299 Layout.maximumHeight: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400300
ababia284cae2020-08-10 12:33:34 +0200301 Label {
302 Layout.fillHeight: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400303
ababia284cae2020-08-10 12:33:34 +0200304 Layout.maximumWidth: 94
305 Layout.preferredWidth: 94
306 Layout.minimumWidth: 94
Sébastien Blin1f915762020-08-03 13:27:42 -0400307
ababia284cae2020-08-10 12:33:34 +0200308 text: qsTr("Download folder")
309 font.pointSize: 10
310 font.kerning: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400311
ababia284cae2020-08-10 12:33:34 +0200312 horizontalAlignment: Text.AlignLeft
313 verticalAlignment: Text.AlignVCenter
Sébastien Blin1f915762020-08-03 13:27:42 -0400314 }
315
ababia284cae2020-08-10 12:33:34 +0200316 Item {
317 Layout.fillHeight: true
Sébastien Blin1f915762020-08-03 13:27:42 -0400318 Layout.fillWidth: true
ababia284cae2020-08-10 12:33:34 +0200319 }
320
321 HoverableRadiusButton {
322 id: downloadButton
323
324 Layout.maximumWidth: 320
325 Layout.preferredWidth: 320
326 Layout.minimumWidth: 320
327
328 Layout.minimumHeight: 30
329 Layout.preferredHeight: 30
Sébastien Blin1f915762020-08-03 13:27:42 -0400330 Layout.maximumHeight: 30
331
ababia284cae2020-08-10 12:33:34 +0200332 radius: height / 2
Sébastien Blin1f915762020-08-03 13:27:42 -0400333
ababia284cae2020-08-10 12:33:34 +0200334 icon.source: "qrc:/images/icons/round-folder-24px.svg"
335 icon.height: 24
336 icon.width: 24
Sébastien Blin1f915762020-08-03 13:27:42 -0400337
ababia284cae2020-08-10 12:33:34 +0200338 text: downloadPath
339 fontPointSize: 10
Sébastien Blin1f915762020-08-03 13:27:42 -0400340
ababia284cae2020-08-10 12:33:34 +0200341 onClicked: {
342 openDownloadFolderSlot()
Sébastien Blin1f915762020-08-03 13:27:42 -0400343 }
344 }
345 }
346 }
Sébastien Blin1f915762020-08-03 13:27:42 -0400347 }
348
349 Item {
ababia284cae2020-08-10 12:33:34 +0200350 Layout.fillWidth: true
351 Layout.minimumHeight: 20
352 Layout.preferredHeight: 20
353 Layout.maximumHeight: 20
354 }
355
356 // call recording setting panel
357 ColumnLayout {
358 spacing: 6
359 Layout.fillWidth: true
360
361 Label {
362 Layout.fillWidth: true
363 Layout.minimumHeight: 21
364 Layout.preferredHeight: 21
365 Layout.maximumHeight: 21
366
367 text: qsTr("Call Recording")
368 font.pointSize: 13
369 font.kerning: true
370
371 horizontalAlignment: Text.AlignLeft
372 verticalAlignment: Text.AlignVCenter
373 }
374
375 Item {
376 Layout.fillWidth: true
377
378 Layout.minimumHeight: 10
379 Layout.preferredHeight: 10
380 Layout.maximumHeight: 10
381 }
382
383 ColumnLayout {
384 spacing: 6
385 Layout.fillWidth: true
386
387 ToggleSwitch {
388 id: alwaysRecordingCheckBox
389
390 Layout.leftMargin: 20
391
392 labelText: "Always record calls"
393 fontPointSize: 11
394
395 onSwitchToggled: {
396 slotAlwaysRecordingClicked(checked)
397 }
398 }
399
400 ToggleSwitch {
401 id: recordPreviewCheckBox
402
403 Layout.leftMargin: 20
404
405 labelText: "Record preview video for a call"
406 fontPointSize: 11
407
408 onSwitchToggled: {
409 slotRecordPreviewClicked(checked)
410 }
411 }
412
413 RowLayout {
414 spacing: 6
415 Layout.leftMargin: 20
416 Layout.fillWidth: true
417 Layout.maximumHeight: 30
418
419 Label {
420 Layout.fillHeight: true
421
422 Layout.maximumWidth: 42
423 Layout.preferredWidth: 42
424 Layout.minimumWidth: 42
425
426 text: qsTr("Quality")
427 font.pointSize: 10
428 font.kerning: true
429
430 horizontalAlignment: Text.AlignLeft
431 verticalAlignment: Text.AlignVCenter
432 }
433
434 Item {
435 Layout.fillHeight: true
436 Layout.fillWidth: true
437 }
438
439 ColumnLayout {
440 spacing: 0
441 Layout.fillHeight: true
442
443 Layout.maximumWidth: recordQualityValueLabel.width
444 Item {
445 Layout.fillHeight: true
446 Layout.fillWidth: true
447 }
448
449 Label {
450 id: recordQualityValueLabel
451
452 Layout.minimumWidth: 40
453
454 Layout.minimumHeight: 16
455 Layout.preferredHeight: 16
456 Layout.maximumHeight: 16
457
458 text: qsTr("VALUE ")
459
460 font.pointSize: 10
461 font.kerning: true
462
463 horizontalAlignment: Text.AlignLeft
464 verticalAlignment: Text.AlignVCenter
465 }
466
467 Item {
468 Layout.fillHeight: true
469 Layout.fillWidth: true
470 }
471 }
472
473 Slider {
474 id: recordQualitySlider
475
476 Layout.fillHeight: true
477
478 Layout.maximumWidth: 320
479 Layout.preferredWidth: 320
480 Layout.minimumWidth: 320
481
482 from: 0
483 to: 500
484 stepSize: 1
485
486 onMoved: {
487 slotRecordQualitySliderValueChanged(value)
488 }
489 }
490 }
491
492 RowLayout {
493 spacing: 6
494
495 Layout.leftMargin: 20
496 Layout.fillWidth: true
497 Layout.maximumHeight: 30
498
499 Label {
500 Layout.fillHeight: true
501
502 Layout.maximumWidth: 42
503 Layout.preferredWidth: 42
504 Layout.minimumWidth: 42
505
506 text: qsTr("Save in")
507 font.pointSize: 10
508 font.kerning: true
509
510 horizontalAlignment: Text.AlignLeft
511 verticalAlignment: Text.AlignVCenter
512 }
513
514 Item {
515 Layout.fillHeight: true
516 Layout.fillWidth: true
517 }
518
519 HoverableRadiusButton {
520 id: recordPathButton
521
522 Layout.maximumWidth: 320
523 Layout.preferredWidth: 320
524 Layout.minimumWidth: 320
525
526 Layout.minimumHeight: 30
527 Layout.preferredHeight: 30
528 Layout.maximumHeight: 30
529
530 radius: height / 2
531
532 icon.source: "qrc:/images/icons/round-folder-24px.svg"
533 icon.height: 24
534 icon.width: 24
535
536 text: recordPath
537 fontPointSize: 10
538
539 onClicked: {
540 openRecordFolderSlot()
541 }
542 }
543 }
544 }
545 }
546
547 Item {
548 Layout.fillWidth: true
549 Layout.minimumHeight: 20
550 Layout.preferredHeight: 20
551 Layout.maximumHeight: 20
552 }
553
554 // update setting panel
555 ColumnLayout {
556 spacing: 6
557 Layout.fillWidth: true
558 visible: Qt.platform.os == "windows"? true : false
559
560 Label {
561 Layout.fillWidth: true
562 Layout.minimumHeight: 21
563 Layout.preferredHeight: 21
564 Layout.maximumHeight: 21
565
566 text: qsTr("Updates")
567 font.pointSize: 13
568 font.kerning: true
569
570 horizontalAlignment: Text.AlignLeft
571 verticalAlignment: Text.AlignVCenter
572 }
573
574 Item {
575 Layout.fillWidth: true
576
577 Layout.minimumHeight: 10
578 Layout.preferredHeight: 10
579 Layout.maximumHeight: 10
580 }
581
582 ColumnLayout {
583 spacing: 6
584 Layout.fillWidth: true
585
586 ToggleSwitch {
587 id: autoUpdateCheckBox
588
589 Layout.leftMargin: 20
590
591 labelText: "Check for updates automatically"
592 fontPointSize: 11
593
594 onSwitchToggled: {
595 slotSetUpdateAutomatic(checked)
596 }
597 }
598
599 RowLayout {
600 spacing: 6
601
602 Layout.leftMargin: 20
603 Layout.fillWidth: true
604 Layout.maximumHeight: 30
605
606 HoverableRadiusButton {
607 id: checkUpdateButton
608
609 Layout.maximumWidth: 275
610 Layout.preferredWidth: 275
611 Layout.minimumWidth: 275
612
613 Layout.minimumHeight: 30
614 Layout.preferredHeight: 30
615 Layout.maximumHeight: 30
616
617 radius: height / 2
618
619 text: "Check for updates now"
620 fontPointSize: 10
621
622 onClicked: {
623 checkForUpdateSlot()
624 }
625 }
626
627 Item {
628 Layout.fillHeight: true
629 Layout.fillWidth: true
630 }
631 }
632
633 RowLayout {
634 spacing: 6
635
636 Layout.leftMargin: 20
637 Layout.fillWidth: true
638 Layout.maximumHeight: 30
639
640 HoverableRadiusButton {
641 id: installBetaButton
642
643 Layout.maximumWidth: 275
644 Layout.preferredWidth: 275
645 Layout.minimumWidth: 275
646
647 Layout.minimumHeight: 30
648 Layout.preferredHeight: 30
649 Layout.maximumHeight: 30
650
651 radius: height / 2
652
653 text: "Install the latest beta version"
654 fontPointSize: 10
655
656 onClicked: {
657 installBetaSlot()
658 }
659 }
660
661 Item {
662 Layout.fillHeight: true
663 Layout.fillWidth: true
664 }
665 }
666 }
667 }
668
669 // spacer on the bottom
670 Item {
Sébastien Blin1f915762020-08-03 13:27:42 -0400671 Layout.fillHeight: true
672 Layout.fillWidth: true
673 }
674 }
675 }
676}