Browse Source

Revise checkbox label for "Use any available ports" functionality

Also reorder the checkboxes a bit.
adaptive-webui-19844
Chocobo1 3 years ago
parent
commit
09e558ae0b
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 12
      src/base/bittorrent/session.cpp
  2. 6
      src/base/bittorrent/session.h
  3. 10
      src/gui/optionsdialog.cpp
  4. 16
      src/gui/optionsdialog.ui
  5. 4
      src/webui/api/appcontroller.cpp
  6. 14
      src/webui/www/private/views/preferences.html

12
src/base/bittorrent/session.cpp

@ -407,7 +407,7 @@ Session::Session(QObject *parent) @@ -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) @@ -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) @@ -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

6
src/base/bittorrent/session.h

@ -306,8 +306,8 @@ namespace BitTorrent @@ -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 @@ -722,7 +722,7 @@ namespace BitTorrent
CachedSettingValue<bool> m_isBandwidthSchedulerEnabled;
CachedSettingValue<int> m_saveResumeDataInterval;
CachedSettingValue<int> m_port;
CachedSettingValue<bool> m_useRandomPort;
CachedSettingValue<bool> m_useAnyAvailablePort;
CachedSettingValue<QString> m_networkInterface;
CachedSettingValue<QString> m_networkInterfaceName;
CachedSettingValue<QString> m_networkInterfaceAddress;

10
src/gui/optionsdialog.cpp

@ -300,7 +300,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -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) @@ -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() @@ -770,7 +770,7 @@ void OptionsDialog::saveOptions()
// Connection preferences
session->setBTProtocol(static_cast<BitTorrent::BTProtocol>(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() @@ -1068,9 +1068,9 @@ void OptionsDialog::loadOptions()
// Connection preferences
m_ui->comboProtocol->setCurrentIndex(static_cast<int>(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)

16
src/gui/optionsdialog.ui

@ -1491,19 +1491,19 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s @@ -1491,19 +1491,19 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkUPnP">
<widget class="QCheckBox" name="useAnyPort">
<property name="text">
<string>Use UPnP / NAT-PMP port forwarding from my router</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Use any available port</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkRandomPort">
<widget class="QCheckBox" name="checkUPnP">
<property name="text">
<string>Use different port on each startup</string>
<string>Use UPnP / NAT-PMP port forwarding from my router</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
@ -3469,6 +3469,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -3469,6 +3469,7 @@ 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>
@ -3520,7 +3521,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -3520,7 +3521,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>lineEditAutoRun</tabstop>
<tabstop>scrollArea_3</tabstop>
<tabstop>randomButton</tabstop>
<tabstop>checkRandomPort</tabstop>
<tabstop>checkMaxConnecs</tabstop>
<tabstop>spinMaxConnec</tabstop>
<tabstop>checkMaxConnecsPerTorrent</tabstop>

4
src/webui/api/appcontroller.cpp

@ -154,7 +154,7 @@ void AppController::preferencesAction() @@ -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() @@ -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());

14
src/webui/www/private/views/preferences.html

@ -235,12 +235,12 @@ @@ -235,12 +235,12 @@
<button style="margin-left: 1em;" onclick="qBittorrent.Preferences.generateRandomPort();">QBT_TR(Random)QBT_TR[CONTEXT=OptionsDialog]</button>
</div>
<div class="formRow">
<input type="checkbox" id="upnp_checkbox" />
<label for="upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR[CONTEXT=OptionsDialog]</label>
<input type="checkbox" id="useAnyPortCheckbox" onclick="qBittorrent.Preferences.updatePortValueEnabled();" />
<label for="useAnyPortCheckbox">QBT_TR(Use any available port)QBT_TR[CONTEXT=OptionsDialog]</label>
</div>
<div class="formRow">
<input type="checkbox" id="random_port_checkbox" onclick="qBittorrent.Preferences.updatePortValueEnabled();" />
<label for="random_port_checkbox">QBT_TR(Use different port on each startup)QBT_TR[CONTEXT=OptionsDialog]</label>
<input type="checkbox" id="upnp_checkbox" />
<label for="upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR[CONTEXT=OptionsDialog]</label>
</div>
</fieldset>
@ -1405,7 +1405,7 @@ @@ -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 @@ @@ -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 @@ @@ -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;

Loading…
Cancel
Save