Browse Source

Merge pull request #16584 from Chocobo1/pr_16548

Allow setting the number of maximum active checking torrents
adaptive-webui-19844
Chocobo1 3 years ago committed by GitHub
parent
commit
5a417c6a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/base/bittorrent/session.cpp
  2. 3
      src/base/bittorrent/session.h
  3. 2
      src/base/bittorrent/torrentimpl.cpp
  4. 3
      src/gui/optionsdialog.cpp
  5. 37
      src/gui/optionsdialog.ui
  6. 5
      src/webui/api/appcontroller.cpp
  7. 2
      src/webui/webapplication.h
  8. 9
      src/webui/www/private/views/preferences.html

17
src/base/bittorrent/session.cpp

@ -450,6 +450,7 @@ Session::Session(QObject *parent) @@ -450,6 +450,7 @@ Session::Session(QObject *parent)
, m_networkInterfaceName(BITTORRENT_SESSION_KEY("InterfaceName"))
, m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress"))
, m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0)
, m_maxActiveCheckingTorrents(BITTORRENT_SESSION_KEY("MaxActiveCheckingTorrents"), 1)
, m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false)
, m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), ChokingAlgorithm::FixedSlots
, clampValue(ChokingAlgorithm::FixedSlots, ChokingAlgorithm::RateBased))
@ -1287,6 +1288,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack) @@ -1287,6 +1288,8 @@ void Session::loadLTSettings(lt::settings_pack &settingsPack)
settingsPack.set_int(lt::settings_pack::in_enc_policy, lt::settings_pack::pe_disabled);
}
settingsPack.set_int(lt::settings_pack::active_checking, maxActiveCheckingTorrents());
// proxy
const auto proxyManager = Net::ProxyConfigurationManager::instance();
const Net::ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
@ -2985,6 +2988,20 @@ void Session::setEncryption(const int state) @@ -2985,6 +2988,20 @@ void Session::setEncryption(const int state)
}
}
int Session::maxActiveCheckingTorrents() const
{
return m_maxActiveCheckingTorrents;
}
void Session::setMaxActiveCheckingTorrents(const int val)
{
if (val == m_maxActiveCheckingTorrents)
return;
m_maxActiveCheckingTorrents = val;
configureDeferred();
}
bool Session::isProxyPeerConnectionsEnabled() const
{
return m_isProxyPeerConnectionsEnabled;

3
src/base/bittorrent/session.h

@ -326,6 +326,8 @@ namespace BitTorrent @@ -326,6 +326,8 @@ namespace BitTorrent
void setNetworkInterfaceAddress(const QString &address);
int encryption() const;
void setEncryption(int state);
int maxActiveCheckingTorrents() const;
void setMaxActiveCheckingTorrents(int val);
bool isProxyPeerConnectionsEnabled() const;
void setProxyPeerConnectionsEnabled(bool enabled);
ChokingAlgorithm chokingAlgorithm() const;
@ -750,6 +752,7 @@ namespace BitTorrent @@ -750,6 +752,7 @@ namespace BitTorrent
CachedSettingValue<QString> m_networkInterfaceName;
CachedSettingValue<QString> m_networkInterfaceAddress;
CachedSettingValue<int> m_encryption;
CachedSettingValue<int> m_maxActiveCheckingTorrents;
CachedSettingValue<bool> m_isProxyPeerConnectionsEnabled;
CachedSettingValue<ChokingAlgorithm> m_chokingAlgorithm;
CachedSettingValue<SeedChokingAlgorithm> m_seedChokingAlgorithm;

2
src/base/bittorrent/torrentimpl.cpp

@ -1925,7 +1925,7 @@ void TorrentImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert @@ -1925,7 +1925,7 @@ void TorrentImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert
void TorrentImpl::handlePerformanceAlert(const lt::performance_alert *p) const
{
LogMsg((tr("Performance alert: %1. More info: %2").arg(QString::fromStdString(p->message())), u"https://libtorrent.org/reference-Alerts.html#enum-performance-warning-t"_qs)
LogMsg((tr("Performance alert: %1. More info: %2").arg(QString::fromStdString(p->message()), u"https://libtorrent.org/reference-Alerts.html#enum-performance-warning-t"_qs))
, Log::INFO);
}

3
src/gui/optionsdialog.cpp

@ -434,6 +434,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) @@ -434,6 +434,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->spinMaxUploadsPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
connect(m_ui->checkDHT, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkAnonymousMode, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->spinBoxMaxActiveCheckingTorrents, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
connect(m_ui->checkPeX, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkLSD, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->comboEncryption, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
@ -816,6 +817,7 @@ void OptionsDialog::saveOptions() @@ -816,6 +817,7 @@ void OptionsDialog::saveOptions()
session->setLSDEnabled(isLSDEnabled());
session->setEncryption(getEncryptionSetting());
session->setAnonymousModeEnabled(m_ui->checkAnonymousMode->isChecked());
session->setMaxActiveCheckingTorrents(m_ui->spinBoxMaxActiveCheckingTorrents->value());
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
session->setGlobalMaxRatio(getMaxRatio());
@ -1208,6 +1210,7 @@ void OptionsDialog::loadOptions() @@ -1208,6 +1210,7 @@ void OptionsDialog::loadOptions()
m_ui->checkLSD->setChecked(session->isLSDEnabled());
m_ui->comboEncryption->setCurrentIndex(session->encryption());
m_ui->checkAnonymousMode->setChecked(session->isAnonymousModeEnabled());
m_ui->spinBoxMaxActiveCheckingTorrents->setValue(session->maxActiveCheckingTorrents());
m_ui->checkEnableAddTrackers->setChecked(session->isAddTrackersEnabled());
m_ui->textTrackers->setPlainText(session->additionalTrackers());

37
src/gui/optionsdialog.ui

@ -2377,6 +2377,43 @@ Disable encryption: Only connect to peers without protocol encryption</string> @@ -2377,6 +2377,43 @@ Disable encryption: Only connect to peers without protocol encryption</string>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="labelMaxActiveCheckingTorrents">
<property name="text">
<string>Maximum active checking torrents:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBoxMaxActiveCheckingTorrents">
<property name="specialValueText">
<string notr="true">∞</string>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2147483647</number>
</property>
</widget>
</item>
<item>
<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>
</layout>
</item>
<item>
<widget class="QGroupBox" name="checkEnableQueueing">
<property name="title">

5
src/webui/api/appcontroller.cpp

@ -210,6 +210,8 @@ void AppController::preferencesAction() @@ -210,6 +210,8 @@ void AppController::preferencesAction()
data["lsd"] = session->isLSDEnabled();
data["encryption"] = session->encryption();
data["anonymous_mode"] = session->isAnonymousModeEnabled();
// Max active checking torrents
data["max_active_checking_torrents"] = session->maxActiveCheckingTorrents();
// Torrent Queueing
data["queueing_enabled"] = session->isQueueingSystemEnabled();
data["max_active_downloads"] = session->maxActiveDownloads();
@ -584,6 +586,9 @@ void AppController::setPreferencesAction() @@ -584,6 +586,9 @@ void AppController::setPreferencesAction()
session->setEncryption(it.value().toInt());
if (hasKey("anonymous_mode"))
session->setAnonymousModeEnabled(it.value().toBool());
// Max active checking torrents
if (hasKey("max_active_checking_torrents"))
session->setMaxActiveCheckingTorrents(it.value().toInt());
// Torrent Queueing
if (hasKey("queueing_enabled"))
session->setQueueingSystemEnabled(it.value().toBool());

2
src/webui/webapplication.h

@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
#include "base/utils/net.h"
#include "base/utils/version.h"
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 8};
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 9};
class APIController;
class WebApplication;

9
src/webui/www/private/views/preferences.html

@ -472,6 +472,11 @@ @@ -472,6 +472,11 @@
</div>
</fieldset>
<div class="formRow">
<label for="maxActiveCheckingTorrents">QBT_TR(Max active checking torrents:)QBT_TR[CONTEXT=OptionsDialog]</label>
<input type="number" id="maxActiveCheckingTorrents" style="width: 4em;" min="-1" />
</div>
<fieldset class="settings">
<legend>
<input type="checkbox" id="queueing_checkbox" onclick="qBittorrent.Preferences.updateQueueingSystem();" />
@ -1835,6 +1840,8 @@ @@ -1835,6 +1840,8 @@
$('encryption_select').getChildren('option')[encryption].setAttribute('selected', '');
$('anonymous_mode_checkbox').setProperty('checked', pref.anonymous_mode);
$('maxActiveCheckingTorrents').setProperty('value', pref.max_active_checking_torrents);
// Torrent Queueing
$('queueing_checkbox').setProperty('checked', pref.queueing_enabled);
$('max_active_dl_value').setProperty('value', pref.max_active_downloads.toInt());
@ -2184,6 +2191,8 @@ @@ -2184,6 +2191,8 @@
settings.set('encryption', $('encryption_select').getSelected()[0].getProperty('value'));
settings.set('anonymous_mode', $('anonymous_mode_checkbox').getProperty('checked'));
settings.set('max_active_checking_torrents', $('maxActiveCheckingTorrents').getProperty('value'));
// Torrent Queueing
settings.set('queueing_enabled', $('queueing_checkbox').getProperty('checked'));
if ($('queueing_checkbox').getProperty('checked')) {

Loading…
Cancel
Save