diff --git a/src/gui/networksettings.cpp b/src/gui/networksettings.cpp index f70cc30e2..8612b6d37 100644 --- a/src/gui/networksettings.cpp +++ b/src/gui/networksettings.cpp @@ -63,6 +63,7 @@ NetworkSettings::NetworkSettings(QWidget *parent) : connect(_ui->autoUploadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); connect(_ui->downloadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); connect(_ui->noDownloadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); + connect(_ui->autoDownloadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); connect(_ui->downloadSpinBox, SIGNAL(valueChanged(int)), SLOT(saveBWLimitSettings())); connect(_ui->uploadSpinBox, SIGNAL(valueChanged(int)), SLOT(saveBWLimitSettings())); } @@ -109,16 +110,25 @@ void NetworkSettings::loadProxySettings() void NetworkSettings::loadBWLimitSettings() { ConfigFile cfgFile; - _ui->downloadLimitRadioButton->setChecked(cfgFile.useDownloadLimit()); - int uploadLimit = cfgFile.useUploadLimit(); - if ( uploadLimit >= 1 ) { + + int useDownloadLimit = cfgFile.useDownloadLimit(); + if ( useDownloadLimit >= 1 ) { + _ui->downloadLimitRadioButton->setChecked(true); + } else if (useDownloadLimit == 0){ + _ui->noDownloadLimitRadioButton->setChecked(true); + } else { + _ui->autoDownloadLimitRadioButton->setChecked(true); + } + _ui->downloadSpinBox->setValue(cfgFile.downloadLimit()); + + int useUploadLimit = cfgFile.useUploadLimit(); + if ( useUploadLimit >= 1 ) { _ui->uploadLimitRadioButton->setChecked(true); - } else if (uploadLimit == 0){ + } else if (useUploadLimit == 0){ _ui->noUploadLimitRadioButton->setChecked(true); } else { _ui->autoUploadLimitRadioButton->setChecked(true); } - _ui->downloadSpinBox->setValue(cfgFile.downloadLimit()); _ui->uploadSpinBox->setValue(cfgFile.uploadLimit()); } @@ -151,7 +161,14 @@ void NetworkSettings::saveProxySettings() void NetworkSettings::saveBWLimitSettings() { ConfigFile cfgFile; - cfgFile.setUseDownloadLimit(_ui->downloadLimitRadioButton->isChecked()); + if (_ui->downloadLimitRadioButton->isChecked()) { + cfgFile.setUseDownloadLimit(1); + } else if (_ui->noDownloadLimitRadioButton->isChecked()) { + cfgFile.setUseDownloadLimit(0); + } else if (_ui->autoDownloadLimitRadioButton->isChecked()) { + cfgFile.setUseDownloadLimit(-1); + } + cfgFile.setDownloadLimit(_ui->downloadSpinBox->value()); if (_ui->uploadLimitRadioButton->isChecked()) { cfgFile.setUseUploadLimit(1); @@ -160,8 +177,6 @@ void NetworkSettings::saveBWLimitSettings() } else if (_ui->autoUploadLimitRadioButton->isChecked()) { cfgFile.setUseUploadLimit(-1); } - - cfgFile.setDownloadLimit(_ui->downloadSpinBox->value()); cfgFile.setUploadLimit(_ui->uploadSpinBox->value()); FolderMan::instance()->setDirtyNetworkLimits(); diff --git a/src/gui/networksettings.ui b/src/gui/networksettings.ui index cd0ba71e0..56eb1cacb 100644 --- a/src/gui/networksettings.ui +++ b/src/gui/networksettings.ui @@ -6,8 +6,8 @@ 0 0 - 518 - 384 + 542 + 391 @@ -104,7 +104,7 @@ - true + false @@ -141,13 +141,22 @@ false - + + 0 + + + 0 + + + 0 + + 0 - true + false @@ -157,7 +166,7 @@ - true + false @@ -190,14 +199,37 @@ Download Bandwidth - + Limit to - + + + + No limit + + + true + + + + + + + Qt::Vertical + + + + 147 + 25 + + + + + @@ -221,42 +253,13 @@ - - + + - No limit - - - true + Limit automatically - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Vertical - - - - 147 - 25 - - - - @@ -323,19 +326,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - autoUploadLimitRadioButton uploadLimitRadioButton diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index d3c39c0c7..c5f0568b9 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -514,9 +514,9 @@ int ConfigFile::useUploadLimit() const return getValue(useUploadLimitC, QString::null, 0).toInt(); } -bool ConfigFile::useDownloadLimit() const +int ConfigFile::useDownloadLimit() const { - return getValue(useDownloadLimitC, QString::null, false).toBool(); + return getValue(useDownloadLimitC, QString::null, 0).toInt(); } void ConfigFile::setUseUploadLimit(int val) @@ -524,9 +524,9 @@ void ConfigFile::setUseUploadLimit(int val) setValue(useUploadLimitC, val); } -void ConfigFile::setUseDownloadLimit(bool enable) +void ConfigFile::setUseDownloadLimit(int val) { - setValue(useDownloadLimitC, enable); + setValue(useDownloadLimitC, val); } int ConfigFile::uploadLimit() const diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index d1af84c55..55bde5d20 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -87,9 +87,9 @@ public: /** 0: no limit, 1: manual, >0: automatic */ int useUploadLimit() const; - bool useDownloadLimit() const; + int useDownloadLimit() const; void setUseUploadLimit(int); - void setUseDownloadLimit(bool); + void setUseDownloadLimit(int); /** in kbyte/s */ int uploadLimit() const; int downloadLimit() const; diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index a1dff6e0b..936b4eff1 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -242,7 +242,7 @@ void GETFileJob::slotReadyRead() if (_bandwidthLimited) { toRead = qMin(qint64(bufferSize), _bandwidthQuota); if (toRead == 0) { - qDebug() << Q_FUNC_INFO << "Out of quota"; + //qDebug() << Q_FUNC_INFO << "Out of quota"; break; } _bandwidthQuota -= toRead;