mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 12:48:04 -06:00
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:
@@ -407,7 +407,6 @@ 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_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,13 +1420,12 @@ void Session::configureNetworkInterfaces(lt::settings_pack &settingsPack)
|
||||
if (m_listenInterfaceConfigured)
|
||||
return;
|
||||
|
||||
const int port = useAnyAvailablePort() ? 0 : this->port();
|
||||
if (port > 0) // user specified port
|
||||
if (port() > 0) // user has specified port number
|
||||
settingsPack.set_int(lt::settings_pack::max_retry_port_bind, 0);
|
||||
|
||||
QStringList endpoints;
|
||||
QStringList outgoingInterfaces;
|
||||
const QString portString = ':' + QString::number(port);
|
||||
const QString portString = ':' + QString::number(port());
|
||||
|
||||
for (const QString &ip : asConst(getListeningIPs()))
|
||||
{
|
||||
@@ -2751,16 +2749,6 @@ void Session::setPort(const int port)
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::useAnyAvailablePort() const
|
||||
{
|
||||
return m_useAnyAvailablePort;
|
||||
}
|
||||
|
||||
void Session::setUseAnyAvailablePort(const bool value)
|
||||
{
|
||||
m_useAnyAvailablePort = value;
|
||||
}
|
||||
|
||||
QString Session::networkInterface() const
|
||||
{
|
||||
return m_networkInterface;
|
||||
|
||||
@@ -306,8 +306,6 @@ namespace BitTorrent
|
||||
void setSaveResumeDataInterval(int value);
|
||||
int port() const;
|
||||
void setPort(int port);
|
||||
bool useAnyAvailablePort() const;
|
||||
void setUseAnyAvailablePort(bool value);
|
||||
QString networkInterface() const;
|
||||
void setNetworkInterface(const QString &iface);
|
||||
QString networkInterfaceName() const;
|
||||
@@ -722,7 +720,6 @@ namespace BitTorrent
|
||||
CachedSettingValue<bool> m_isBandwidthSchedulerEnabled;
|
||||
CachedSettingValue<int> m_saveResumeDataInterval;
|
||||
CachedSettingValue<int> m_port;
|
||||
CachedSettingValue<bool> m_useAnyAvailablePort;
|
||||
CachedSettingValue<QString> m_networkInterface;
|
||||
CachedSettingValue<QString> m_networkInterfaceName;
|
||||
CachedSettingValue<QString> m_networkInterfaceAddress;
|
||||
|
||||
@@ -234,6 +234,13 @@ void SettingsStorage::removeValue(const QString &key)
|
||||
}
|
||||
}
|
||||
|
||||
bool SettingsStorage::hasKey(const QString &key) const
|
||||
{
|
||||
const QString realKey = mapKey(key);
|
||||
const QReadLocker locker {&m_lock};
|
||||
return m_data.contains(realKey);
|
||||
}
|
||||
|
||||
QVariantHash TransactionalSettings::read() const
|
||||
{
|
||||
QVariantHash res;
|
||||
|
||||
@@ -79,6 +79,7 @@ public:
|
||||
}
|
||||
|
||||
void removeValue(const QString &key);
|
||||
bool hasKey(const QString &key) const;
|
||||
|
||||
public slots:
|
||||
bool save();
|
||||
|
||||
Reference in New Issue
Block a user