From 09e558ae0b912a29a4ba5bd12da16767527586e4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 26 Jul 2021 12:46:06 +0800 Subject: [PATCH] Revise checkbox label for "Use any available ports" functionality Also reorder the checkboxes a bit. --- src/base/bittorrent/session.cpp | 12 ++++++------ src/base/bittorrent/session.h | 6 +++--- src/gui/optionsdialog.cpp | 10 +++++----- src/gui/optionsdialog.ui | 18 +++++++++--------- src/webui/api/appcontroller.cpp | 4 ++-- src/webui/www/private/views/preferences.html | 14 +++++++------- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index aebb53d54..419fd7122 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -407,7 +407,7 @@ Session::Session(QObject *parent) , m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false) , m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 60) , m_port(BITTORRENT_SESSION_KEY("Port"), -1) - , m_useRandomPort(BITTORRENT_SESSION_KEY("UseRandomPort"), false) + , m_useAnyAvailablePort(BITTORRENT_SESSION_KEY("UseRandomPort"), false) , m_networkInterface(BITTORRENT_SESSION_KEY("Interface")) , m_networkInterfaceName(BITTORRENT_SESSION_KEY("InterfaceName")) , m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress")) @@ -1421,7 +1421,7 @@ void Session::configureNetworkInterfaces(lt::settings_pack &settingsPack) if (m_listenInterfaceConfigured) return; - const int port = useRandomPort() ? 0 : this->port(); + const int port = useAnyAvailablePort() ? 0 : this->port(); if (port > 0) // user specified port settingsPack.set_int(lt::settings_pack::max_retry_port_bind, 0); @@ -2751,14 +2751,14 @@ void Session::setPort(const int port) } } -bool Session::useRandomPort() const +bool Session::useAnyAvailablePort() const { - return m_useRandomPort; + return m_useAnyAvailablePort; } -void Session::setUseRandomPort(const bool value) +void Session::setUseAnyAvailablePort(const bool value) { - m_useRandomPort = value; + m_useAnyAvailablePort = value; } QString Session::networkInterface() const diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 64c27bc84..5e507fe9a 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -306,8 +306,8 @@ namespace BitTorrent void setSaveResumeDataInterval(int value); int port() const; void setPort(int port); - bool useRandomPort() const; - void setUseRandomPort(bool value); + bool useAnyAvailablePort() const; + void setUseAnyAvailablePort(bool value); QString networkInterface() const; void setNetworkInterface(const QString &iface); QString networkInterfaceName() const; @@ -722,7 +722,7 @@ namespace BitTorrent CachedSettingValue m_isBandwidthSchedulerEnabled; CachedSettingValue m_saveResumeDataInterval; CachedSettingValue m_port; - CachedSettingValue m_useRandomPort; + CachedSettingValue m_useAnyAvailablePort; CachedSettingValue m_networkInterface; CachedSettingValue m_networkInterfaceName; CachedSettingValue m_networkInterfaceAddress; diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 3b989cb25..0035e5c9a 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -300,7 +300,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) void (QSpinBox::*qSpinBoxValueChanged)(int) = &QSpinBox::valueChanged; connect(m_ui->comboProxyType, qComboBoxCurrentIndexChanged, this, &ThisType::enableProxy); - connect(m_ui->checkRandomPort, &QAbstractButton::toggled, m_ui->spinPort, &ThisType::setDisabled); + connect(m_ui->useAnyPort, &QAbstractButton::toggled, m_ui->spinPort, &ThisType::setDisabled); // Apply button is activated when a value is changed // Behavior tab @@ -408,7 +408,7 @@ 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->checkRandomPort, &QAbstractButton::toggled, 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 +770,7 @@ void OptionsDialog::saveOptions() // Connection preferences session->setBTProtocol(static_cast(m_ui->comboProtocol->currentIndex())); session->setPort(getPort()); - session->setUseRandomPort(m_ui->checkRandomPort->isChecked()); + 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); @@ -1068,9 +1068,9 @@ void OptionsDialog::loadOptions() // Connection preferences m_ui->comboProtocol->setCurrentIndex(static_cast(session->btProtocol())); m_ui->checkUPnP->setChecked(Net::PortForwarder::instance()->isEnabled()); - m_ui->checkRandomPort->setChecked(session->useRandomPort()); + m_ui->useAnyPort->setChecked(session->useAnyAvailablePort()); m_ui->spinPort->setValue(session->port()); - m_ui->spinPort->setDisabled(m_ui->checkRandomPort->isChecked()); + m_ui->spinPort->setDisabled(m_ui->useAnyPort->isChecked()); intValue = session->maxConnections(); if (intValue > 0) diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index a1e838d02..d9fb0c094 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -1491,19 +1491,19 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually - + - Use UPnP / NAT-PMP port forwarding from my router - - - true + Use any available port - + - Use different port on each startup + Use UPnP / NAT-PMP port forwarding from my router + + + true @@ -3281,7 +3281,7 @@ Use ';' to split multiple entries. Can use wildcard '*'. - + Enable reverse proxy support @@ -3469,6 +3469,7 @@ Use ';' to split multiple entries. Can use wildcard '*'. customThemeFilePath checkStartPaused spinPort + useAnyPort checkUPnP textWebUiUsername checkWebUi @@ -3520,7 +3521,6 @@ Use ';' to split multiple entries. Can use wildcard '*'. lineEditAutoRun scrollArea_3 randomButton - checkRandomPort checkMaxConnecs spinMaxConnec checkMaxConnecsPerTorrent diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 0b5e3a3af..7745509e7 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -154,7 +154,7 @@ void AppController::preferencesAction() // Listening Port data["listen_port"] = session->port(); data["upnp"] = Net::PortForwarder::instance()->isEnabled(); - data["random_port"] = session->useRandomPort(); + data["random_port"] = session->useAnyAvailablePort(); // Connections Limits data["max_connec"] = session->maxConnections(); data["max_connec_per_torrent"] = session->maxConnectionsPerTorrent(); @@ -487,7 +487,7 @@ void AppController::setPreferencesAction() if (hasKey("upnp")) Net::PortForwarder::instance()->setEnabled(it.value().toBool()); if (hasKey("random_port")) - session->setUseRandomPort(it.value().toBool()); + session->setUseAnyAvailablePort(it.value().toBool()); // Connections Limits if (hasKey("max_connec")) session->setMaxConnections(it.value().toInt()); diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 56dadeb24..5b9ca18cb 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -235,12 +235,12 @@
- - + +
- - + +
@@ -1405,7 +1405,7 @@ // Connection tab const updatePortValueEnabled = function() { - const checked = $('random_port_checkbox').getProperty('checked'); + const checked = $('useAnyPortCheckbox').getProperty('checked'); $('port_value').setProperty('disabled', checked); }; @@ -1708,7 +1708,7 @@ // Listening Port $('port_value').setProperty('value', pref.listen_port.toInt()); $('upnp_checkbox').setProperty('checked', pref.upnp); - $('random_port_checkbox').setProperty('checked', pref.random_port); + $('useAnyPortCheckbox').setProperty('checked', pref.random_port); updatePortValueEnabled(); // Connections Limits @@ -2024,7 +2024,7 @@ } settings.set('listen_port', listen_port); settings.set('upnp', $('upnp_checkbox').getProperty('checked')); - settings.set('random_port', $('random_port_checkbox').getProperty('checked')); + settings.set('random_port', $('useAnyPortCheckbox').getProperty('checked')); // Connections Limits let max_connec = -1;