Browse Source

Fix setting a speed limit.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
e440fc3d17
  1. 28
      src/base/bittorrent/session.cpp
  2. 16
      src/gui/optionsdlg.cpp

28
src/base/bittorrent/session.cpp

@ -2052,11 +2052,16 @@ void Session::configureListeningInterface() @@ -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) @@ -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) @@ -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) @@ -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;

16
src/gui/optionsdlg.cpp

@ -875,7 +875,7 @@ void OptionsDialog::loadOptions() @@ -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() @@ -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() @@ -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() @@ -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 @@ -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 @@ -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…
Cancel
Save