Browse Source

Allow bandwidth values up to 65535 KiB/s

The slider has a max value, but it's changed whenever a value greater
than it is specified.

Note: 65535 is the maximum value allowed by libtorrent.

Closes #2373.
adaptive-webui-19844
Gabriele 10 years ago
parent
commit
c5db1157f1
  1. 2
      src/bandwidth_limit.ui
  2. 26
      src/speedlimitdlg.cpp
  3. 3
      src/speedlimitdlg.h

2
src/bandwidth_limit.ui

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
<string/>
</property>
<property name="maximum">
<number>10000</number>
<number>65535</number>
</property>
<property name="value">
<number>0</number>

26
src/speedlimitdlg.cpp

@ -50,8 +50,7 @@ long SpeedLimitDialog::askSpeedLimit(bool *ok, QString title, long default_value @@ -50,8 +50,7 @@ long SpeedLimitDialog::askSpeedLimit(bool *ok, QString title, long default_value
{
SpeedLimitDialog dlg;
dlg.setWindowTitle(title);
dlg.setMaxValue(max_value / 1024.);
dlg.setDefaultValue(default_value / 1024.);
dlg.setupDialog(max_value / 1024., default_value / 1024.);
if (dlg.exec() == QDialog::Accepted) {
*ok = true;
int val = dlg.getSpeedLimit();
@ -86,6 +85,8 @@ void SpeedLimitDialog::updateSliderValue(int val) const @@ -86,6 +85,8 @@ void SpeedLimitDialog::updateSliderValue(int val) const
spinBandwidth->setSpecialValueText(QString::fromUtf8(""));
spinBandwidth->setSuffix(QString::fromUtf8(""));
}
if (val > bandwidthSlider->maximum())
bandwidthSlider->setMaximum(val);
bandwidthSlider->setValue(val);
}
@ -97,18 +98,17 @@ long SpeedLimitDialog::getSpeedLimit() const @@ -97,18 +98,17 @@ long SpeedLimitDialog::getSpeedLimit() const
return -1;
}
void SpeedLimitDialog::setMaxValue(long val) const
{
if (val > 0) {
bandwidthSlider->setMaximum(val);
spinBandwidth->setMaximum(val);
}
}
void SpeedLimitDialog::setDefaultValue(long val) const
void SpeedLimitDialog::setupDialog(long max_slider, long val) const
{
if (val < 0) val = 0;
if (val > bandwidthSlider->maximum()) val = bandwidthSlider->maximum();
if (val < 0)
val = 0;
if (max_slider < 0)
max_slider = 1000;
// This can happen for example if global rate limit is lower
// than torrent rate limit.
if (val > max_slider)
max_slider = val;
bandwidthSlider->setMaximum(max_slider);
bandwidthSlider->setValue(val);
updateSpinValue(val);
}

3
src/speedlimitdlg.h

@ -48,8 +48,7 @@ protected slots: @@ -48,8 +48,7 @@ protected slots:
void updateSpinValue(int val) const;
void updateSliderValue(int val) const;
long getSpeedLimit() const;
void setMaxValue(long val) const;
void setDefaultValue(long val) const;
void setupDialog(long max_slider, long val) const;
};
#endif

Loading…
Cancel
Save