diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 707761ff2..956b36ea5 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -290,6 +290,9 @@ Session::Session(QObject *parent) , m_maxActiveUploads(BITTORRENT_SESSION_KEY("MaxActiveUploads"), 3, lowerLimited(-1)) , m_maxActiveTorrents(BITTORRENT_SESSION_KEY("MaxActiveTorrents"), 5, lowerLimited(-1)) , m_ignoreSlowTorrentsForQueueing(BITTORRENT_SESSION_KEY("IgnoreSlowTorrentsForQueueing"), false) + , m_downloadRateForSlowTorrents(BITTORRENT_SESSION_KEY("SlowTorrentsDownloadRate"), 2) + , m_uploadRateForSlowTorrents(BITTORRENT_SESSION_KEY("SlowTorrentsUploadRate"), 2) + , m_slowTorrentsInactivityTimer(BITTORRENT_SESSION_KEY("SlowTorrentsInactivityTimer"), 60) , m_outgoingPortsMin(BITTORRENT_SESSION_KEY("OutgoingPortsMin"), 0) , m_outgoingPortsMax(BITTORRENT_SESSION_KEY("OutgoingPortsMax"), 0) , m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), true) @@ -1318,6 +1321,9 @@ void Session::configure(libtorrent::settings_pack &settingsPack) settingsPack.set_int(libt::settings_pack::active_seeds, maxActiveUploads()); settingsPack.set_bool(libt::settings_pack::dont_count_slow_torrents, ignoreSlowTorrentsForQueueing()); + settingsPack.set_int(libt::settings_pack::inactive_down_rate, downloadRateForSlowTorrents() * 1024); // KiB to Bytes + settingsPack.set_int(libt::settings_pack::inactive_up_rate, uploadRateForSlowTorrents() * 1024); // KiB to Bytes + settingsPack.set_int(libt::settings_pack::auto_manage_startup, slowTorrentsInactivityTimer()); } else { settingsPack.set_int(libt::settings_pack::active_downloads, -1); @@ -3185,6 +3191,48 @@ void Session::setIgnoreSlowTorrentsForQueueing(bool ignore) } } +int Session::downloadRateForSlowTorrents() const +{ + return m_downloadRateForSlowTorrents; +} + +void Session::setDownloadRateForSlowTorrents(int rateInKibiBytes) +{ + if (rateInKibiBytes == m_downloadRateForSlowTorrents) + return; + + m_downloadRateForSlowTorrents = rateInKibiBytes; + configureDeferred(); +} + +int Session::uploadRateForSlowTorrents() const +{ + return m_uploadRateForSlowTorrents; +} + +void Session::setUploadRateForSlowTorrents(int rateInKibiBytes) +{ + if (rateInKibiBytes == m_uploadRateForSlowTorrents) + return; + + m_uploadRateForSlowTorrents = rateInKibiBytes; + configureDeferred(); +} + +int Session::slowTorrentsInactivityTimer() const +{ + return m_slowTorrentsInactivityTimer; +} + +void Session::setSlowTorrentsInactivityTimer(int timeInSeconds) +{ + if (timeInSeconds == m_slowTorrentsInactivityTimer) + return; + + m_slowTorrentsInactivityTimer = timeInSeconds; + configureDeferred(); +} + int Session::outgoingPortsMin() const { return m_outgoingPortsMin; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 0e219fb1d..953293158 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -396,6 +396,12 @@ namespace BitTorrent void setQueueingSystemEnabled(bool enabled); bool ignoreSlowTorrentsForQueueing() const; void setIgnoreSlowTorrentsForQueueing(bool ignore); + int downloadRateForSlowTorrents() const; + void setDownloadRateForSlowTorrents(int rateInKibiBytes); + int uploadRateForSlowTorrents() const; + void setUploadRateForSlowTorrents(int rateInKibiBytes); + int slowTorrentsInactivityTimer() const; + void setSlowTorrentsInactivityTimer(int timeInSeconds); int outgoingPortsMin() const; void setOutgoingPortsMin(int min); int outgoingPortsMax() const; @@ -656,6 +662,9 @@ namespace BitTorrent CachedSettingValue m_maxActiveUploads; CachedSettingValue m_maxActiveTorrents; CachedSettingValue m_ignoreSlowTorrentsForQueueing; + CachedSettingValue m_downloadRateForSlowTorrents; + CachedSettingValue m_uploadRateForSlowTorrents; + CachedSettingValue m_slowTorrentsInactivityTimer; CachedSettingValue m_outgoingPortsMin; CachedSettingValue m_outgoingPortsMax; CachedSettingValue m_ignoreLimitsOnLAN; diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index 628be70b0..2ac7855a2 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -344,9 +344,20 @@ OptionsDialog::OptionsDialog(QWidget *parent) connect(m_ui->spinMaxActiveDownloads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxActiveUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxActiveTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); - connect(m_ui->checkIgnoreSlowTorrentsForQueueing, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkIgnoreSlowTorrentsForQueueing, &QGroupBox::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->spinDownloadRateForSlowTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); + connect(m_ui->spinUploadRateForSlowTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); + connect(m_ui->spinSlowTorrentsInactivityTimer, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton); connect(m_ui->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton); + + const QString slowTorrentsExplanation = QLatin1String("

") + + tr("A torrent will be considered slow if its download and upload rates stay below these values for \"Torrent inactivity timer\" seconds") + + QLatin1String("

"); + m_ui->labelDownloadRateForSlowTorrents->setToolTip(slowTorrentsExplanation); + m_ui->labelUploadRateForSlowTorrents->setToolTip(slowTorrentsExplanation); + m_ui->labelSlowTorrentInactivityTimer->setToolTip(slowTorrentsExplanation); + #ifndef DISABLE_WEBUI // Web UI tab connect(m_ui->textServerDomains, &QLineEdit::textChanged, this, &ThisType::enableApplyButton); @@ -652,6 +663,9 @@ void OptionsDialog::saveOptions() session->setMaxActiveUploads(m_ui->spinMaxActiveUploads->value()); session->setMaxActiveTorrents(m_ui->spinMaxActiveTorrents->value()); session->setIgnoreSlowTorrentsForQueueing(m_ui->checkIgnoreSlowTorrentsForQueueing->isChecked()); + session->setDownloadRateForSlowTorrents(m_ui->spinDownloadRateForSlowTorrents->value()); + session->setUploadRateForSlowTorrents(m_ui->spinUploadRateForSlowTorrents->value()); + session->setSlowTorrentsInactivityTimer(m_ui->spinSlowTorrentsInactivityTimer->value()); // End Queueing system preferences // Web UI pref->setWebUiEnabled(isWebUiEnabled()); @@ -1021,6 +1035,9 @@ void OptionsDialog::loadOptions() m_ui->spinMaxActiveUploads->setValue(session->maxActiveUploads()); m_ui->spinMaxActiveTorrents->setValue(session->maxActiveTorrents()); m_ui->checkIgnoreSlowTorrentsForQueueing->setChecked(session->ignoreSlowTorrentsForQueueing()); + m_ui->spinDownloadRateForSlowTorrents->setValue(session->downloadRateForSlowTorrents()); + m_ui->spinUploadRateForSlowTorrents->setValue(session->uploadRateForSlowTorrents()); + m_ui->spinSlowTorrentsInactivityTimer->setValue(session->slowTorrentsInactivityTimer()); if (session->globalMaxRatio() >= 0.) { // Enable diff --git a/src/gui/optionsdlg.ui b/src/gui/optionsdlg.ui index f3170a3c8..db100500a 100644 --- a/src/gui/optionsdlg.ui +++ b/src/gui/optionsdlg.ui @@ -2362,10 +2362,124 @@ - - + + Do not count slow torrents in these limits + + true + + + false + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + KiB/s + + + 2000000 + + + 2 + + + + + + + KiB/s + + + 2000000 + + + 2 + + + + + + + Upload rate threshold: + + + + + + + Download rate threshold: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1 + + + 999999 + + + 60 + + + + + + + Torrent inactivity timer: + + + + + + + seconds + + + + @@ -2772,8 +2886,8 @@ IP address that the Web UI will bind to. -Specify an IPv4 or IPv6 address. You can specify "0.0.0.0" for any IPv4 address, -"::" for any IPv6 address, or "*" for both IPv4 and IPv6. +Specify an IPv4 or IPv6 address. You can specify "0.0.0.0" for any IPv4 address, +"::" for any IPv6 address, or "*" for both IPv4 and IPv6. @@ -2984,7 +3098,7 @@ Use ';' to split multiple entries. Can use wildcard '*'. - + @@ -3266,7 +3380,6 @@ Use ';' to split multiple entries. Can use wildcard '*'. spinMaxActiveDownloads spinMaxActiveUploads spinMaxActiveTorrents - checkIgnoreSlowTorrentsForQueueing checkMaxRatio spinMaxRatio checkMaxSeedingMinutes