mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 13:28:50 +03:00
Fix setting a speed limit.
This commit is contained in:
parent
3081a8bb3f
commit
e440fc3d17
2 changed files with 32 additions and 12 deletions
|
@ -2052,11 +2052,16 @@ void Session::configureListeningInterface()
|
|||
|
||||
int Session::globalDownloadSpeedLimit() const
|
||||
{
|
||||
return m_globalDownloadSpeedLimit;
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
return m_globalDownloadSpeedLimit * 1024;
|
||||
}
|
||||
|
||||
void Session::setGlobalDownloadSpeedLimit(int limit)
|
||||
{
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
limit /= 1024;
|
||||
if (limit < 0) limit = 0;
|
||||
if (limit == globalDownloadSpeedLimit()) return;
|
||||
|
||||
|
@ -2067,11 +2072,16 @@ void Session::setGlobalDownloadSpeedLimit(int limit)
|
|||
|
||||
int Session::globalUploadSpeedLimit() const
|
||||
{
|
||||
return m_globalUploadSpeedLimit;
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
return m_globalUploadSpeedLimit * 1024;
|
||||
}
|
||||
|
||||
void Session::setGlobalUploadSpeedLimit(int limit)
|
||||
{
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
limit /= 1024;
|
||||
if (limit < 0) limit = 0;
|
||||
if (limit == globalUploadSpeedLimit()) return;
|
||||
|
||||
|
@ -2082,11 +2092,16 @@ void Session::setGlobalUploadSpeedLimit(int limit)
|
|||
|
||||
int Session::altGlobalDownloadSpeedLimit() const
|
||||
{
|
||||
return m_altGlobalDownloadSpeedLimit;
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
return m_altGlobalDownloadSpeedLimit * 1024;
|
||||
}
|
||||
|
||||
void Session::setAltGlobalDownloadSpeedLimit(int limit)
|
||||
{
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
limit /= 1024;
|
||||
if (limit < 0) limit = 0;
|
||||
if (limit == altGlobalDownloadSpeedLimit()) return;
|
||||
|
||||
|
@ -2097,11 +2112,16 @@ void Session::setAltGlobalDownloadSpeedLimit(int limit)
|
|||
|
||||
int Session::altGlobalUploadSpeedLimit() const
|
||||
{
|
||||
return m_altGlobalUploadSpeedLimit;
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
return m_altGlobalUploadSpeedLimit * 1024;
|
||||
}
|
||||
|
||||
void Session::setAltGlobalUploadSpeedLimit(int limit)
|
||||
{
|
||||
// Unfortunately the value was saved as KiB instead of B.
|
||||
// But it is better to pass it around internally(+ webui) as Bytes.
|
||||
limit /= 1024;
|
||||
if (limit < 0) limit = 0;
|
||||
if (limit == altGlobalUploadSpeedLimit()) return;
|
||||
|
||||
|
|
|
@ -875,7 +875,7 @@ void OptionsDialog::loadOptions()
|
|||
// End Connection preferences
|
||||
|
||||
// Speed preferences
|
||||
intValue = session->globalDownloadSpeedLimit();
|
||||
intValue = session->globalDownloadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkDownloadLimit->setChecked(true);
|
||||
|
@ -887,7 +887,7 @@ void OptionsDialog::loadOptions()
|
|||
m_ui->checkDownloadLimit->setChecked(false);
|
||||
m_ui->spinDownloadLimit->setEnabled(false);
|
||||
}
|
||||
intValue = session->globalUploadSpeedLimit();
|
||||
intValue = session->globalUploadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkUploadLimit->setChecked(true);
|
||||
|
@ -900,7 +900,7 @@ void OptionsDialog::loadOptions()
|
|||
m_ui->spinUploadLimit->setEnabled(false);
|
||||
}
|
||||
|
||||
intValue = session->altGlobalDownloadSpeedLimit();
|
||||
intValue = session->altGlobalDownloadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkDownloadLimitAlt->setChecked(true);
|
||||
|
@ -912,7 +912,7 @@ void OptionsDialog::loadOptions()
|
|||
m_ui->checkDownloadLimitAlt->setChecked(false);
|
||||
m_ui->spinDownloadLimitAlt->setEnabled(false);
|
||||
}
|
||||
intValue = session->altGlobalUploadSpeedLimit();
|
||||
intValue = session->altGlobalUploadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkUploadLimitAlt->setChecked(true);
|
||||
|
@ -1058,9 +1058,9 @@ QPair<int, int> OptionsDialog::getGlobalBandwidthLimits() const
|
|||
{
|
||||
int DL = 0, UP = 0;
|
||||
if (m_ui->checkDownloadLimit->isChecked())
|
||||
DL = m_ui->spinDownloadLimit->value();
|
||||
DL = m_ui->spinDownloadLimit->value() * 1024;
|
||||
if (m_ui->checkUploadLimit->isChecked())
|
||||
UP = m_ui->spinUploadLimit->value();
|
||||
UP = m_ui->spinUploadLimit->value() * 1024;
|
||||
return qMakePair(DL, UP);
|
||||
}
|
||||
|
||||
|
@ -1070,9 +1070,9 @@ QPair<int, int> OptionsDialog::getAltGlobalBandwidthLimits() const
|
|||
{
|
||||
int DL = 0, UP = 0;
|
||||
if (m_ui->checkDownloadLimitAlt->isChecked())
|
||||
DL = m_ui->spinDownloadLimitAlt->value();
|
||||
DL = m_ui->spinDownloadLimitAlt->value() * 1024;
|
||||
if (m_ui->checkUploadLimitAlt->isChecked())
|
||||
UP = m_ui->spinUploadLimitAlt->value();
|
||||
UP = m_ui->spinUploadLimitAlt->value() * 1024;
|
||||
return qMakePair(DL, UP);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue