mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 18:04:32 +00:00
Merge pull request #9799 from Chocobo1/removeCheckbox
Remove speed limit checkbox in Options dialog
This commit is contained in:
commit
2ce57b97be
@ -2660,7 +2660,7 @@ int Session::downloadSpeedLimit() const
|
||||
: globalDownloadSpeedLimit();
|
||||
}
|
||||
|
||||
void Session::setDownloadSpeedLimit(int limit)
|
||||
void Session::setDownloadSpeedLimit(const int limit)
|
||||
{
|
||||
if (isAltGlobalSpeedLimitEnabled())
|
||||
setAltGlobalDownloadSpeedLimit(limit);
|
||||
@ -2675,7 +2675,7 @@ int Session::uploadSpeedLimit() const
|
||||
: globalUploadSpeedLimit();
|
||||
}
|
||||
|
||||
void Session::setUploadSpeedLimit(int limit)
|
||||
void Session::setUploadSpeedLimit(const int limit)
|
||||
{
|
||||
if (isAltGlobalSpeedLimitEnabled())
|
||||
setAltGlobalUploadSpeedLimit(limit);
|
||||
@ -2688,7 +2688,7 @@ bool Session::isAltGlobalSpeedLimitEnabled() const
|
||||
return m_isAltGlobalSpeedLimitEnabled;
|
||||
}
|
||||
|
||||
void Session::setAltGlobalSpeedLimitEnabled(bool enabled)
|
||||
void Session::setAltGlobalSpeedLimitEnabled(const bool enabled)
|
||||
{
|
||||
if (enabled == isAltGlobalSpeedLimitEnabled()) return;
|
||||
|
||||
|
@ -306,10 +306,6 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
connect(m_ui->spinPort, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkRandomPort, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkUPnP, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkUploadLimit, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkDownloadLimit, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkUploadLimitAlt, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkDownloadLimitAlt, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinUploadLimit, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinDownloadLimit, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->spinUploadLimitAlt, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
@ -643,15 +639,13 @@ void OptionsDialog::saveOptions()
|
||||
session->setPort(getPort());
|
||||
session->setUseRandomPort(m_ui->checkRandomPort->isChecked());
|
||||
Net::PortForwarder::instance()->setEnabled(isUPnPEnabled());
|
||||
const QPair<int, int> downUpLimit = getGlobalBandwidthLimits();
|
||||
session->setGlobalDownloadSpeedLimit(downUpLimit.first);
|
||||
session->setGlobalUploadSpeedLimit(downUpLimit.second);
|
||||
session->setGlobalDownloadSpeedLimit(m_ui->spinDownloadLimit->value() * 1024);
|
||||
session->setGlobalUploadSpeedLimit(m_ui->spinUploadLimit->value() * 1024);
|
||||
session->setAltGlobalDownloadSpeedLimit(m_ui->spinDownloadLimitAlt->value() * 1024);
|
||||
session->setAltGlobalUploadSpeedLimit(m_ui->spinUploadLimitAlt->value() * 1024);
|
||||
session->setUTPRateLimited(m_ui->checkLimituTPConnections->isChecked());
|
||||
session->setIncludeOverheadInLimits(m_ui->checkLimitTransportOverhead->isChecked());
|
||||
session->setIgnoreLimitsOnLAN(!m_ui->checkLimitLocalPeerRate->isChecked());
|
||||
const QPair<int, int> altDownUpLimit = getAltGlobalBandwidthLimits();
|
||||
session->setAltGlobalDownloadSpeedLimit(altDownUpLimit.first);
|
||||
session->setAltGlobalUploadSpeedLimit(altDownUpLimit.second);
|
||||
pref->setSchedulerStartTime(m_ui->timeEditScheduleFrom->time());
|
||||
pref->setSchedulerEndTime(m_ui->timeEditScheduleTo->time());
|
||||
pref->setSchedulerDays(static_cast<SchedulerDays>(m_ui->comboBoxScheduleDays->currentIndex()));
|
||||
@ -1010,55 +1004,10 @@ void OptionsDialog::loadOptions()
|
||||
// End Connection preferences
|
||||
|
||||
// Speed preferences
|
||||
intValue = session->globalDownloadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkDownloadLimit->setChecked(true);
|
||||
m_ui->spinDownloadLimit->setEnabled(true);
|
||||
m_ui->spinDownloadLimit->setValue(intValue);
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
m_ui->checkDownloadLimit->setChecked(false);
|
||||
m_ui->spinDownloadLimit->setEnabled(false);
|
||||
}
|
||||
intValue = session->globalUploadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkUploadLimit->setChecked(true);
|
||||
m_ui->spinUploadLimit->setEnabled(true);
|
||||
m_ui->spinUploadLimit->setValue(intValue);
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
m_ui->checkUploadLimit->setChecked(false);
|
||||
m_ui->spinUploadLimit->setEnabled(false);
|
||||
}
|
||||
|
||||
intValue = session->altGlobalDownloadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkDownloadLimitAlt->setChecked(true);
|
||||
m_ui->spinDownloadLimitAlt->setEnabled(true);
|
||||
m_ui->spinDownloadLimitAlt->setValue(intValue);
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
m_ui->checkDownloadLimitAlt->setChecked(false);
|
||||
m_ui->spinDownloadLimitAlt->setEnabled(false);
|
||||
}
|
||||
intValue = session->altGlobalUploadSpeedLimit() / 1024;
|
||||
if (intValue > 0) {
|
||||
// Enabled
|
||||
m_ui->checkUploadLimitAlt->setChecked(true);
|
||||
m_ui->spinUploadLimitAlt->setEnabled(true);
|
||||
m_ui->spinUploadLimitAlt->setValue(intValue);
|
||||
}
|
||||
else {
|
||||
// Disabled
|
||||
m_ui->checkUploadLimitAlt->setChecked(false);
|
||||
m_ui->spinUploadLimitAlt->setEnabled(false);
|
||||
}
|
||||
m_ui->spinDownloadLimit->setValue(session->globalDownloadSpeedLimit() / 1024);
|
||||
m_ui->spinUploadLimit->setValue(session->globalUploadSpeedLimit() / 1024);
|
||||
m_ui->spinDownloadLimitAlt->setValue(session->altGlobalDownloadSpeedLimit() / 1024);
|
||||
m_ui->spinUploadLimitAlt->setValue(session->altGlobalUploadSpeedLimit() / 1024);
|
||||
|
||||
m_ui->checkLimituTPConnections->setChecked(session->isUTPRateLimited());
|
||||
m_ui->checkLimitTransportOverhead->setChecked(session->includeOverheadInLimits());
|
||||
@ -1198,30 +1147,6 @@ bool OptionsDialog::isUPnPEnabled() const
|
||||
return m_ui->checkUPnP->isChecked();
|
||||
}
|
||||
|
||||
// Return Download & Upload limits in kbps
|
||||
// [download,upload]
|
||||
QPair<int, int> OptionsDialog::getGlobalBandwidthLimits() const
|
||||
{
|
||||
int DL = 0, UP = 0;
|
||||
if (m_ui->checkDownloadLimit->isChecked())
|
||||
DL = m_ui->spinDownloadLimit->value() * 1024;
|
||||
if (m_ui->checkUploadLimit->isChecked())
|
||||
UP = m_ui->spinUploadLimit->value() * 1024;
|
||||
return qMakePair(DL, UP);
|
||||
}
|
||||
|
||||
// Return alternate Download & Upload limits in kbps
|
||||
// [download,upload]
|
||||
QPair<int, int> OptionsDialog::getAltGlobalBandwidthLimits() const
|
||||
{
|
||||
int DL = 0, UP = 0;
|
||||
if (m_ui->checkDownloadLimitAlt->isChecked())
|
||||
DL = m_ui->spinDownloadLimitAlt->value() * 1024;
|
||||
if (m_ui->checkUploadLimitAlt->isChecked())
|
||||
UP = m_ui->spinUploadLimitAlt->value() * 1024;
|
||||
return qMakePair(DL, UP);
|
||||
}
|
||||
|
||||
bool OptionsDialog::startMinimized() const
|
||||
{
|
||||
return m_ui->checkStartMinimized->isChecked();
|
||||
|
@ -137,8 +137,6 @@ private:
|
||||
// Connection options
|
||||
int getPort() const;
|
||||
bool isUPnPEnabled() const;
|
||||
QPair<int, int> getGlobalBandwidthLimits() const;
|
||||
QPair<int, int> getAltGlobalBandwidthLimits() const;
|
||||
// Bittorrent options
|
||||
int getMaxConnecs() const;
|
||||
int getMaxConnecsPerTorrent() const;
|
||||
|
@ -1812,15 +1812,12 @@
|
||||
<layout class="QGridLayout" name="rateLimitBoxLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="spinUploadLimit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<property name="specialValueText">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> KiB/s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
@ -1829,24 +1826,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkUploadLimit">
|
||||
<property name="text">
|
||||
<string>Upload:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="spinDownloadLimit">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<property name="specialValueText">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> KiB/s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
@ -1858,13 +1845,6 @@
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="labelGlobalRate"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkDownloadLimit">
|
||||
<property name="text">
|
||||
<string>Download:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
@ -1878,6 +1858,20 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Upload:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Download:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1887,6 +1881,22 @@
|
||||
<string>Alternative Rate Limits</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="spinDownloadLimitAlt">
|
||||
<property name="specialValueText">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> KiB/s</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="labelAltRate"/>
|
||||
</item>
|
||||
@ -2001,50 +2011,14 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkUploadLimitAlt">
|
||||
<property name="text">
|
||||
<string>Upload:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkDownloadLimitAlt">
|
||||
<property name="text">
|
||||
<string>Download:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="spinUploadLimitAlt">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<property name="specialValueText">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> KiB/s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="spinDownloadLimitAlt">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> KiB/s</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000</number>
|
||||
</property>
|
||||
@ -2066,6 +2040,20 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Upload:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Download:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -3432,15 +3420,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
|
||||
<tabstop>checkIpFilterTrackers</tabstop>
|
||||
<tabstop>scrollArea_9</tabstop>
|
||||
<tabstop>spinUploadLimit</tabstop>
|
||||
<tabstop>checkUploadLimit</tabstop>
|
||||
<tabstop>spinDownloadLimit</tabstop>
|
||||
<tabstop>checkDownloadLimit</tabstop>
|
||||
<tabstop>groupBoxSchedule</tabstop>
|
||||
<tabstop>timeEditScheduleTo</tabstop>
|
||||
<tabstop>timeEditScheduleFrom</tabstop>
|
||||
<tabstop>comboBoxScheduleDays</tabstop>
|
||||
<tabstop>checkUploadLimitAlt</tabstop>
|
||||
<tabstop>checkDownloadLimitAlt</tabstop>
|
||||
<tabstop>spinUploadLimitAlt</tabstop>
|
||||
<tabstop>spinDownloadLimitAlt</tabstop>
|
||||
<tabstop>checkLimitLocalPeerRate</tabstop>
|
||||
@ -3476,38 +3460,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>checkUploadLimit</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinUploadLimit</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>367</x>
|
||||
<y>61</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>448</x>
|
||||
<y>62</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkDownloadLimit</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinDownloadLimit</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>377</x>
|
||||
<y>81</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>430</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkMaxConnecs</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
@ -3572,38 +3524,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkDownloadLimitAlt</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinDownloadLimitAlt</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>547</x>
|
||||
<y>415</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>815</x>
|
||||
<y>413</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkUploadLimitAlt</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>spinUploadLimitAlt</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>604</x>
|
||||
<y>271</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>677</x>
|
||||
<y>272</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkMaxRatio</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <QWheelEvent>
|
||||
|
||||
#include "base/bittorrent/peerinfo.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrenthandle.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/net/geoipmanager.h"
|
||||
|
@ -28,16 +28,14 @@
|
||||
|
||||
#include "speedlimitdialog.h"
|
||||
|
||||
#include "base/unicodestrings.h"
|
||||
#include "ui_speedlimitdialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::SpeedLimitDialog())
|
||||
, m_ui(new Ui::SpeedLimitDialog)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
qDebug("Bandwidth allocation dialog creation");
|
||||
|
||||
// Connect to slots
|
||||
connect(m_ui->bandwidthSlider, &QSlider::valueChanged, this, &SpeedLimitDialog::updateSpinValue);
|
||||
@ -49,73 +47,59 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
|
||||
|
||||
SpeedLimitDialog::~SpeedLimitDialog()
|
||||
{
|
||||
qDebug("Deleting bandwidth allocation dialog");
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
// -2: if cancel
|
||||
long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long defaultVal, long maxVal)
|
||||
long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, const QString &title, const long defaultVal, const long maxVal)
|
||||
{
|
||||
if (ok) *ok = false;
|
||||
|
||||
SpeedLimitDialog dlg(parent);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.setupDialog(maxVal / 1024., defaultVal / 1024.);
|
||||
dlg.setupDialog((maxVal / 1024.), (defaultVal / 1024.));
|
||||
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
*ok = true;
|
||||
int val = dlg.getSpeedLimit();
|
||||
if (val <= 0)
|
||||
if (ok) *ok = true;
|
||||
|
||||
const int val = dlg.getSpeedLimit();
|
||||
if (val < 0)
|
||||
return 0;
|
||||
return (val * 1024);
|
||||
}
|
||||
else {
|
||||
*ok = false;
|
||||
return -2;
|
||||
}
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
void SpeedLimitDialog::updateSpinValue(int val) const
|
||||
void SpeedLimitDialog::updateSpinValue(const int value)
|
||||
{
|
||||
qDebug("Called updateSpinValue with %d", val);
|
||||
if (val <= 0) {
|
||||
m_ui->spinBandwidth->setValue(0);
|
||||
m_ui->spinBandwidth->setSpecialValueText(QString::fromUtf8(C_INFINITY));
|
||||
m_ui->spinBandwidth->setSuffix("");
|
||||
}
|
||||
else {
|
||||
m_ui->spinBandwidth->setValue(val);
|
||||
m_ui->spinBandwidth->setSuffix(' ' + tr("KiB/s"));
|
||||
}
|
||||
m_ui->spinBandwidth->setValue(value);
|
||||
}
|
||||
|
||||
void SpeedLimitDialog::updateSliderValue(int val) const
|
||||
void SpeedLimitDialog::updateSliderValue(const int value)
|
||||
{
|
||||
if (val <= 0) {
|
||||
m_ui->spinBandwidth->setValue(0);
|
||||
m_ui->spinBandwidth->setSpecialValueText(QString::fromUtf8(C_INFINITY));
|
||||
m_ui->spinBandwidth->setSuffix("");
|
||||
}
|
||||
if (val > m_ui->bandwidthSlider->maximum())
|
||||
m_ui->bandwidthSlider->setMaximum(val);
|
||||
m_ui->bandwidthSlider->setValue(val);
|
||||
if (value > m_ui->bandwidthSlider->maximum())
|
||||
m_ui->bandwidthSlider->setMaximum(value);
|
||||
m_ui->bandwidthSlider->setValue(value);
|
||||
}
|
||||
|
||||
long SpeedLimitDialog::getSpeedLimit() const
|
||||
int SpeedLimitDialog::getSpeedLimit() const
|
||||
{
|
||||
long val = m_ui->bandwidthSlider->value();
|
||||
if (val > 0)
|
||||
return val;
|
||||
return -1;
|
||||
return m_ui->spinBandwidth->value();
|
||||
}
|
||||
|
||||
void SpeedLimitDialog::setupDialog(long maxSlider, long val) const
|
||||
void SpeedLimitDialog::setupDialog(long maxSlider, long val)
|
||||
{
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
val = qMax<long>(0, val);
|
||||
|
||||
if (maxSlider <= 0)
|
||||
maxSlider = 10000;
|
||||
|
||||
// This can happen for example if global rate limit is lower
|
||||
// than torrent rate limit.
|
||||
if (val > maxSlider)
|
||||
maxSlider = val;
|
||||
|
||||
m_ui->bandwidthSlider->setMaximum(maxSlider);
|
||||
m_ui->bandwidthSlider->setValue(val);
|
||||
updateSpinValue(val);
|
||||
|
@ -31,9 +31,6 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/utils/misc.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class SpeedLimitDialog;
|
||||
@ -46,15 +43,15 @@ class SpeedLimitDialog : public QDialog
|
||||
public:
|
||||
explicit SpeedLimitDialog(QWidget *parent);
|
||||
~SpeedLimitDialog();
|
||||
static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long defaultVal, long maxVal=10240000);
|
||||
static long askSpeedLimit(QWidget *parent, bool *ok, const QString &title, long defaultVal, long maxVal = 10240000);
|
||||
|
||||
protected slots:
|
||||
void updateSpinValue(int val) const;
|
||||
void updateSliderValue(int val) const;
|
||||
void setupDialog(long maxSlider, long val) const;
|
||||
private slots:
|
||||
void updateSpinValue(int val);
|
||||
void updateSliderValue(int val);
|
||||
|
||||
private:
|
||||
long getSpeedLimit() const;
|
||||
void setupDialog(long maxSlider, long val);
|
||||
int getSpeedLimit() const;
|
||||
|
||||
Ui::SpeedLimitDialog *m_ui;
|
||||
};
|
||||
|
@ -22,12 +22,15 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBandwidth">
|
||||
<property name="specialValueText">
|
||||
<string>∞</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> KiB/s</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -206,18 +206,19 @@ void StatusBar::updateSpeedLabels()
|
||||
{
|
||||
const BitTorrent::SessionStatus &sessionStatus = BitTorrent::Session::instance()->status();
|
||||
|
||||
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate, true);
|
||||
int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit();
|
||||
if (speedLimit)
|
||||
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + ']';
|
||||
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload) + ')';
|
||||
m_dlSpeedLbl->setText(speedLbl);
|
||||
speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit();
|
||||
speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate, true);
|
||||
if (speedLimit)
|
||||
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + ']';
|
||||
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload) + ')';
|
||||
m_upSpeedLbl->setText(speedLbl);
|
||||
QString dlSpeedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate, true);
|
||||
const int dlSpeedLimit = BitTorrent::Session::instance()->downloadSpeedLimit();
|
||||
if (dlSpeedLimit > 0)
|
||||
dlSpeedLbl += " [" + Utils::Misc::friendlyUnit(dlSpeedLimit, true) + ']';
|
||||
dlSpeedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload) + ')';
|
||||
m_dlSpeedLbl->setText(dlSpeedLbl);
|
||||
|
||||
QString upSpeedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate, true);
|
||||
const int upSpeedLimit = BitTorrent::Session::instance()->uploadSpeedLimit();
|
||||
if (upSpeedLimit > 0)
|
||||
upSpeedLbl += " [" + Utils::Misc::friendlyUnit(upSpeedLimit, true) + ']';
|
||||
upSpeedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload) + ')';
|
||||
m_upSpeedLbl->setText(upSpeedLbl);
|
||||
}
|
||||
|
||||
void StatusBar::refresh()
|
||||
|
@ -147,11 +147,11 @@ void AppController::preferencesAction()
|
||||
// Global Rate Limits
|
||||
data["dl_limit"] = session->globalDownloadSpeedLimit();
|
||||
data["up_limit"] = session->globalUploadSpeedLimit();
|
||||
data["alt_dl_limit"] = session->altGlobalDownloadSpeedLimit();
|
||||
data["alt_up_limit"] = session->altGlobalUploadSpeedLimit();
|
||||
data["bittorrent_protocol"] = static_cast<int>(session->btProtocol());
|
||||
data["limit_utp_rate"] = session->isUTPRateLimited();
|
||||
data["limit_tcp_overhead"] = session->includeOverheadInLimits();
|
||||
data["alt_dl_limit"] = session->altGlobalDownloadSpeedLimit();
|
||||
data["alt_up_limit"] = session->altGlobalUploadSpeedLimit();
|
||||
// Scheduling
|
||||
data["scheduler_enabled"] = session->isBandwidthSchedulerEnabled();
|
||||
const QTime start_time = pref->getSchedulerStartTime();
|
||||
@ -368,16 +368,16 @@ void AppController::setPreferencesAction()
|
||||
session->setGlobalDownloadSpeedLimit(m["dl_limit"].toInt());
|
||||
if (m.contains("up_limit"))
|
||||
session->setGlobalUploadSpeedLimit(m["up_limit"].toInt());
|
||||
if (m.contains("alt_dl_limit"))
|
||||
session->setAltGlobalDownloadSpeedLimit(m["alt_dl_limit"].toInt());
|
||||
if (m.contains("alt_up_limit"))
|
||||
session->setAltGlobalUploadSpeedLimit(m["alt_up_limit"].toInt());
|
||||
if (m.contains("bittorrent_protocol"))
|
||||
session->setBTProtocol(static_cast<BitTorrent::BTProtocol>(m["bittorrent_protocol"].toInt()));
|
||||
if (m.contains("limit_utp_rate"))
|
||||
session->setUTPRateLimited(m["limit_utp_rate"].toBool());
|
||||
if (m.contains("limit_tcp_overhead"))
|
||||
session->setIncludeOverheadInLimits(m["limit_tcp_overhead"].toBool());
|
||||
if (m.contains("alt_dl_limit"))
|
||||
session->setAltGlobalDownloadSpeedLimit(m["alt_dl_limit"].toInt());
|
||||
if (m.contains("alt_up_limit"))
|
||||
session->setAltGlobalUploadSpeedLimit(m["alt_up_limit"].toInt());
|
||||
// Scheduling
|
||||
if (m.contains("scheduler_enabled"))
|
||||
session->setBandwidthSchedulerEnabled(m["scheduler_enabled"].toBool());
|
||||
|
@ -211,40 +211,30 @@
|
||||
<legend>QBT_TR(Global Rate Limits)QBT_TR[CONTEXT=OptionsDialog]</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" id="up_limit_checkbox" onclick="updateUpLimitEnabled();" />
|
||||
<label for="up_limit_checkbox">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</td>
|
||||
<td><input type="text" id="up_limit_value" style="width: 4em;" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
<td><label for="up_limit_value">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
|
||||
<td><input type="number" id="up_limit_value" style="width: 4em;" min="0" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" id="dl_limit_checkbox" onclick="updateDlLimitEnabled();" />
|
||||
<label for="dl_limit_checkbox">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</td>
|
||||
<td><input type="text" id="dl_limit_value" style="width: 4em;" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
<td><label for="dl_limit_value">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
|
||||
<td><input type="number" id="dl_limit_value" style="width: 4em;" min="0" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
</tr>
|
||||
</table>
|
||||
<i>QBT_TR(0 means unlimited)QBT_TR[CONTEXT=OptionsDialog]</i>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="settings">
|
||||
<legend>QBT_TR(Alternative Rate Limits)QBT_TR[CONTEXT=OptionsDialog]</legend>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" id="alt_up_limit_checkbox" onclick="updateAltUpLimitEnabled();" />
|
||||
<label for="alt_up_limit_checkbox">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</td>
|
||||
<td><input type="text" id="alt_up_limit_value" style="width: 4em;" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
<td><label for="alt_up_limit_value">QBT_TR(Upload:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
|
||||
<td><input type="number" id="alt_up_limit_value" style="width: 4em;" min="0" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" id="alt_dl_limit_checkbox" onclick="updateAltDlLimitEnabled();" />
|
||||
<label for="alt_dl_limit_checkbox">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</td>
|
||||
<td><input type="text" id="alt_dl_limit_value" style="width: 4em;" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
<td><label for="alt_dl_limit_value">QBT_TR(Download:)QBT_TR[CONTEXT=OptionsDialog]</label></td>
|
||||
<td><input type="number" id="alt_dl_limit_value" style="width: 4em;" min="0" /> QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog]</td>
|
||||
</tr>
|
||||
</table>
|
||||
<i>QBT_TR(0 means unlimited)QBT_TR[CONTEXT=OptionsDialog]</i>
|
||||
|
||||
<fieldset class="settings">
|
||||
<legend><input type="checkbox" id="limit_sheduling_checkbox" onclick="updateSchedulingEnabled();" />
|
||||
@ -677,26 +667,6 @@
|
||||
};
|
||||
|
||||
// Speed tab
|
||||
updateUpLimitEnabled = function() {
|
||||
var isUpLimitEnabled = $('up_limit_checkbox').getProperty('checked');
|
||||
$('up_limit_value').setProperty('disabled', !isUpLimitEnabled);
|
||||
};
|
||||
|
||||
updateDlLimitEnabled = function() {
|
||||
var isDlLimitEnabled = $('dl_limit_checkbox').getProperty('checked');
|
||||
$('dl_limit_value').setProperty('disabled', !isDlLimitEnabled);
|
||||
};
|
||||
|
||||
updateAltUpLimitEnabled = function() {
|
||||
var isAltUpLimitEnabled = $('alt_up_limit_checkbox').getProperty('checked');
|
||||
$('alt_up_limit_value').setProperty('disabled', !isAltUpLimitEnabled);
|
||||
};
|
||||
|
||||
updateAltDlLimitEnabled = function() {
|
||||
var isAltDlLimitEnabled = $('alt_dl_limit_checkbox').getProperty('checked');
|
||||
$('alt_dl_limit_value').setProperty('disabled', !isAltDlLimitEnabled);
|
||||
};
|
||||
|
||||
updateSchedulingEnabled = function() {
|
||||
var isLimitSchedulingEnabled = $('limit_sheduling_checkbox').getProperty('checked');
|
||||
$('schedule_from_hour').setProperty('disabled', !isLimitSchedulingEnabled);
|
||||
@ -918,48 +888,16 @@
|
||||
|
||||
// Speed tab
|
||||
// Global Rate Limits
|
||||
var up_limit = pref.up_limit.toInt() / 1024;
|
||||
if (up_limit <= 0) {
|
||||
$('up_limit_checkbox').setProperty('checked', false);
|
||||
}
|
||||
else {
|
||||
$('up_limit_checkbox').setProperty('checked', true);
|
||||
$('up_limit_value').setProperty('value', up_limit);
|
||||
}
|
||||
updateUpLimitEnabled();
|
||||
var dl_limit = pref.dl_limit.toInt() / 1024;
|
||||
if (dl_limit <= 0) {
|
||||
$('dl_limit_checkbox').setProperty('checked', false);
|
||||
}
|
||||
else {
|
||||
$('dl_limit_checkbox').setProperty('checked', true);
|
||||
$('dl_limit_value').setProperty('value', dl_limit);
|
||||
}
|
||||
updateDlLimitEnabled();
|
||||
$('up_limit_value').setProperty('value', (pref.up_limit.toInt() / 1024));
|
||||
$('dl_limit_value').setProperty('value', (pref.dl_limit.toInt() / 1024));
|
||||
// Alternative Global Rate Limits
|
||||
$('alt_up_limit_value').setProperty('value', (pref.alt_up_limit.toInt() / 1024));
|
||||
$('alt_dl_limit_value').setProperty('value', (pref.alt_dl_limit.toInt() / 1024));
|
||||
|
||||
$('enable_protocol_combobox').setProperty('value', pref.bittorrent_protocol);
|
||||
$('limit_utp_rate_checkbox').setProperty('checked', pref.limit_utp_rate);
|
||||
$('limit_tcp_overhead_checkbox').setProperty('checked', pref.limit_tcp_overhead);
|
||||
|
||||
// Alternative Global Rate Limits
|
||||
var alt_up_limit = pref.alt_up_limit.toInt() / 1024;
|
||||
if (alt_up_limit <= 0) {
|
||||
$('alt_up_limit_checkbox').setProperty('checked', false);
|
||||
}
|
||||
else {
|
||||
$('alt_up_limit_checkbox').setProperty('checked', true);
|
||||
$('alt_up_limit_value').setProperty('value', alt_up_limit);
|
||||
}
|
||||
updateAltUpLimitEnabled();
|
||||
var alt_dl_limit = pref.alt_dl_limit.toInt() / 1024;
|
||||
if (alt_dl_limit <= 0) {
|
||||
$('alt_dl_limit_checkbox').setProperty('checked', false);
|
||||
}
|
||||
else {
|
||||
$('alt_dl_limit_checkbox').setProperty('checked', true);
|
||||
$('alt_dl_limit_value').setProperty('value', alt_dl_limit);
|
||||
}
|
||||
updateAltDlLimitEnabled();
|
||||
|
||||
// Scheduling
|
||||
$('limit_sheduling_checkbox').setProperty('checked', pref.scheduler_enabled);
|
||||
$('schedule_from_hour').setProperty('value', time_padding(pref.schedule_from_hour));
|
||||
@ -1175,48 +1113,39 @@
|
||||
|
||||
// Speed tab
|
||||
// Global Rate Limits
|
||||
var up_limit = -1;
|
||||
if ($('up_limit_checkbox').getProperty('checked')) {
|
||||
up_limit = $('up_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(up_limit) || up_limit <= 0) {
|
||||
alert("QBT_TR(Global upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
var up_limit = $('up_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(up_limit) || up_limit < 0) {
|
||||
alert("QBT_TR(Global upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
settings.set('up_limit', up_limit);
|
||||
var dl_limit = -1;
|
||||
if ($('dl_limit_checkbox').getProperty('checked')) {
|
||||
dl_limit = $('dl_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(dl_limit) || dl_limit <= 0) {
|
||||
alert("QBT_TR(Global download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
|
||||
var dl_limit = $('dl_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(dl_limit) || dl_limit < 0) {
|
||||
alert("QBT_TR(Global download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
settings.set('dl_limit', dl_limit);
|
||||
|
||||
// Alternative Global Rate Limits
|
||||
var alt_up_limit = $('alt_up_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(alt_up_limit) || alt_up_limit < 0) {
|
||||
alert("QBT_TR(Alternative upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
settings.set('alt_up_limit', alt_up_limit);
|
||||
|
||||
var alt_dl_limit = $('alt_dl_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(alt_dl_limit) || alt_dl_limit < 0) {
|
||||
alert("QBT_TR(Alternative download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
settings.set('alt_dl_limit', alt_dl_limit);
|
||||
|
||||
settings.set('bittorrent_protocol', $('enable_protocol_combobox').getProperty('value'));
|
||||
settings.set('limit_utp_rate', $('limit_utp_rate_checkbox').getProperty('checked'));
|
||||
settings.set('limit_tcp_overhead', $('limit_tcp_overhead_checkbox').getProperty('checked'));
|
||||
|
||||
// Alternative Global Rate Limits
|
||||
var alt_up_limit = -1;
|
||||
if ($('alt_up_limit_checkbox').getProperty('checked')) {
|
||||
alt_up_limit = $('alt_up_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(alt_up_limit) || alt_up_limit <= 0) {
|
||||
alert("QBT_TR(Alternative upload rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
settings.set('alt_up_limit', alt_up_limit);
|
||||
var alt_dl_limit = -1;
|
||||
if ($('alt_dl_limit_checkbox').getProperty('checked')) {
|
||||
alt_dl_limit = $('alt_dl_limit_value').getProperty('value').toInt() * 1024;
|
||||
if (isNaN(alt_dl_limit) || alt_dl_limit <= 0) {
|
||||
alert("QBT_TR(Alternative download rate limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
settings.set('alt_dl_limit', alt_dl_limit);
|
||||
|
||||
// Scheduler
|
||||
var scheduling_enabled = $('limit_sheduling_checkbox').getProperty('checked');
|
||||
settings.set('scheduler_enabled', scheduling_enabled);
|
||||
|
Loading…
x
Reference in New Issue
Block a user