Skip to content
Snippets Groups Projects
Commit 3e6aefed authored by Edric Milaret's avatar Edric Milaret Committed by gerrit2
Browse files

settings : add advanced and security settings

Refs #75237

Change-Id: I0438729d872a17c14f88f2eb6c67fb2af913ed17
parent aa50336a
Branches
Tags
No related merge requests found
...@@ -41,7 +41,8 @@ SOURCES += main.cpp\ ...@@ -41,7 +41,8 @@ SOURCES += main.cpp\
windowscontactbackend.cpp \ windowscontactbackend.cpp \
historydelegate.cpp \ historydelegate.cpp \
contactdelegate.cpp \ contactdelegate.cpp \
selectareadialog.cpp selectareadialog.cpp \
accountserializationadapter.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
callwidget.h \ callwidget.h \
...@@ -58,7 +59,8 @@ HEADERS += mainwindow.h \ ...@@ -58,7 +59,8 @@ HEADERS += mainwindow.h \
windowscontactbackend.h \ windowscontactbackend.h \
historydelegate.h \ historydelegate.h \
contactdelegate.h \ contactdelegate.h \
selectareadialog.h selectareadialog.h \
accountserializationadapter.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
callwidget.ui \ callwidget.ui \
......
...@@ -20,16 +20,20 @@ ...@@ -20,16 +20,20 @@
#include "ui_accountdetails.h" #include "ui_accountdetails.h"
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QFileDialog>
#include <QPushButton>
#include "accountmodel.h"
#include "account.h"
#include "accountdetails.h" #include "accountdetails.h"
#include "audio/codecmodel.h" #include "audio/codecmodel.h"
#include "protocolmodel.h"
#include "certificate.h"
#include "ciphermodel.h"
AccountDetails::AccountDetails(QWidget *parent) : AccountDetails::AccountDetails(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::AccountDetails), ui(new Ui::AccountDetails),
codecModel_(nullptr), codecModel_(nullptr),
currentAccount_(nullptr),
codecModelModified(false) codecModelModified(false)
{ {
ui->setupUi(this); ui->setupUi(this);
...@@ -48,20 +52,16 @@ AccountDetails::AccountDetails(QWidget *parent) : ...@@ -48,20 +52,16 @@ AccountDetails::AccountDetails(QWidget *parent) :
ui->videoCodecView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->videoCodecView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->videoCodecView->setShowGrid(false); ui->videoCodecView->setShowGrid(false);
ui->hashValue->setAlignment(Qt::AlignCenter); ui->lrcfg_username->setAlignment(Qt::AlignCenter);
connect(ui->audioCodecView, SIGNAL(cellChanged(int,int)), connect(ui->audioCodecView, SIGNAL(cellChanged(int,int)),
this, SLOT(audio_codec_checked(int, int))); this, SLOT(audio_codec_checked(int, int)));
connect(ui->videoCodecView, SIGNAL(cellChanged(int,int)), connect(ui->videoCodecView, SIGNAL(cellChanged(int,int)),
this, SLOT(video_codec_checked(int,int))); this, SLOT(video_codec_checked(int,int)));
connect(ui->videoEnabledCheckBox, SIGNAL(toggled(bool)),
this, SLOT(setVideoEnabled(bool))); connect(ui->lrcfg_tlsCaListCertificate, SIGNAL(clicked(bool)), this, SLOT(onCertButtonClicked()));
connect(ui->autoAnswerCheckBox, SIGNAL(toggled(bool)), connect(ui->lrcfg_tlsCertificate, SIGNAL(clicked(bool)), this, SLOT(onCertButtonClicked()));
this, SLOT(setAutoAnswer(bool))); connect(ui->lrcfg_tlsPrivateKeyCertificate, SIGNAL(clicked(bool)), this, SLOT(onCertButtonClicked()));
connect(ui->aliasValue, SIGNAL(editingFinished()),
this, SLOT(aliasChanged()));
connect(ui->bootstrapLineEdit, SIGNAL(editingFinished()),
this, SLOT(bootstrapChanged()));
} }
AccountDetails::~AccountDetails() AccountDetails::~AccountDetails()
...@@ -144,6 +144,10 @@ AccountDetails::reloadCodec(CodecType type) ...@@ -144,6 +144,10 @@ AccountDetails::reloadCodec(CodecType type)
void void
AccountDetails::setAccount(Account* currentAccount) { AccountDetails::setAccount(Account* currentAccount) {
if (currentAccount_) {
currentAccount_->performAction(Account::EditAction::SAVE);
}
currentAccount_ = currentAccount; currentAccount_ = currentAccount;
if (codecModel_ && codecModelModified) if (codecModel_ && codecModelModified)
...@@ -151,75 +155,77 @@ AccountDetails::setAccount(Account* currentAccount) { ...@@ -151,75 +155,77 @@ AccountDetails::setAccount(Account* currentAccount) {
codecModel_ = currentAccount->codecModel(); codecModel_ = currentAccount->codecModel();
//FIX ME : Reorganize this in group ui->typeValueLabel->setText(currentAccount_->protocolModel()->
ui->hashValue->hide(); selectionModel()->currentIndex().data().value<QString>());
ui->hashLabel->hide();
ui->aliasValue->hide(); ui->publishGroup->disconnect();
ui->aliasLabel->hide();
ui->bootstrapLabel->hide(); if (currentAccount_->isPublishedSameAsLocal())
ui->bootstrapLineEdit->hide(); ui->puslishedSameAsLocalRadio->setChecked(true);
ui->hostnameLabel->hide(); else
ui->hostnameEdit->hide(); ui->customPublishedRadio->setChecked(true);
ui->usernameEdit->hide();
ui->usernameLabel->hide(); ui->publishGroup->setId(ui->puslishedSameAsLocalRadio, 1);
ui->passwordEdit->hide(); ui->publishGroup->setId(ui->customPublishedRadio, 0);
ui->passwordLabel->hide(); ui->lrcfg_publishedAddress->setEnabled(!currentAccount_->isPublishedSameAsLocal());
ui->proxyEdit->hide(); ui->lrcfg_publishedPort->setEnabled(!currentAccount_->isPublishedSameAsLocal());
ui->proxyLabel->hide();
ui->voicemailLabel->hide(); connect(ui->publishGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
ui->voicemailEdit->hide(); [=](int id) {
currentAccount_->setPublishedSameAsLocal(static_cast<bool>(id));
switch (currentAccount_->protocol()) { });
case Account::Protocol::SIP:
if (currentAccount_ != AccountModel::instance()->ip2ip()) { switch (currentAccount_->DTMFType()) {
ui->typeValueLabel->setText("SIP"); case DtmfType::OverRtp:
ui->aliasValue->setText(currentAccount_->alias()); ui->rtpRadio->setChecked(true);
ui->hostnameEdit->setText(currentAccount_->hostname());
ui->usernameEdit->setText(currentAccount_->username());
ui->passwordEdit->setText(currentAccount_->password());
ui->proxyEdit->setText(currentAccount_->proxy());
ui->voicemailEdit->setText(currentAccount_->mailbox());
ui->aliasLabel->show();
ui->aliasValue->show();
ui->hostnameLabel->show();
ui->hostnameEdit->show();
ui->usernameEdit->show();
ui->usernameLabel->show();
ui->passwordEdit->show();
ui->passwordLabel->show();
ui->proxyEdit->show();
ui->proxyLabel->show();
ui->voicemailLabel->show();
ui->voicemailEdit->show();
} else {
ui->typeValueLabel->setText("IP2IP");
}
break;
case Account::Protocol::IAX:
ui->typeValueLabel->setText("IAX");
break;
case Account::Protocol::RING:
ui->typeValueLabel->setText("RING");
ui->aliasValue->setText(currentAccount_->alias());
ui->hashValue->setText(currentAccount_->username());
ui->bootstrapLineEdit->setText(currentAccount_->hostname());
ui->hashValue->show();
ui->hashLabel->show();
ui->aliasLabel->show();
ui->aliasValue->show();
ui->bootstrapLabel->show();
ui->bootstrapLineEdit->show();
break; break;
default: case DtmfType::OverSip:
ui->sipRadio->setChecked(true);
break; break;
} }
reloadCodec(); ui->dtmfGroup->disconnect();
ui->dtmfGroup->setId(ui->rtpRadio, DtmfType::OverRtp);
ui->dtmfGroup->setId(ui->sipRadio, DtmfType::OverSip);
connect(ui->dtmfGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[=](int id){ currentAccount_->setDTMFType(static_cast<DtmfType>(id)); });
ui->keyExchangeModelCombo->setModel(currentAccount_->keyExchangeModel());
ui->tlsProtocoCombo->setModel(currentAccount_->tlsMethodModel());
ui->videoEnabledCheckBox->setChecked(currentAccount_->isVideoEnabled()); if (currentAccount_->tlsCaListCertificate())
ui->autoAnswerCheckBox->setChecked(currentAccount_->isAutoAnswer()); ui->lrcfg_tlsCaListCertificate->setText(currentAccount_->tlsCaListCertificate()->path().fileName());
ui->upnpCheckBox->setChecked(currentAccount_->isUpnpEnabled()); if (currentAccount_->tlsCertificate())
ui->lrcfg_tlsCertificate->setText(currentAccount_->tlsCertificate()->path().fileName());
if (currentAccount_->tlsPrivateKeyCertificate())
ui->lrcfg_tlsPrivateKeyCertificate->setText(currentAccount_->tlsPrivateKeyCertificate()->path().fileName());
certMap_[ui->lrcfg_tlsCaListCertificate->objectName()] = &currentAccount_->setTlsCaListCertificate;
certMap_[ui->lrcfg_tlsCertificate->objectName()] = &currentAccount_->setTlsCertificate;
certMap_[ui->lrcfg_tlsPrivateKeyCertificate->objectName()] = &currentAccount_->setTlsPrivateKeyCertificate;
ui->srtpEnabled->disconnect();
connect(ui->srtpEnabled, &QCheckBox::toggled, [=](bool checked) {
currentAccount_->setSrtpEnabled(checked);
ui->lrcfg_srtpRtpFallback->setEnabled(checked);
ui->keyExchangeModelCombo->setEnabled(checked);
});
ui->srtpEnabled->setChecked(currentAccount_->isSrtpEnabled());
if (currentAccount_->cipherModel()->useDefault())
ui->defaultCipherRadio->setChecked(true);
else
ui->customCipherRadio->setChecked(true);
connect(ui->defaultCipherRadio, &QRadioButton::toggled, [=](bool checked) {
currentAccount_->cipherModel()->setUseDefault(checked);
});
ui->cipherListView->setModel(currentAccount_->cipherModel());
reloadCodec();
} }
void void
...@@ -244,26 +250,6 @@ AccountDetails::video_codec_checked(int row, int column) { ...@@ -244,26 +250,6 @@ AccountDetails::video_codec_checked(int row, int column) {
codecModelModified = true; codecModelModified = true;
} }
void
AccountDetails::setVideoEnabled(bool enabled) {
currentAccount_->setVideoEnabled(enabled);
}
void
AccountDetails::setAutoAnswer(bool enabled) {
currentAccount_->setAutoAnswer(enabled);
}
void
AccountDetails::aliasChanged() {
currentAccount_->setAlias(ui->aliasValue->text());
}
void
AccountDetails::bootstrapChanged() {
currentAccount_->setHostname(ui->bootstrapLineEdit->text());
}
void void
AccountDetails::on_upAudioButton_clicked() AccountDetails::on_upAudioButton_clicked()
{ {
...@@ -322,36 +308,12 @@ AccountDetails::save() { ...@@ -322,36 +308,12 @@ AccountDetails::save() {
codecModel_->save(); codecModel_->save();
} }
void
AccountDetails::on_hostnameEdit_editingFinished()
{
currentAccount_->setHostname(ui->hostnameEdit->text());
}
void void
AccountDetails::on_usernameEdit_editingFinished() AccountDetails::on_usernameEdit_editingFinished()
{ {
currentAccount_->setUsername(ui->usernameEdit->text()); currentAccount_->setUsername(ui->usernameEdit->text());
} }
void
AccountDetails::on_passwordEdit_editingFinished()
{
currentAccount_->setPassword(ui->passwordEdit->text());
}
void
AccountDetails::on_proxyEdit_editingFinished()
{
currentAccount_->setProxy(ui->proxyEdit->text());
}
void
AccountDetails::on_voicemailEdit_editingFinished()
{
currentAccount_->setMailbox(ui->voicemailEdit->text());
}
void void
AccountDetails::on_tabWidget_currentChanged(int index) AccountDetails::on_tabWidget_currentChanged(int index)
{ {
...@@ -362,7 +324,17 @@ AccountDetails::on_tabWidget_currentChanged(int index) ...@@ -362,7 +324,17 @@ AccountDetails::on_tabWidget_currentChanged(int index)
} }
} }
void AccountDetails::on_upnpCheckBox_clicked(bool checked)
void
AccountDetails::onCertButtonClicked()
{ {
currentAccount_->setUpnpEnabled(checked); QString fileName = QFileDialog::getOpenFileName(this, tr("Choose File"),
"",
tr("Files (*)"));
auto sender = QObject::sender();
(currentAccount_->*certMap_[sender->objectName()])(fileName);
static_cast<QPushButton*>(sender)->setText(fileName);
} }
...@@ -20,11 +20,13 @@ ...@@ -20,11 +20,13 @@
#define ACCOUNTDETAILS_H #define ACCOUNTDETAILS_H
#include <QWidget> #include <QWidget>
#include <QMap>
#include <QTableWidgetItem> #include <QTableWidgetItem>
#include "accountmodel.h" #include "accountmodel.h"
#include "audio/codecmodel.h" #include "audio/codecmodel.h"
#include "account.h"
namespace Ui { namespace Ui {
class AccountDetails; class AccountDetails;
...@@ -53,27 +55,21 @@ private slots: ...@@ -53,27 +55,21 @@ private slots:
void on_downVideoButton_clicked(); void on_downVideoButton_clicked();
void on_audioCodecView_itemSelectionChanged(); void on_audioCodecView_itemSelectionChanged();
void on_videoCodecView_itemSelectionChanged(); void on_videoCodecView_itemSelectionChanged();
void on_hostnameEdit_editingFinished();
void on_usernameEdit_editingFinished(); void on_usernameEdit_editingFinished();
void on_passwordEdit_editingFinished();
void on_proxyEdit_editingFinished();
void on_voicemailEdit_editingFinished();
void on_tabWidget_currentChanged(int index); void on_tabWidget_currentChanged(int index);
void on_upnpCheckBox_clicked(bool checked);
private slots: private slots:
void audio_codec_checked(int row, int column); void audio_codec_checked(int row, int column);
void setVideoEnabled(bool enabled);
void video_codec_checked(int row, int column); void video_codec_checked(int row, int column);
void setAutoAnswer(bool enabled); void onCertButtonClicked();
void aliasChanged();
void bootstrapChanged();
private: private:
Ui::AccountDetails *ui; Ui::AccountDetails *ui;
CodecModel* codecModel_; CodecModel* codecModel_;
Account* currentAccount_; Account* currentAccount_;
bool codecModelModified; bool codecModelModified;
typedef void (Account::*ACC_PTR)(const QString&);
QMap<QString, ACC_PTR > certMap_;
}; };
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>730</width> <width>748</width>
<height>559</height> <height>657</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -63,13 +63,6 @@ ...@@ -63,13 +63,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="typeValueLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="aliasLabel"> <widget class="QLabel" name="aliasLabel">
<property name="text"> <property name="text">
...@@ -78,7 +71,7 @@ ...@@ -78,7 +71,7 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="aliasValue"/> <widget class="QLineEdit" name="lrcfg_alias"/>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="hashLabel"> <widget class="QLabel" name="hashLabel">
...@@ -88,12 +81,19 @@ ...@@ -88,12 +81,19 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="hashValue"> <widget class="QLineEdit" name="lrcfg_username">
<property name="readOnly"> <property name="readOnly">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="typeValueLabel">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
...@@ -130,86 +130,120 @@ ...@@ -130,86 +130,120 @@
<property name="topMargin"> <property name="topMargin">
<number>10</number> <number>10</number>
</property> </property>
<item row="6" column="0">
<widget class="QCheckBox" name="autoAnswerCheckBox">
<property name="text">
<string>Auto-answer calls</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="upnpCheckBox">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>UPnP enabled</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="bootstrapLabel">
<property name="text">
<string>Bootstrap</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="bootstrapLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="hostnameLabel"> <widget class="QLabel" name="hostnameLabel">
<property name="text"> <property name="text">
<string>Hostname</string> <string>Hostname</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="hostnameEdit"/> <widget class="QLineEdit" name="lrcfg_hostname"/>
</item> </item>
<item row="2" column="0"> <item row="1" column="0">
<widget class="QLabel" name="usernameLabel"> <widget class="QLabel" name="usernameLabel">
<property name="text"> <property name="text">
<string>Username</string> <string>Username</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="usernameEdit"/> <widget class="QLineEdit" name="usernameEdit"/>
</item> </item>
<item row="3" column="0"> <item row="2" column="0">
<widget class="QLabel" name="passwordLabel"> <widget class="QLabel" name="passwordLabel">
<property name="text"> <property name="text">
<string>Password</string> <string>Password</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="passwordEdit"> <widget class="QLineEdit" name="lrcfg_password">
<property name="echoMode"> <property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum> <enum>QLineEdit::PasswordEchoOnEdit</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="3" column="0">
<widget class="QLabel" name="proxyLabel"> <widget class="QLabel" name="proxyLabel">
<property name="text"> <property name="text">
<string>Proxy</string> <string>Proxy</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="3" column="1">
<widget class="QLineEdit" name="proxyEdit"/> <widget class="QLineEdit" name="lrcfg_proxy"/>
</item> </item>
<item row="5" column="0"> <item row="4" column="0">
<widget class="QLabel" name="voicemailLabel"> <widget class="QLabel" name="voicemailLabel">
<property name="text"> <property name="text">
<string>Voicemail number</string> <string>Voicemail number</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="4" column="1">
<widget class="QLineEdit" name="voicemailEdit"/> <widget class="QLineEdit" name="lrcfg_mailbox"/>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="lrcfg_autoAnswer">
<property name="text">
<string>Auto-answer calls</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="lrcfg_upnpEnabled">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>UPnP enabled</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>DTMF tone type</string>
</property>
</widget>
</item>
<item row="7" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="rtpRadio">
<property name="text">
<string>RTP</string>
</property>
<attribute name="buttonGroup">
<string notr="true">dtmfGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="sipRadio">
<property name="text">
<string>SIP</string>
</property>
<attribute name="buttonGroup">
<string notr="true">dtmfGroup</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>
...@@ -310,7 +344,7 @@ ...@@ -310,7 +344,7 @@
<widget class="QTableWidget" name="videoCodecView"/> <widget class="QTableWidget" name="videoCodecView"/>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="videoEnabledCheckBox"> <widget class="QCheckBox" name="lrcfg_isVideoEnabled">
<property name="text"> <property name="text">
<string>Enable Video</string> <string>Enable Video</string>
</property> </property>
...@@ -372,6 +406,729 @@ ...@@ -372,6 +406,729 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="advancedTab">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Registration</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Registration expire timeout (seconds):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="lrcfg_registrationExpire">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Network Interface</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Local Port:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QSpinBox" name="lrcfg_localPort">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Published Adress</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="puslishedSameAsLocalRadio">
<property name="text">
<string>Same as local parameters</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">publishGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="customPublishedRadio">
<property name="text">
<string>Set published address and port:</string>
</property>
<attribute name="buttonGroup">
<string notr="true">publishGroup</string>
</attribute>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="publishAdressLayout">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Adress</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lrcfg_publishedAddress">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lrcfg_publishedPort">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="lrcfg_sipStunEnabled">
<property name="text">
<string>Use STUN</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lrcfg_sipStunServer">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="lrcfg_turnEnabled">
<property name="text">
<string>Use TURN</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lrcfg_sipTurnServer">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>SDP Session Negotiation (ICE Fallback)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>These settings are only used during SDP session negotiation in case ICE is not supported by the server or peer.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Audio RTP Port Range</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Min</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lrcfg_audioPortMin">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>Max</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lrcfg_audioPortMax">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Video RTP Port Range</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>30</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>Min</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lrcfg_videoPortMin">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>Max</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="lrcfg_videoPortMax">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="securityTab">
<attribute name="title">
<string>Security</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_17">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Media Stream Encryption</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="srtpEnabled">
<property name="text">
<string>Encrypt media stream (SRTP)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Key exchange protocol</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="keyExchangeModelCombo">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="lrcfg_srtpRtpFallback">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Fallback on RTP on encryption failure</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_19">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Negotiation Encryption</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lrcfg_tlsEnabled">
<property name="text">
<string>Encrypt negotiation (TLS)</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>CA certificate</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>User certificate</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Private key</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Private key password</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>TLS protocol method</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>Outgoing TLS server name</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_26">
<property name="text">
<string>Negotiation timeout (seconds)</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lrcfg_tlsPassword">
<property name="enabled">
<bool>false</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="tlsProtocoCombo">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lrcfg_tlsServerName">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="lrcfg_tlsNegotiationTimeoutSec">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="lrcfg_tlsCertificate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>PushButton</string>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/folder-download.png</normaloff>:/images/folder-download.png</iconset>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="lrcfg_tlsPrivateKeyCertificate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>PushButton</string>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/folder-download.png</normaloff>:/images/folder-download.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="lrcfg_tlsCaListCertificate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>PushButton</string>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/folder-download.png</normaloff>:/images/folder-download.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="lrcfg_tlsVerifyServer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Verify incoming certificates (server side)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lrcfg_tlsVerifyClient">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Verify answer certificates (client side)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lrcfg_tlsRequireClientCertificate">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Require a certificate for incoming TLS connections</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Cipher</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10" stretch="0,1">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="defaultCipherRadio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Use default ciphers</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="customCipherRadio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>User custom cipher list</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListView" name="cipherListView">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
...@@ -379,5 +1136,283 @@ ...@@ -379,5 +1136,283 @@
<resources> <resources>
<include location="ressources.qrc"/> <include location="ressources.qrc"/>
</resources> </resources>
<connections/> <connections>
<connection>
<sender>customPublishedRadio</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_publishedAddress</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>120</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>131</x>
<y>311</y>
</hint>
</hints>
</connection>
<connection>
<sender>customPublishedRadio</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_publishedPort</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>386</x>
<y>277</y>
</hint>
<hint type="destinationlabel">
<x>390</x>
<y>305</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_turnEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_sipTurnServer</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>71</x>
<y>396</y>
</hint>
<hint type="destinationlabel">
<x>196</x>
<y>393</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_sipStunEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_sipStunServer</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>33</x>
<y>355</y>
</hint>
<hint type="destinationlabel">
<x>252</x>
<y>355</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsCaListCertificate</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>143</x>
<y>257</y>
</hint>
<hint type="destinationlabel">
<x>327</x>
<y>296</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsCertificate</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>88</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>289</x>
<y>336</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsPrivateKeyCertificate</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>69</x>
<y>266</y>
</hint>
<hint type="destinationlabel">
<x>257</x>
<y>376</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsPassword</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>188</x>
<y>259</y>
</hint>
<hint type="destinationlabel">
<x>257</x>
<y>415</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>tlsProtocoCombo</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>115</x>
<y>258</y>
</hint>
<hint type="destinationlabel">
<x>261</x>
<y>455</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsServerName</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>217</x>
<y>257</y>
</hint>
<hint type="destinationlabel">
<x>244</x>
<y>490</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsNegotiationTimeoutSec</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>52</x>
<y>261</y>
</hint>
<hint type="destinationlabel">
<x>259</x>
<y>523</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsVerifyServer</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>240</x>
<y>261</y>
</hint>
<hint type="destinationlabel">
<x>180</x>
<y>565</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsVerifyClient</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>333</x>
<y>258</y>
</hint>
<hint type="destinationlabel">
<x>288</x>
<y>584</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>lrcfg_tlsRequireClientCertificate</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>369</x>
<y>262</y>
</hint>
<hint type="destinationlabel">
<x>375</x>
<y>625</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>defaultCipherRadio</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>373</x>
<y>255</y>
</hint>
<hint type="destinationlabel">
<x>195</x>
<y>66</y>
</hint>
</hints>
</connection>
<connection>
<sender>lrcfg_tlsEnabled</sender>
<signal>toggled(bool)</signal>
<receiver>customCipherRadio</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>373</x>
<y>255</y>
</hint>
<hint type="destinationlabel">
<x>551</x>
<y>66</y>
</hint>
</hints>
</connection>
<connection>
<sender>customCipherRadio</sender>
<signal>toggled(bool)</signal>
<receiver>cipherListView</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>496</x>
<y>74</y>
</hint>
<hint type="destinationlabel">
<x>499</x>
<y>139</y>
</hint>
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="publishGroup"/>
<buttongroup name="dtmfGroup"/>
<buttongroup name="cipherGroup"/>
</buttongroups>
</ui> </ui>
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@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/>. *
**************************************************************************/
#include "accountserializationadapter.h"
#include <QtWidgets/QWidget>
#include <QtWidgets/QLayout>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QAbstractButton>
#include <account.h>
#include <accountmodel.h>
constexpr static const char LRC_CFG[] = "lrcfg_";
constexpr static const int LRC_CFG_LEN = 6 ;
struct ConnHolder {
QMetaObject::Connection c;
~ConnHolder();
};
Q_DECLARE_METATYPE(ConnHolder*);
ConnHolder::~ConnHolder()
{
QObject::disconnect(c);
}
static void avoidDuplicate(QWidget* w)
{
if (qvariant_cast<ConnHolder*>(w->property("lrcfgConn")))
delete qvariant_cast<ConnHolder*>(w->property("lrcfgConn"));
}
/**
* This check for some supported widgets and bind the widgets and property
*/
static void setupWidget(QWidget* w, Account* a, const QHash<QByteArray, int>& roles)
{
if (w->objectName().left(LRC_CFG_LEN) == LRC_CFG) {
const QByteArray prop = w->objectName().mid(LRC_CFG_LEN, 999).toLatin1();
if (roles.contains(prop)) {
const int role = roles[prop];
if (qobject_cast<QLineEdit*>(w)) {
QLineEdit* le = qobject_cast<QLineEdit*>(w);
avoidDuplicate(le);
le->setText(a->roleData(role).toString());
ConnHolder* c = new ConnHolder {
QObject::connect(le, &QLineEdit::textChanged, [a,role](const QString& text) {
if (a->roleData(role) != text)
a->setRoleData(role, text);
})
};
le->setProperty("lrcfgConn",QVariant::fromValue(c));
}
else if (qobject_cast<QSpinBox*>(w)) {
QSpinBox* sb = qobject_cast<QSpinBox*>(w);
avoidDuplicate(sb);
sb->setValue(a->roleData(role).toInt());
ConnHolder* c = new ConnHolder {
QObject::connect(sb, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [a,role](int value) {
if (a->roleData(role).toInt() != value)
a->setRoleData(role, value);
})
};
sb->setProperty("lrcfgConn",QVariant::fromValue(c));
}
else if (qobject_cast<QAbstractButton*>(w)) {
//QCheckBox, QRadioButton, QToolButton, QPushButton
QAbstractButton* b = qobject_cast<QAbstractButton*>(w);
avoidDuplicate(b);
b->setChecked(a->roleData(role).toBool());
ConnHolder* c = new ConnHolder {
QObject::connect(b, &QAbstractButton::toggled,[a,role](bool c) {
if (a->roleData(role).toBool() != c)
a->setRoleData(role, c);
})
};
b->setProperty("lrcfgConn",QVariant::fromValue(c));
}
}
else {
qWarning() << "Unknown config properties" << w->objectName();
}
}
}
static void clearConnections(QWidget* w)
{
if (w->objectName().left(LRC_CFG_LEN) == LRC_CFG) {
avoidDuplicate(w);
}
}
static void drill(QWidget* w, Account* a, const QHash<QByteArray, int>& roles, bool clear = false)
{
for (QObject *object : w->children()) {
if (!object->isWidgetType())
continue;
QWidget* w2 = static_cast<QWidget*>(object);
if (clear)
clearConnections(w2);
else
setupWidget(w2, a, roles);
drill(w2, a, roles);
}
}
AccountSerializationAdapter::AccountSerializationAdapter(Account* a, QWidget* w) : QObject(w)
{
static QHash<QByteArray, int> reverse;
if (reverse.isEmpty()) {
const QHash<int, QByteArray> a = AccountModel::instance()->roleNames();
for (QHash<int, QByteArray>::const_iterator i = a.begin(); i != a.end(); ++i) {
reverse[i.value()] = i.key();
}
}
drill(w, a, reverse);
}
AccountSerializationAdapter::~AccountSerializationAdapter()
{
}
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author : Emmanuel Lepage Vallee <emmanuel.lepage@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/>. *
**************************************************************************/
#ifndef ACCOUNTSERIALIZATIONADAPTER_H
#define ACCOUNTSERIALIZATIONADAPTER_H
#include "typedefs.h"
class QWidget;
class Account;
/**
* This class will automatically bridge QtDesigner .ui to the LRC Account::
* class. To use it, all relevant .ui fields need to have in their name
*
* `lrcfg_propertyName` where `propertyName` is part of the Account object
* roleName hash.
*
* Supported widgets are currently:
*
* * QLineEdit
*/
class LIB_EXPORT AccountSerializationAdapter : public QObject
{
Q_OBJECT
public:
AccountSerializationAdapter(Account* a, QWidget* w);
virtual ~AccountSerializationAdapter();
};
#endif
\ No newline at end of file
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "video/rate.h" #include "video/rate.h"
#include "video/previewmanager.h" #include "video/previewmanager.h"
#include "accountserializationadapter.h"
#include "accountmodel.h" #include "accountmodel.h"
#include "protocolmodel.h" #include "protocolmodel.h"
#include "accountdetails.h" #include "accountdetails.h"
...@@ -136,9 +138,12 @@ ConfigurationWidget::on_rateBox_currentIndexChanged(int index) ...@@ -136,9 +138,12 @@ ConfigurationWidget::on_rateBox_currentIndexChanged(int index)
void void
ConfigurationWidget::accountSelected(QItemSelection itemSel) { ConfigurationWidget::accountSelected(QItemSelection itemSel) {
Q_UNUSED(itemSel) Q_UNUSED(itemSel)
accountDetails_->setAccount(accountModel_->getAccountByModelIndex( auto account = accountModel_->getAccountByModelIndex(
ui->accountView->currentIndex())); ui->accountView->currentIndex());
accountDetails_->setAccount(account);
AccountSerializationAdapter adapter(account, accountDetails_);
} }
void void
......
images/folder-download.png

381 B

...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<item> <item>
<widget class="QPushButton" name="backButton"> <widget class="QPushButton" name="backButton">
<property name="text"> <property name="text">
<string>Back</string> <string>Done</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="ressources.qrc"> <iconset resource="ressources.qrc">
......
...@@ -22,5 +22,6 @@ ...@@ -22,5 +22,6 @@
<file>images/arrow-down.png</file> <file>images/arrow-down.png</file>
<file>images/arrow-up.png</file> <file>images/arrow-up.png</file>
<file>images/spinner.gif</file> <file>images/spinner.gif</file>
<file>images/folder-download.png</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -190,7 +190,7 @@ QTabWidget::pane { ...@@ -190,7 +190,7 @@ QTabWidget::pane {
} }
QTabBar::tab { QTabBar::tab {
min-width: 80px; min-width: 95px;
min-height: 30px; min-height: 30px;
font-size: 20px; font-size: 20px;
color: black; color: black;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment