2020-08-03 13:27:42 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019-2020 by Savoir-faire Linux
|
|
|
|
* Author: Yang Wang <yang.wang@savoirfairelinux.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Window 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
import QtQuick.Controls.Universal 2.12
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.14
|
|
|
|
import net.jami.Models 1.0
|
2020-09-01 14:31:31 -04:00
|
|
|
import net.jami.Adapters 1.0
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
import "components"
|
|
|
|
|
|
|
|
Rectangle {
|
2020-09-03 21:19:10 -04:00
|
|
|
id: root
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
enum SettingsMenu{
|
|
|
|
Account,
|
|
|
|
General,
|
|
|
|
Media,
|
|
|
|
Plugin
|
|
|
|
}
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
|
|
|
if(visible){
|
|
|
|
setSelected(selectedMenu,true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSelected(sel, recovery = false){
|
2020-09-01 14:31:31 -04:00
|
|
|
profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type()
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
if(selectedMenu === sel && (!recovery)){return}
|
|
|
|
switch(sel){
|
2020-09-03 21:19:10 -04:00
|
|
|
case SettingsView.Account:
|
|
|
|
currentAccountSettingsScrollWidget.connectCurrentAccount()
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
avSettings.stopAudioMeter()
|
|
|
|
avSettings.stopPreviewing()
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
selectedMenu = sel
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
if(!settingsViewRect.isSIP){
|
|
|
|
if(currentAccountSettingsScrollWidget.isPhotoBoothOpened())
|
|
|
|
{
|
|
|
|
currentAccountSettingsScrollWidget.setAvatar()
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
currentAccountSettingsScrollWidget.updateAccountInfoDisplayed()
|
|
|
|
} else {
|
|
|
|
if(currentSIPAccountSettingsScrollWidget.isPhotoBoothOpened()) {
|
|
|
|
currentSIPAccountSettingsScrollWidget.setAvatar()
|
|
|
|
}
|
|
|
|
currentSIPAccountSettingsScrollWidget.updateAccountInfoDisplayed()
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-09-03 21:19:10 -04:00
|
|
|
break
|
|
|
|
case SettingsView.General:
|
|
|
|
try{
|
|
|
|
avSettings.stopAudioMeter()
|
|
|
|
avSettings.stopPreviewing()
|
|
|
|
} catch(erro){}
|
|
|
|
|
|
|
|
selectedMenu = sel
|
|
|
|
generalSettings.populateGeneralSettings()
|
|
|
|
break
|
|
|
|
case SettingsView.Media:
|
|
|
|
selectedMenu = sel
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
avSettings.stopPreviewing()
|
|
|
|
avSettings.populateAVSettings()
|
|
|
|
avSettings.startAudioMeter()
|
|
|
|
break
|
|
|
|
case SettingsView.Plugin:
|
|
|
|
try{
|
|
|
|
avSettings.stopAudioMeter()
|
|
|
|
avSettings.stopPreviewing()
|
|
|
|
} catch(erro){}
|
|
|
|
|
|
|
|
selectedMenu = sel
|
|
|
|
pluginSettings.populatePluginSettings()
|
|
|
|
break
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections{
|
|
|
|
id: accountListChangedConnection
|
|
|
|
target: ClientWrapper.lrcInstance
|
|
|
|
|
|
|
|
function onAccountListChanged(){
|
|
|
|
slotAccountListChanged()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// slots
|
2020-08-17 22:38:19 -04:00
|
|
|
function leaveSettingsSlot(showMainView){
|
2020-08-03 13:27:42 -04:00
|
|
|
avSettings.stopAudioMeter()
|
|
|
|
avSettings.stopPreviewing()
|
|
|
|
if(!settingsViewRect.isSIP){
|
|
|
|
currentAccountSettingsScrollWidget.stopBooth()
|
|
|
|
} else {
|
|
|
|
currentSIPAccountSettingsScrollWidget.stopBooth()
|
|
|
|
}
|
|
|
|
if (showMainView)
|
2020-08-17 22:38:19 -04:00
|
|
|
settingsViewWindowNeedToShowMainViewWindow()
|
2020-08-03 13:27:42 -04:00
|
|
|
else
|
|
|
|
settingsViewWindowNeedToShowNewWizardWindow()
|
|
|
|
}
|
|
|
|
|
|
|
|
function slotAccountListChanged(){
|
|
|
|
var accountList = ClientWrapper.accountModel.getAccountList()
|
2020-09-04 14:57:36 -04:00
|
|
|
if(accountList.length === 0)
|
|
|
|
return
|
|
|
|
|
|
|
|
currentAccountSettingsScrollWidget.disconnectAccountConnections()
|
2020-08-03 13:27:42 -04:00
|
|
|
var device = ClientWrapper.avmodel.getDefaultDevice()
|
|
|
|
if(device.length === 0){
|
|
|
|
ClientWrapper.avmodel.setCurrentVideoCaptureDevice(device)
|
|
|
|
}
|
|
|
|
}
|
2020-09-01 14:31:31 -04:00
|
|
|
property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type()
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
|
|
|
|
property int selectedMenu: SettingsView.Account
|
2020-09-03 21:19:10 -04:00
|
|
|
// signal to redirect the page to main view
|
2020-08-17 22:38:19 -04:00
|
|
|
signal settingsViewWindowNeedToShowMainViewWindow()
|
2020-08-03 13:27:42 -04:00
|
|
|
signal settingsViewWindowNeedToShowNewWizardWindow
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
signal settingsBackArrowClicked
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
visible: true
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: settingsViewRect
|
2020-09-03 21:19:10 -04:00
|
|
|
anchors.fill: root
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
property bool isSIP: {
|
|
|
|
switch (profileType) {
|
|
|
|
case Profile.Type.SIP:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
StackLayout {
|
|
|
|
id: rightSettingsWidget
|
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
property int pageIdCurrentAccountSettingsScrollPage: 0
|
|
|
|
property int pageIdCurrentSIPAccountSettingScrollPage: 1
|
|
|
|
property int pageIdGeneralSettingsPage: 2
|
|
|
|
property int pageIdAvSettingPage: 3
|
|
|
|
property int pageIdPluginSettingsPage: 4
|
|
|
|
|
|
|
|
currentIndex: {
|
|
|
|
switch(selectedMenu){
|
|
|
|
case SettingsView.Account:
|
|
|
|
if(settingsViewRect.isSIP){
|
|
|
|
return pageIdCurrentSIPAccountSettingScrollPage
|
|
|
|
} else {
|
|
|
|
return pageIdCurrentAccountSettingsScrollPage
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-08-10 12:33:34 +02:00
|
|
|
case SettingsView.General:
|
|
|
|
return pageIdGeneralSettingsPage
|
|
|
|
case SettingsView.Media:
|
|
|
|
return pageIdAvSettingPage
|
|
|
|
case SettingsView.Plugin:
|
|
|
|
return pageIdPluginSettingsPage
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
// current account setting scroll page, index 0
|
|
|
|
CurrentAccountSettingsScrollPage {
|
|
|
|
id: currentAccountSettingsScrollWidget
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
onNavigateToMainView: {
|
|
|
|
leaveSettingsSlot(true)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
onNavigateToNewWizardView: {
|
2020-08-17 22:38:19 -04:00
|
|
|
leaveSettingsSlot(false)
|
2020-08-10 12:33:34 +02:00
|
|
|
}
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
// current SIP account setting scroll page, index 1
|
|
|
|
CurrentSIPAccountSettingScrollPage {
|
|
|
|
id: currentSIPAccountSettingsScrollWidget
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
onNavigateToMainView: {
|
|
|
|
leaveSettingsSlot(true)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
onNavigateToNewWizardView: {
|
2020-08-17 22:38:19 -04:00
|
|
|
leaveSettingsSlot(false)
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
2020-08-10 12:33:34 +02:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
// general setting page, index 2
|
|
|
|
GeneralSettingsPage {
|
|
|
|
id: generalSettings
|
2020-09-03 21:19:10 -04:00
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
|
|
|
|
anchors.centerIn: parent
|
2020-08-10 12:33:34 +02:00
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-08-10 12:33:34 +02:00
|
|
|
// av setting page, index 3
|
|
|
|
AvSettingPage {
|
|
|
|
id: avSettings
|
2020-09-03 21:19:10 -04:00
|
|
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
|
|
|
|
anchors.centerIn: parent
|
2020-08-10 12:33:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// plugin setting page, index 4
|
|
|
|
PluginSettingsPage {
|
|
|
|
id: pluginSettings
|
2020-09-03 21:19:10 -04:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.maximumWidth: JamiTheme.maximumWidthSettingsView
|
|
|
|
anchors.centerIn: parent
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-10 12:33:34 +02:00
|
|
|
|
|
|
|
|
2020-09-03 21:19:10 -04:00
|
|
|
// Back button signal redirection
|
2020-08-10 12:33:34 +02:00
|
|
|
Component.onCompleted: {
|
|
|
|
currentAccountSettingsScrollWidget.backArrowClicked.connect(settingsBackArrowClicked)
|
|
|
|
currentSIPAccountSettingsScrollWidget.backArrowClicked.connect(settingsBackArrowClicked)
|
|
|
|
generalSettings.backArrowClicked.connect(settingsBackArrowClicked)
|
|
|
|
avSettings.backArrowClicked.connect(settingsBackArrowClicked)
|
|
|
|
pluginSettings.backArrowClicked.connect(settingsBackArrowClicked)
|
|
|
|
}
|
2020-08-03 13:27:42 -04:00
|
|
|
}
|