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
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
9 changed files with 39 additions and 54 deletions

View file

@ -153,8 +153,8 @@ void AppController::preferencesAction()
// Connection
// Listening Port
data["listen_port"] = session->port();
data["random_port"] = (session->port() == 0); // deprecated
data["upnp"] = Net::PortForwarder::instance()->isEnabled();
data["random_port"] = session->useAnyAvailablePort();
// Connections Limits
data["max_connec"] = session->maxConnections();
data["max_connec_per_torrent"] = session->maxConnectionsPerTorrent();
@ -482,12 +482,16 @@ void AppController::setPreferencesAction()
// Connection
// Listening Port
if (hasKey("listen_port"))
if (hasKey("random_port") && it.value().toBool()) // deprecated
{
session->setPort(0);
}
else if (hasKey("listen_port"))
{
session->setPort(it.value().toInt());
}
if (hasKey("upnp"))
Net::PortForwarder::instance()->setEnabled(it.value().toBool());
if (hasKey("random_port"))
session->setUseAnyAvailablePort(it.value().toBool());
// Connections Limits
if (hasKey("max_connec"))
session->setMaxConnections(it.value().toInt());