Use spinbox special value to represent "Use any available port"

WebAPI functionality is preserved (deprecated) for now and should be
removed in the future.
This commit is contained in:
Chocobo1
2021-07-28 12:24:03 +08:00
parent 09e558ae0b
commit 49aab492e0
9 changed files with 39 additions and 54 deletions

View File

@@ -300,7 +300,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
void (QSpinBox::*qSpinBoxValueChanged)(int) = &QSpinBox::valueChanged;
connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableProxy);
connect(m_ui->useAnyPort, &QAbstractButton::toggled, m_ui->spinPort, &ThisType::setDisabled);
// Apply button is activated when a value is changed
// Behavior tab
@@ -408,7 +407,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
// Connection tab
connect(m_ui->comboProtocol, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
connect(m_ui->spinPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
connect(m_ui->useAnyPort, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkUPnP, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->spinUploadLimit, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
connect(m_ui->spinDownloadLimit, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
@@ -770,7 +768,6 @@ void OptionsDialog::saveOptions()
// Connection preferences
session->setBTProtocol(static_cast<BitTorrent::BTProtocol>(m_ui->comboProtocol->currentIndex()));
session->setPort(getPort());
session->setUseAnyAvailablePort(m_ui->useAnyPort->isChecked());
Net::PortForwarder::instance()->setEnabled(isUPnPEnabled());
session->setGlobalDownloadSpeedLimit(m_ui->spinDownloadLimit->value() * 1024);
session->setGlobalUploadSpeedLimit(m_ui->spinUploadLimit->value() * 1024);
@@ -1067,10 +1064,8 @@ void OptionsDialog::loadOptions()
// Connection preferences
m_ui->comboProtocol->setCurrentIndex(static_cast<int>(session->btProtocol()));
m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled());
m_ui->useAnyPort->setChecked(session->useAnyAvailablePort());
m_ui->spinPort->setValue(session->port());
m_ui->spinPort->setDisabled(m_ui->useAnyPort->isChecked());
m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled());
intValue = session->maxConnections();
if (intValue > 0)

View File

@@ -1457,15 +1457,12 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
</item>
<item>
<widget class="QSpinBox" name="spinPort">
<property name="minimum">
<number>1</number>
<property name="specialValueText">
<string>Any</string>
</property>
<property name="maximum">
<number>65535</number>
</property>
<property name="value">
<number>8999</number>
</property>
</widget>
</item>
<item>
@@ -1490,13 +1487,6 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="useAnyPort">
<property name="text">
<string>Use any available port</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkUPnP">
<property name="text">
@@ -3469,7 +3459,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>customThemeFilePath</tabstop>
<tabstop>checkStartPaused</tabstop>
<tabstop>spinPort</tabstop>
<tabstop>useAnyPort</tabstop>
<tabstop>checkUPnP</tabstop>
<tabstop>textWebUiUsername</tabstop>
<tabstop>checkWebUi</tabstop>