Browse Source

Fix values for unsetting speed limits.

adaptive-webui-19844
sledgehammer999 8 years ago
parent
commit
db4b30ad48
  1. 4
      src/gui/mainwindow.cpp
  2. 4
      src/gui/optionsdlg.cpp
  3. 2
      src/gui/speedlimitdlg.cpp
  4. 28
      src/gui/statusbar.cpp

4
src/gui/mainwindow.cpp

@ -817,7 +817,7 @@ void MainWindow::on_actionSetGlobalUploadLimit_triggered()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok; bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit( const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit()); &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
if (ok) { if (ok) {
@ -830,7 +830,7 @@ void MainWindow::on_actionSetGlobalDownloadLimit_triggered()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok; bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit( const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit()); &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
if (ok) { if (ok) {

4
src/gui/optionsdlg.cpp

@ -1056,7 +1056,7 @@ bool OptionsDialog::isUPnPEnabled() const
// [download,upload] // [download,upload]
QPair<int, int> OptionsDialog::getGlobalBandwidthLimits() const QPair<int, int> OptionsDialog::getGlobalBandwidthLimits() const
{ {
int DL = -1, UP = -1; int DL = 0, UP = 0;
if (m_ui->checkDownloadLimit->isChecked()) if (m_ui->checkDownloadLimit->isChecked())
DL = m_ui->spinDownloadLimit->value(); DL = m_ui->spinDownloadLimit->value();
if (m_ui->checkUploadLimit->isChecked()) if (m_ui->checkUploadLimit->isChecked())
@ -1068,7 +1068,7 @@ QPair<int, int> OptionsDialog::getGlobalBandwidthLimits() const
// [download,upload] // [download,upload]
QPair<int, int> OptionsDialog::getAltGlobalBandwidthLimits() const QPair<int, int> OptionsDialog::getAltGlobalBandwidthLimits() const
{ {
int DL = -1, UP = -1; int DL = 0, UP = 0;
if (m_ui->checkDownloadLimitAlt->isChecked()) if (m_ui->checkDownloadLimitAlt->isChecked())
DL = m_ui->spinDownloadLimitAlt->value(); DL = m_ui->spinDownloadLimitAlt->value();
if (m_ui->checkUploadLimitAlt->isChecked()) if (m_ui->checkUploadLimitAlt->isChecked())

2
src/gui/speedlimitdlg.cpp

@ -56,7 +56,7 @@ long SpeedLimitDialog::askSpeedLimit(bool *ok, QString title, long default_value
*ok = true; *ok = true;
int val = dlg.getSpeedLimit(); int val = dlg.getSpeedLimit();
if (val <= 0) if (val <= 0)
return -1; return 0;
return val * 1024; return val * 1024;
} }
else { else {

28
src/gui/statusbar.cpp

@ -205,13 +205,13 @@ void StatusBar::updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus
{ {
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true); QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true);
int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit(); int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit();
if (speedLimit >= 0) if (speedLimit)
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")"; speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")";
m_dlSpeedLbl->setText(speedLbl); m_dlSpeedLbl->setText(speedLbl);
speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit(); speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit();
speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true); speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true);
if (speedLimit >= 0) if (speedLimit)
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")"; speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")";
m_upSpeedLbl->setText(speedLbl); m_upSpeedLbl->setText(speedLbl);
@ -252,17 +252,11 @@ void StatusBar::capDownloadSpeed()
{ {
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false; bool ok = false;
long newLimit = SpeedLimitDialog::askSpeedLimit( const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit()); &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
if (ok) { if (ok) {
if (newLimit <= 0) { qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
qDebug("Setting global download rate limit to Unlimited"); session->setDownloadSpeedLimit(newLimit);
session->setDownloadSpeedLimit(-1);
}
else {
qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
session->setDownloadSpeedLimit(newLimit);
}
refreshStatusBar(); refreshStatusBar();
} }
} }
@ -271,17 +265,11 @@ void StatusBar::capUploadSpeed()
{ {
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false; bool ok = false;
long newLimit = SpeedLimitDialog::askSpeedLimit( const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit()); &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
if (ok) { if (ok) {
if (newLimit <= 0) { qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
qDebug("Setting global upload rate limit to Unlimited"); session->setUploadSpeedLimit(newLimit);
session->setUploadSpeedLimit(-1);
}
else {
qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
session->setUploadSpeedLimit(newLimit);
}
refreshStatusBar(); refreshStatusBar();
} }
} }

Loading…
Cancel
Save