diff --git a/advancedsipsettingwidget.cpp b/advancedsipsettingwidget.cpp index 9c838e49a0ab47bd3810d1c0abecab2da164ff57..42d69e5de680273cebee5e81c4a4ab3c2920ea5a 100644 --- a/advancedsipsettingwidget.cpp +++ b/advancedsipsettingwidget.cpp @@ -96,6 +96,14 @@ AdvancedSIPSettingsWidget::AdvancedSIPSettingsWidget(QWidget* parent) ui->lineEditSTUNAddressSIP->setEnabled((bool)state); }); + // published address + connect(ui->checkBoxCustomAddressPort, &QAbstractButton::clicked, this, &AdvancedSIPSettingsWidget::setUseCustomAddressAndPort); + connect(ui->checkBoxCustomAddressPort, &QAbstractButton::clicked, [this](int state) { + ui->lineEditSIPCustomAddress->setEnabled((bool)state); + ui->customPortSIPSpinBox->setEnabled((bool)state); + }); + connect(ui->lineEditSIPCustomAddress, &QLineEdit::editingFinished, this, &AdvancedSIPSettingsWidget::lineEditSIPCustomAddressLineEditTextChanged); + // codecs connect(ui->audioListWidgetSIP, &QListWidget::itemChanged, this, &AdvancedSIPSettingsWidget::audioCodecsStateChange); connect(ui->videoListWidgetSIP, &QListWidget::itemChanged, this, &AdvancedSIPSettingsWidget::videoCodecsStateChange); @@ -194,6 +202,13 @@ void AdvancedSIPSettingsWidget::updateAdvancedSIPSettings() ui->networkInterfaceSpinBox->setValue(config.localPort); connect(ui->networkInterfaceSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AdvancedSIPSettingsWidget::networkInterfaceSpinBoxValueChanged); + // published address + ui->checkBoxCustomAddressPort->setChecked(config.publishedSameAsLocal); + ui->lineEditSIPCustomAddress->setText(QString::fromStdString(config.publishedAddress)); + ui->customPortSIPSpinBox->setValue(config.publishedPort); + + connect(ui->customPortSIPSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &AdvancedSIPSettingsWidget::customPortSIPSpinBoxValueChanged); + // codecs ui->videoCheckBoxSIP->setChecked(config.Video.videoEnabled); disconnect(ui->audioListWidgetSIP, &QListWidget::itemChanged, this, &AdvancedSIPSettingsWidget::audioCodecsStateChange); @@ -578,3 +593,27 @@ AdvancedSIPSettingsWidget::networkInterfaceSpinBoxValueChanged(const int& value) confProps.localPort = value; LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); } + +void +AdvancedSIPSettingsWidget::setUseCustomAddressAndPort(bool state) +{ + auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); + confProps.publishedSameAsLocal = state; + LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); +} + +void +AdvancedSIPSettingsWidget::lineEditSIPCustomAddressLineEditTextChanged() +{ + auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); + confProps.publishedAddress = ui->lineEditSIPCustomAddress->text().toStdString(); + LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); +} + +void +AdvancedSIPSettingsWidget::customPortSIPSpinBoxValueChanged(const int& value) +{ + auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); + confProps.publishedPort = value; + LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); +} diff --git a/advancedsipsettingwidget.h b/advancedsipsettingwidget.h index 336e20af3dcc1fbf8e0fad0786b1993909ae342f..7d05704fd491ada51286e86ca3f3ab0f46e95232 100644 --- a/advancedsipsettingwidget.h +++ b/advancedsipsettingwidget.h @@ -85,6 +85,12 @@ private slots: void setTURNRealm(); void setSTUNAddress(); + // published address + void setUseCustomAddressAndPort(bool state); + + void lineEditSIPCustomAddressLineEditTextChanged(); + void customPortSIPSpinBoxValueChanged(const int& value); + // codecs void updateAudioCodecs(); void updateVideoCodecs(); diff --git a/advancedsipsettingwidget.ui b/advancedsipsettingwidget.ui index a97a904e82928070429c608c823ba8a25593be20..eb517660fd1583df15e086aed0567b66c042e484 100644 --- a/advancedsipsettingwidget.ui +++ b/advancedsipsettingwidget.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>731</width> - <height>1424</height> + <height>1532</height> </rect> </property> <property name="windowTitle"> @@ -1113,6 +1113,205 @@ </item> </layout> </item> + <item> + <spacer name="verticalSpacer_10"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Minimum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QLabel" name="label_4"> + <property name="font"> + <font> + <pointsize>13</pointsize> + </font> + </property> + <property name="text"> + <string>Published Address</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_9"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_17"> + <property name="leftMargin"> + <number>20</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <item row="1" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_28"> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_24"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Address</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="1"> + <spacer name="horizontalSpacer_27"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::MinimumExpanding</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="2" column="2"> + <widget class="QSpinBox" name="customPortSIPSpinBox"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="maximum"> + <number>65536</number> + </property> + </widget> + </item> + <item row="2" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_27"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text"> + <string>Port</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="0" column="0"> + <widget class="ToggleSwitch" name="checkBoxCustomAddressPort" native="true"> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="text" stdset="0"> + <string>Use Custom Address/Port</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="lineEditSIPCustomAddress"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>300</width> + <height>0</height> + </size> + </property> + <property name="font"> + <font> + <pointsize>10</pointsize> + </font> + </property> + <property name="echoMode"> + <enum>QLineEdit::PasswordEchoOnEdit</enum> + </property> + <property name="placeholderText"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> <item> <spacer name="verticalSpacer_6"> <property name="orientation">