Browse Source

Merge pull request #8372 from thalieht/inactiverate

Expose the libtorrent fields for "dont_count_slow_torrents" to GUI.
Closes #5713.
adaptive-webui-19844
Vladimir Golovnev 7 years ago committed by GitHub
parent
commit
6207855f3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      src/base/bittorrent/session.cpp
  2. 9
      src/base/bittorrent/session.h
  3. 19
      src/gui/optionsdlg.cpp
  4. 125
      src/gui/optionsdlg.ui

48
src/base/bittorrent/session.cpp

@ -295,6 +295,9 @@ Session::Session(QObject *parent) @@ -295,6 +295,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)
@ -1327,6 +1330,9 @@ void Session::configure(libtorrent::settings_pack &settingsPack) @@ -1327,6 +1330,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);
@ -3208,6 +3214,48 @@ void Session::setIgnoreSlowTorrentsForQueueing(bool ignore) @@ -3208,6 +3214,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;

9
src/base/bittorrent/session.h

@ -398,6 +398,12 @@ namespace BitTorrent @@ -398,6 +398,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;
@ -659,6 +665,9 @@ namespace BitTorrent @@ -659,6 +665,9 @@ namespace BitTorrent
CachedSettingValue<int> m_maxActiveUploads;
CachedSettingValue<int> m_maxActiveTorrents;
CachedSettingValue<bool> m_ignoreSlowTorrentsForQueueing;
CachedSettingValue<int> m_downloadRateForSlowTorrents;
CachedSettingValue<int> m_uploadRateForSlowTorrents;
CachedSettingValue<int> m_slowTorrentsInactivityTimer;
CachedSettingValue<int> m_outgoingPortsMin;
CachedSettingValue<int> m_outgoingPortsMax;
CachedSettingValue<bool> m_ignoreLimitsOnLAN;

19
src/gui/optionsdlg.cpp

@ -347,9 +347,20 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -347,9 +347,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("<html><body><p>")
+ tr("A torrent will be considered slow if its download and upload rates stay below these values for \"Torrent inactivity timer\" seconds")
+ QLatin1String("</p></body></html>");
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);
@ -659,6 +670,9 @@ void OptionsDialog::saveOptions() @@ -659,6 +670,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());
@ -1033,6 +1047,9 @@ void OptionsDialog::loadOptions() @@ -1033,6 +1047,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

125
src/gui/optionsdlg.ui

@ -2362,10 +2362,124 @@ @@ -2362,10 +2362,124 @@
</spacer>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="checkIgnoreSlowTorrentsForQueueing">
<property name="text">
<widget class="QGroupBox" name="checkIgnoreSlowTorrentsForQueueing">
<property name="title">
<string>Do not count slow torrents in these limits</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="2" column="3">
<spacer name="horizontalSpacer_21">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinDownloadRateForSlowTorrents">
<property name="suffix">
<string> KiB/s</string>
</property>
<property name="maximum">
<number>2000000</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinUploadRateForSlowTorrents">
<property name="suffix">
<string> KiB/s</string>
</property>
<property name="maximum">
<number>2000000</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelUploadRateForSlowTorrents">
<property name="text">
<string>Upload rate threshold:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelDownloadRateForSlowTorrents">
<property name="text">
<string>Download rate threshold:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinSlowTorrentsInactivityTimer">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="value">
<number>60</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSlowTorrentInactivityTimer">
<property name="text">
<string>Torrent inactivity timer:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="labelSeconds">
<property name="text">
<string>seconds</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@ -2784,8 +2898,8 @@ @@ -2784,8 +2898,8 @@
<widget class="QLineEdit" name="textWebUiAddress">
<property name="toolTip">
<string>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.</string>
Specify an IPv4 or IPv6 address. You can specify &quot;0.0.0.0&quot; for any IPv4 address,
&quot;::&quot; for any IPv6 address, or &quot;*&quot; for both IPv4 and IPv6.</string>
</property>
</widget>
</item>
@ -2996,7 +3110,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -2996,7 +3110,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="1">
<item row="6" column="1">
<widget class="QPushButton" name="IPSubnetWhitelistButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -3303,7 +3417,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string> @@ -3303,7 +3417,6 @@ Use ';' to split multiple entries. Can use wildcard '*'.</string>
<tabstop>spinMaxActiveDownloads</tabstop>
<tabstop>spinMaxActiveUploads</tabstop>
<tabstop>spinMaxActiveTorrents</tabstop>
<tabstop>checkIgnoreSlowTorrentsForQueueing</tabstop>
<tabstop>checkMaxRatio</tabstop>
<tabstop>spinMaxRatio</tabstop>
<tabstop>checkMaxSeedingMinutes</tabstop>

Loading…
Cancel
Save