From d2b7feeca57dc50de5f3581d5ac36e3e78dce9e8 Mon Sep 17 00:00:00 2001 From: lstrsrt <79076531+lstrsrt@users.noreply.github.com> Date: Tue, 5 Aug 2025 16:47:32 +0200 Subject: [PATCH 1/6] Add alternative connection limits option for seeding torrents --- src/base/bittorrent/session.h | 2 ++ src/base/bittorrent/sessionimpl.cpp | 32 ++++++++++++++++++++++++++++- src/base/bittorrent/sessionimpl.h | 3 +++ src/base/bittorrent/torrentimpl.cpp | 19 +++++++++++++++++ src/base/bittorrent/torrentimpl.h | 1 + src/gui/optionsdialog.cpp | 30 +++++++++++++++++++++++++++ src/gui/optionsdialog.h | 1 + src/gui/optionsdialog.ui | 29 +++++++++++++++++++++++--- 8 files changed, 113 insertions(+), 4 deletions(-) diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index cae03ba83..feaba7abc 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -406,6 +406,8 @@ namespace BitTorrent virtual void setMaxConnections(int max) = 0; virtual int maxConnectionsPerTorrent() const = 0; virtual void setMaxConnectionsPerTorrent(int max) = 0; + virtual int maxAltConnectionsPerTorrent() const = 0; + virtual void setMaxAltConnectionsPerTorrent(int max) = 0; virtual int maxUploads() const = 0; virtual void setMaxUploads(int max) = 0; virtual int maxUploadsPerTorrent() const = 0; diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 3bdd9ff13..610947ee1 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -495,6 +495,7 @@ SessionImpl::SessionImpl(QObject *parent) , m_maxConnections(BITTORRENT_SESSION_KEY(u"MaxConnections"_s), 500, lowerLimited(0, -1)) , m_maxUploads(BITTORRENT_SESSION_KEY(u"MaxUploads"_s), 20, lowerLimited(0, -1)) , m_maxConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxConnectionsPerTorrent"_s), 100, lowerLimited(0, -1)) + , m_maxAltConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxAltConnectionsPerTorrent"_s), 40, lowerLimited(0, -1)) , m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxUploadsPerTorrent"_s), 4, lowerLimited(0, -1)) , m_btProtocol(BITTORRENT_SESSION_KEY(u"BTProtocol"_s), BTProtocol::Both , clampValue(BTProtocol::Both, BTProtocol::UTP)) @@ -4355,6 +4356,11 @@ int SessionImpl::maxConnectionsPerTorrent() const return m_maxConnectionsPerTorrent; } +int SessionImpl::maxAltConnectionsPerTorrent() const +{ + return m_maxAltConnectionsPerTorrent; +} + void SessionImpl::setMaxConnectionsPerTorrent(int max) { max = (max > 0) ? max : -1; @@ -4366,7 +4372,31 @@ void SessionImpl::setMaxConnectionsPerTorrent(int max) { try { - torrent->nativeHandle().set_max_connections(max); + if (m_maxAltConnectionsPerTorrent == -1 || !torrent->isUploading()) + { + torrent->nativeHandle().set_max_connections(max); + } + } + catch (const std::exception &) {} + } + } +} + +void SessionImpl::setMaxAltConnectionsPerTorrent(int max) +{ + max = (max > 0) ? max : -1; + if (max != maxAltConnectionsPerTorrent()) + { + m_maxAltConnectionsPerTorrent = max; + + for (const TorrentImpl *torrent : asConst(m_torrents)) + { + try + { + if (torrent->isUploading()) + { + torrent->nativeHandle().set_max_connections(max); + } } catch (const std::exception &) {} } diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index e923f8a13..a51169cad 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -380,6 +380,8 @@ namespace BitTorrent void setMaxConnections(int max) override; int maxConnectionsPerTorrent() const override; void setMaxConnectionsPerTorrent(int max) override; + int maxAltConnectionsPerTorrent() const override; + void setMaxAltConnectionsPerTorrent(int max) override; int maxUploads() const override; void setMaxUploads(int max) override; int maxUploadsPerTorrent() const override; @@ -699,6 +701,7 @@ namespace BitTorrent CachedSettingValue m_maxConnections; CachedSettingValue m_maxUploads; CachedSettingValue m_maxConnectionsPerTorrent; + CachedSettingValue m_maxAltConnectionsPerTorrent; CachedSettingValue m_maxUploadsPerTorrent; CachedSettingValue m_btProtocol; CachedSettingValue m_isUTPRateLimited; diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 1c101d0be..46820ff6a 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -2539,8 +2539,14 @@ void TorrentImpl::updateStatus(const lt::torrent_status &nativeStatus) if (m_nativeStatus.last_seen_complete != oldStatus.last_seen_complete) m_lastSeenComplete = QDateTime::fromSecsSinceEpoch(m_nativeStatus.last_seen_complete); + const bool wasUploading = isUploading(); updateState(); + if (wasUploading ^ isUploading()) { + // Switching from Stopped to Uploading or vice versa may require updating the connection limits. + updateMaxConnections(); + } + m_payloadRateMonitor.addSample({nativeStatus.download_payload_rate , nativeStatus.upload_payload_rate}); @@ -2596,6 +2602,19 @@ void TorrentImpl::updateProgress() } } +void TorrentImpl::updateMaxConnections() +{ + const int maxConnections = m_session->maxConnectionsPerTorrent(); + const int maxAltConnections = m_session->maxAltConnectionsPerTorrent(); + const bool useAltLimit = (maxAltConnections != -1) && isUploading(); + const int max = useAltLimit ? maxAltConnections : maxConnections; + + if (nativeHandle().max_connections() == max) + return; + + nativeHandle().set_max_connections(max); +} + void TorrentImpl::setRatioLimit(qreal limit) { if (limit < USE_GLOBAL_RATIO) diff --git a/src/base/bittorrent/torrentimpl.h b/src/base/bittorrent/torrentimpl.h index e44d875c9..ce8230ff7 100644 --- a/src/base/bittorrent/torrentimpl.h +++ b/src/base/bittorrent/torrentimpl.h @@ -295,6 +295,7 @@ namespace BitTorrent void updateStatus(const lt::torrent_status &nativeStatus); void updateProgress(); void updateState(); + void updateMaxConnections(); bool isMoveInProgress() const; diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 557c5569c..4c1bf2275 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -860,6 +860,19 @@ void OptionsDialog::loadConnectionTabOptions() m_ui->checkMaxConnectionsPerTorrent->setChecked(false); m_ui->spinMaxConnecPerTorrent->setEnabled(false); } + intValue = session->maxAltConnectionsPerTorrent(); + if (intValue > 0) + { + // enable + m_ui->checkMaxAltConnectionsPerTorrent->setChecked(true); + m_ui->spinMaxAltConnecPerTorrent->setValue(intValue); + } + else + { + // disable + m_ui->checkMaxAltConnectionsPerTorrent->setChecked(false); + m_ui->spinMaxAltConnecPerTorrent->setEnabled(false); + } intValue = session->maxUploads(); if (intValue > 0) { @@ -938,12 +951,20 @@ void OptionsDialog::loadConnectionTabOptions() connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->checkMaxAltConnectionsPerTorrent, &QWidget::setEnabled); + connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxAltConnecPerTorrent, [this](bool checked) + { + m_ui->spinMaxAltConnecPerTorrent->setEnabled(checked && m_ui->checkMaxAltConnectionsPerTorrent->isChecked()); + }); + connect(m_ui->checkMaxAltConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxAltConnecPerTorrent, &QWidget::setEnabled); + connect(m_ui->checkMaxAltConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, m_ui->spinMaxUploads, &QWidget::setEnabled); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxUploadsPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnec, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); + connect(m_ui->spinMaxAltConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxUploadsPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); @@ -987,6 +1008,7 @@ void OptionsDialog::saveConnectionTabOptions() const session->setMaxConnections(getMaxConnections()); session->setMaxConnectionsPerTorrent(getMaxConnectionsPerTorrent()); + session->setMaxAltConnectionsPerTorrent(getMaxAltConnectionsPerTorrent()); session->setMaxUploads(getMaxUploads()); session->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent()); @@ -1614,6 +1636,14 @@ int OptionsDialog::getMaxConnectionsPerTorrent() const return m_ui->spinMaxConnecPerTorrent->value(); } +int OptionsDialog::getMaxAltConnectionsPerTorrent() const +{ + if (!m_ui->checkMaxAltConnectionsPerTorrent->isChecked()) + return -1; + + return m_ui->spinMaxAltConnecPerTorrent->value(); +} + int OptionsDialog::getMaxUploads() const { if (!m_ui->checkMaxUploads->isChecked()) diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index c1e29c1d6..6d2fc3533 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -166,6 +166,7 @@ private: // Bittorrent options int getMaxConnections() const; int getMaxConnectionsPerTorrent() const; + int getMaxAltConnectionsPerTorrent() const; int getMaxUploads() const; int getMaxUploadsPerTorrent() const; bool isDHTEnabled() const; diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index a0afed167..6daf290e3 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -1933,13 +1933,36 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. + + + Alternative limit for seeding torrents: + + + true + + + + + + + 2 + + + 2000 + + + 40 + + + + Global maximum number of upload slots: - + 2000 @@ -1949,14 +1972,14 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + Maximum number of upload slots per torrent: - + 500 From 0391da3ba1604640d61e928998ee8f3499e51739 Mon Sep 17 00:00:00 2001 From: lstrsrt <79076531+lstrsrt@users.noreply.github.com> Date: Tue, 5 Aug 2025 18:39:58 +0200 Subject: [PATCH 2/6] Improve option UI name and make it not gated --- src/gui/optionsdialog.cpp | 5 ----- src/gui/optionsdialog.ui | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 4c1bf2275..26799d0b2 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -951,11 +951,6 @@ void OptionsDialog::loadConnectionTabOptions() connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); - connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->checkMaxAltConnectionsPerTorrent, &QWidget::setEnabled); - connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxAltConnecPerTorrent, [this](bool checked) - { - m_ui->spinMaxAltConnecPerTorrent->setEnabled(checked && m_ui->checkMaxAltConnectionsPerTorrent->isChecked()); - }); connect(m_ui->checkMaxAltConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxAltConnecPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxAltConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, m_ui->spinMaxUploads, &QWidget::setEnabled); diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index 6daf290e3..6400ebb14 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -1935,7 +1935,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - Alternative limit for seeding torrents: + Maximum number of connections per seeding torrent: true From 2e711bff9f730348ce5c84a01507848bbe4d1d63 Mon Sep 17 00:00:00 2001 From: lstrsrt <79076531+lstrsrt@users.noreply.github.com> Date: Tue, 5 Aug 2025 22:20:29 +0200 Subject: [PATCH 3/6] Rename alt* variables to seed* --- src/base/bittorrent/session.h | 4 ++-- src/base/bittorrent/sessionimpl.cpp | 14 +++++++------- src/base/bittorrent/sessionimpl.h | 6 +++--- src/base/bittorrent/torrentimpl.cpp | 6 +++--- src/gui/optionsdialog.cpp | 24 ++++++++++++------------ src/gui/optionsdialog.h | 2 +- src/gui/optionsdialog.ui | 4 ++-- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index feaba7abc..0e1f520af 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -406,8 +406,8 @@ namespace BitTorrent virtual void setMaxConnections(int max) = 0; virtual int maxConnectionsPerTorrent() const = 0; virtual void setMaxConnectionsPerTorrent(int max) = 0; - virtual int maxAltConnectionsPerTorrent() const = 0; - virtual void setMaxAltConnectionsPerTorrent(int max) = 0; + virtual int maxSeedConnectionsPerTorrent() const = 0; + virtual void setMaxSeedConnectionsPerTorrent(int max) = 0; virtual int maxUploads() const = 0; virtual void setMaxUploads(int max) = 0; virtual int maxUploadsPerTorrent() const = 0; diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 610947ee1..357113320 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -495,7 +495,7 @@ SessionImpl::SessionImpl(QObject *parent) , m_maxConnections(BITTORRENT_SESSION_KEY(u"MaxConnections"_s), 500, lowerLimited(0, -1)) , m_maxUploads(BITTORRENT_SESSION_KEY(u"MaxUploads"_s), 20, lowerLimited(0, -1)) , m_maxConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxConnectionsPerTorrent"_s), 100, lowerLimited(0, -1)) - , m_maxAltConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxAltConnectionsPerTorrent"_s), 40, lowerLimited(0, -1)) + , m_maxSeedConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxSeedConnectionsPerTorrent"_s), 40, lowerLimited(0, -1)) , m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxUploadsPerTorrent"_s), 4, lowerLimited(0, -1)) , m_btProtocol(BITTORRENT_SESSION_KEY(u"BTProtocol"_s), BTProtocol::Both , clampValue(BTProtocol::Both, BTProtocol::UTP)) @@ -4356,9 +4356,9 @@ int SessionImpl::maxConnectionsPerTorrent() const return m_maxConnectionsPerTorrent; } -int SessionImpl::maxAltConnectionsPerTorrent() const +int SessionImpl::maxSeedConnectionsPerTorrent() const { - return m_maxAltConnectionsPerTorrent; + return m_maxSeedConnectionsPerTorrent; } void SessionImpl::setMaxConnectionsPerTorrent(int max) @@ -4372,7 +4372,7 @@ void SessionImpl::setMaxConnectionsPerTorrent(int max) { try { - if (m_maxAltConnectionsPerTorrent == -1 || !torrent->isUploading()) + if (m_maxSeedConnectionsPerTorrent == -1 || !torrent->isUploading()) { torrent->nativeHandle().set_max_connections(max); } @@ -4382,12 +4382,12 @@ void SessionImpl::setMaxConnectionsPerTorrent(int max) } } -void SessionImpl::setMaxAltConnectionsPerTorrent(int max) +void SessionImpl::setMaxSeedConnectionsPerTorrent(int max) { max = (max > 0) ? max : -1; - if (max != maxAltConnectionsPerTorrent()) + if (max != maxSeedConnectionsPerTorrent()) { - m_maxAltConnectionsPerTorrent = max; + m_maxSeedConnectionsPerTorrent = max; for (const TorrentImpl *torrent : asConst(m_torrents)) { diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index a51169cad..7a3d57439 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -380,8 +380,8 @@ namespace BitTorrent void setMaxConnections(int max) override; int maxConnectionsPerTorrent() const override; void setMaxConnectionsPerTorrent(int max) override; - int maxAltConnectionsPerTorrent() const override; - void setMaxAltConnectionsPerTorrent(int max) override; + int maxSeedConnectionsPerTorrent() const override; + void setMaxSeedConnectionsPerTorrent(int max) override; int maxUploads() const override; void setMaxUploads(int max) override; int maxUploadsPerTorrent() const override; @@ -701,7 +701,7 @@ namespace BitTorrent CachedSettingValue m_maxConnections; CachedSettingValue m_maxUploads; CachedSettingValue m_maxConnectionsPerTorrent; - CachedSettingValue m_maxAltConnectionsPerTorrent; + CachedSettingValue m_maxSeedConnectionsPerTorrent; CachedSettingValue m_maxUploadsPerTorrent; CachedSettingValue m_btProtocol; CachedSettingValue m_isUTPRateLimited; diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 46820ff6a..17020a996 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -2605,9 +2605,9 @@ void TorrentImpl::updateProgress() void TorrentImpl::updateMaxConnections() { const int maxConnections = m_session->maxConnectionsPerTorrent(); - const int maxAltConnections = m_session->maxAltConnectionsPerTorrent(); - const bool useAltLimit = (maxAltConnections != -1) && isUploading(); - const int max = useAltLimit ? maxAltConnections : maxConnections; + const int maxSeedConnections = m_session->maxSeedConnectionsPerTorrent(); + const bool useAltLimit = (maxSeedConnections != -1) && isUploading(); + const int max = useAltLimit ? maxSeedConnections : maxConnections; if (nativeHandle().max_connections() == max) return; diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 26799d0b2..d1dc7ad25 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -860,18 +860,18 @@ void OptionsDialog::loadConnectionTabOptions() m_ui->checkMaxConnectionsPerTorrent->setChecked(false); m_ui->spinMaxConnecPerTorrent->setEnabled(false); } - intValue = session->maxAltConnectionsPerTorrent(); + intValue = session->maxSeedConnectionsPerTorrent(); if (intValue > 0) { // enable - m_ui->checkMaxAltConnectionsPerTorrent->setChecked(true); - m_ui->spinMaxAltConnecPerTorrent->setValue(intValue); + m_ui->checkMaxSeedConnectionsPerTorrent->setChecked(true); + m_ui->spinMaxSeedConnecPerTorrent->setValue(intValue); } else { // disable - m_ui->checkMaxAltConnectionsPerTorrent->setChecked(false); - m_ui->spinMaxAltConnecPerTorrent->setEnabled(false); + m_ui->checkMaxSeedConnectionsPerTorrent->setChecked(false); + m_ui->spinMaxSeedConnecPerTorrent->setEnabled(false); } intValue = session->maxUploads(); if (intValue > 0) @@ -951,15 +951,15 @@ void OptionsDialog::loadConnectionTabOptions() connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); - connect(m_ui->checkMaxAltConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxAltConnecPerTorrent, &QWidget::setEnabled); - connect(m_ui->checkMaxAltConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxSeedConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxSeedConnecPerTorrent, &QWidget::setEnabled); + connect(m_ui->checkMaxSeedConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, m_ui->spinMaxUploads, &QWidget::setEnabled); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxUploadsPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnec, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); - connect(m_ui->spinMaxAltConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); + connect(m_ui->spinMaxSeedConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxUploadsPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); @@ -1003,7 +1003,7 @@ void OptionsDialog::saveConnectionTabOptions() const session->setMaxConnections(getMaxConnections()); session->setMaxConnectionsPerTorrent(getMaxConnectionsPerTorrent()); - session->setMaxAltConnectionsPerTorrent(getMaxAltConnectionsPerTorrent()); + session->setMaxSeedConnectionsPerTorrent(getMaxSeedConnectionsPerTorrent()); session->setMaxUploads(getMaxUploads()); session->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent()); @@ -1631,12 +1631,12 @@ int OptionsDialog::getMaxConnectionsPerTorrent() const return m_ui->spinMaxConnecPerTorrent->value(); } -int OptionsDialog::getMaxAltConnectionsPerTorrent() const +int OptionsDialog::getMaxSeedConnectionsPerTorrent() const { - if (!m_ui->checkMaxAltConnectionsPerTorrent->isChecked()) + if (!m_ui->checkMaxSeedConnectionsPerTorrent->isChecked()) return -1; - return m_ui->spinMaxAltConnecPerTorrent->value(); + return m_ui->spinMaxSeedConnecPerTorrent->value(); } int OptionsDialog::getMaxUploads() const diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index 6d2fc3533..27fd8b15c 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -166,7 +166,7 @@ private: // Bittorrent options int getMaxConnections() const; int getMaxConnectionsPerTorrent() const; - int getMaxAltConnectionsPerTorrent() const; + int getMaxSeedConnectionsPerTorrent() const; int getMaxUploads() const; int getMaxUploadsPerTorrent() const; bool isDHTEnabled() const; diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index 6400ebb14..e9f6bcfaa 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -1933,7 +1933,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + Maximum number of connections per seeding torrent: @@ -1943,7 +1943,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + 2 From 28900f3fb6d461880512001d1341259470493900 Mon Sep 17 00:00:00 2001 From: lstrsrt <79076531+lstrsrt@users.noreply.github.com> Date: Wed, 6 Aug 2025 18:37:48 +0200 Subject: [PATCH 4/6] Add WebUI interface --- src/webui/api/appcontroller.cpp | 3 ++ src/webui/www/private/views/preferences.html | 34 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index e2e465acd..4c4322c15 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -230,6 +230,7 @@ void AppController::preferencesAction() // Connections Limits data[u"max_connec"_s] = session->maxConnections(); data[u"max_connec_per_torrent"_s] = session->maxConnectionsPerTorrent(); + data[u"max_seed_connec_per_torrent"_s] = session->maxSeedConnectionsPerTorrent(); data[u"max_uploads"_s] = session->maxUploads(); data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent(); @@ -711,6 +712,8 @@ void AppController::setPreferencesAction() session->setMaxConnections(it.value().toInt()); if (hasKey(u"max_connec_per_torrent"_s)) session->setMaxConnectionsPerTorrent(it.value().toInt()); + if (hasKey(u"max_seed_connec_per_torrent"_s)) + session->setMaxSeedConnectionsPerTorrent(it.value().toInt()); if (hasKey(u"max_uploads"_s)) session->setMaxUploads(it.value().toInt()); if (hasKey(u"max_uploads_per_torrent"_s)) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 198cb5409..5ba8fb8d9 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -441,6 +441,13 @@ + + + + + + + @@ -1772,6 +1779,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD generateRandomPort: generateRandomPort, updateMaxConnecEnabled: updateMaxConnecEnabled, updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled, + updateMaxSeedConnecPerTorrentEnabled: updateMaxSeedConnecPerTorrentEnabled, updateMaxUploadsEnabled: updateMaxUploadsEnabled, updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled, updateI2PSettingsEnabled: updateI2PSettingsEnabled, @@ -1981,6 +1989,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD document.getElementById("maxConnectionsPerTorrentValue").disabled = !isMaxConnecPerTorrentEnabled; }; + const updateMaxSeedConnecPerTorrentEnabled = () => { + const isMaxSeedConnecPerTorrentEnabled = document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked; + document.getElementById("maxSeedConnectionsPerTorrentValue").disabled = !isMaxSeedConnecPerTorrentEnabled; + }; + const updateMaxUploadsEnabled = () => { const isMaxUploadsEnabled = document.getElementById("maxUploadsCheckbox").checked; document.getElementById("max_uploads_value").disabled = !isMaxUploadsEnabled; @@ -2388,6 +2401,17 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD } updateMaxConnecPerTorrentEnabled(); + const maxSeedConnecPerTorrent = Number(pref.max_seed_connec_per_torrent); + if (maxSeedConnecPerTorrent <= 0) { + document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked = false; + document.getElementById("maxSeedConnectionsPerTorrentValue").value = 100; + } + else { + document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked = true; + document.getElementById("maxSeedConnectionsPerTorrentValue").value = maxSeedConnecPerTorrent; + } + updateMaxSeedConnecPerTorrentEnabled(); + const maxUploads = Number(pref.max_uploads); if (maxUploads <= 0) { document.getElementById("maxUploadsCheckbox").checked = false; @@ -2773,6 +2797,16 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD } settings["max_connec_per_torrent"] = maxConnecPerTorrent; + let maxSeedConnecPerTorrent = -1; + if (document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked) { + maxSeedConnecPerTorrent = Number(document.getElementById("maxSeedConnectionsPerTorrentValue").value); + if (Number.isNaN(maxSeedConnecPerTorrent) || (maxSeedConnecPerTorrent <= 0)) { + alert("QBT_TR(Maximum number of seed connections per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); + return; + } + } + settings["max_seed_connec_per_torrent"] = maxSeedConnecPerTorrent; + let maxUploads = -1; if (document.getElementById("maxUploadsCheckbox").checked) { maxUploads = Number(document.getElementById("max_uploads_value").value); From 7ae1a891a8096d43715cbbaa5fb4ea0c6c8477aa Mon Sep 17 00:00:00 2001 From: lstrsrt <79076531+lstrsrt@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:30:02 +0200 Subject: [PATCH 5/6] Second round of renaming --- src/base/bittorrent/session.h | 8 +-- src/base/bittorrent/sessionimpl.cpp | 30 ++++---- src/base/bittorrent/sessionimpl.h | 12 ++-- src/base/bittorrent/torrentimpl.cpp | 8 +-- src/gui/optionsdialog.cpp | 50 ++++++------- src/gui/optionsdialog.h | 4 +- src/gui/optionsdialog.ui | 8 +-- src/webui/api/appcontroller.cpp | 12 ++-- src/webui/www/private/views/preferences.html | 76 ++++++++++---------- 9 files changed, 104 insertions(+), 104 deletions(-) diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 0e1f520af..fcb746154 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -404,10 +404,10 @@ namespace BitTorrent virtual void setStopTrackerTimeout(int value) = 0; virtual int maxConnections() const = 0; virtual void setMaxConnections(int max) = 0; - virtual int maxConnectionsPerTorrent() const = 0; - virtual void setMaxConnectionsPerTorrent(int max) = 0; - virtual int maxSeedConnectionsPerTorrent() const = 0; - virtual void setMaxSeedConnectionsPerTorrent(int max) = 0; + virtual int maxConnectionsPerDownloadingTorrent() const = 0; + virtual void setMaxConnectionsPerDownloadingTorrent(int max) = 0; + virtual int maxConnectionsPerSeedingTorrent() const = 0; + virtual void setMaxConnectionsPerSeedingTorrent(int max) = 0; virtual int maxUploads() const = 0; virtual void setMaxUploads(int max) = 0; virtual int maxUploadsPerTorrent() const = 0; diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 357113320..05b49616d 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -494,8 +494,8 @@ SessionImpl::SessionImpl(QObject *parent) , m_stopTrackerTimeout(BITTORRENT_SESSION_KEY(u"StopTrackerTimeout"_s), 2) , m_maxConnections(BITTORRENT_SESSION_KEY(u"MaxConnections"_s), 500, lowerLimited(0, -1)) , m_maxUploads(BITTORRENT_SESSION_KEY(u"MaxUploads"_s), 20, lowerLimited(0, -1)) - , m_maxConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxConnectionsPerTorrent"_s), 100, lowerLimited(0, -1)) - , m_maxSeedConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxSeedConnectionsPerTorrent"_s), 40, lowerLimited(0, -1)) + , m_maxConnectionsPerDownloadingTorrent(BITTORRENT_SESSION_KEY(u"MaxConnectionsPerDownloadingTorrent"_s), 100, lowerLimited(0, -1)) + , m_maxConnectionsPerSeedingTorrent(BITTORRENT_SESSION_KEY(u"MaxConnectionsPerSeedingTorrent"_s), 40, lowerLimited(0, -1)) , m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxUploadsPerTorrent"_s), 4, lowerLimited(0, -1)) , m_btProtocol(BITTORRENT_SESSION_KEY(u"BTProtocol"_s), BTProtocol::Both , clampValue(BTProtocol::Both, BTProtocol::UTP)) @@ -2982,7 +2982,7 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr p.added_time = std::time(nullptr); // Limits - p.max_connections = maxConnectionsPerTorrent(); + p.max_connections = maxConnectionsPerDownloadingTorrent(); p.max_uploads = maxUploadsPerTorrent(); p.userdata = LTClientData(new ExtensionData); @@ -3180,7 +3180,7 @@ bool SessionImpl::downloadMetadata(const TorrentDescriptor &torrentDescr) p.storage_mode = lt::storage_mode_sparse; // Limits - p.max_connections = maxConnectionsPerTorrent(); + p.max_connections = maxConnectionsPerDownloadingTorrent(); p.max_uploads = maxUploadsPerTorrent(); const auto id = TorrentID::fromInfoHash(infoHash); @@ -4351,28 +4351,28 @@ void SessionImpl::resume() } } -int SessionImpl::maxConnectionsPerTorrent() const +int SessionImpl::maxConnectionsPerDownloadingTorrent() const { - return m_maxConnectionsPerTorrent; + return m_maxConnectionsPerDownloadingTorrent; } -int SessionImpl::maxSeedConnectionsPerTorrent() const +int SessionImpl::maxConnectionsPerSeedingTorrent() const { - return m_maxSeedConnectionsPerTorrent; + return m_maxConnectionsPerSeedingTorrent; } -void SessionImpl::setMaxConnectionsPerTorrent(int max) +void SessionImpl::setMaxConnectionsPerDownloadingTorrent(int max) { max = (max > 0) ? max : -1; - if (max != maxConnectionsPerTorrent()) + if (max != maxConnectionsPerDownloadingTorrent()) { - m_maxConnectionsPerTorrent = max; + m_maxConnectionsPerDownloadingTorrent = max; for (const TorrentImpl *torrent : asConst(m_torrents)) { try { - if (m_maxSeedConnectionsPerTorrent == -1 || !torrent->isUploading()) + if (m_maxConnectionsPerSeedingTorrent == -1 || !torrent->isUploading()) { torrent->nativeHandle().set_max_connections(max); } @@ -4382,12 +4382,12 @@ void SessionImpl::setMaxConnectionsPerTorrent(int max) } } -void SessionImpl::setMaxSeedConnectionsPerTorrent(int max) +void SessionImpl::setMaxConnectionsPerSeedingTorrent(int max) { max = (max > 0) ? max : -1; - if (max != maxSeedConnectionsPerTorrent()) + if (max != maxConnectionsPerSeedingTorrent()) { - m_maxSeedConnectionsPerTorrent = max; + m_maxConnectionsPerSeedingTorrent = max; for (const TorrentImpl *torrent : asConst(m_torrents)) { diff --git a/src/base/bittorrent/sessionimpl.h b/src/base/bittorrent/sessionimpl.h index 7a3d57439..6614626e0 100644 --- a/src/base/bittorrent/sessionimpl.h +++ b/src/base/bittorrent/sessionimpl.h @@ -378,10 +378,10 @@ namespace BitTorrent void setStopTrackerTimeout(int value) override; int maxConnections() const override; void setMaxConnections(int max) override; - int maxConnectionsPerTorrent() const override; - void setMaxConnectionsPerTorrent(int max) override; - int maxSeedConnectionsPerTorrent() const override; - void setMaxSeedConnectionsPerTorrent(int max) override; + int maxConnectionsPerDownloadingTorrent() const override; + void setMaxConnectionsPerDownloadingTorrent(int max) override; + int maxConnectionsPerSeedingTorrent() const override; + void setMaxConnectionsPerSeedingTorrent(int max) override; int maxUploads() const override; void setMaxUploads(int max) override; int maxUploadsPerTorrent() const override; @@ -700,8 +700,8 @@ namespace BitTorrent CachedSettingValue m_stopTrackerTimeout; CachedSettingValue m_maxConnections; CachedSettingValue m_maxUploads; - CachedSettingValue m_maxConnectionsPerTorrent; - CachedSettingValue m_maxSeedConnectionsPerTorrent; + CachedSettingValue m_maxConnectionsPerDownloadingTorrent; + CachedSettingValue m_maxConnectionsPerSeedingTorrent; CachedSettingValue m_maxUploadsPerTorrent; CachedSettingValue m_btProtocol; CachedSettingValue m_isUTPRateLimited; diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 17020a996..5d11423b6 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -2604,10 +2604,10 @@ void TorrentImpl::updateProgress() void TorrentImpl::updateMaxConnections() { - const int maxConnections = m_session->maxConnectionsPerTorrent(); - const int maxSeedConnections = m_session->maxSeedConnectionsPerTorrent(); - const bool useAltLimit = (maxSeedConnections != -1) && isUploading(); - const int max = useAltLimit ? maxSeedConnections : maxConnections; + const int maxDownloadingConnections = m_session->maxConnectionsPerDownloadingTorrent(); + const int maxSeedingConnections = m_session->maxConnectionsPerSeedingTorrent(); + const bool useSeedingLimit = (maxSeedingConnections != -1) && isUploading(); + const int max = useSeedingLimit ? maxSeedingConnections : maxDownloadingConnections; if (nativeHandle().max_connections() == max) return; diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index d1dc7ad25..ce6615dc9 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -846,32 +846,32 @@ void OptionsDialog::loadConnectionTabOptions() m_ui->checkMaxConnections->setChecked(false); m_ui->spinMaxConnec->setEnabled(false); } - intValue = session->maxConnectionsPerTorrent(); + intValue = session->maxConnectionsPerDownloadingTorrent(); if (intValue > 0) { // enable - m_ui->checkMaxConnectionsPerTorrent->setChecked(true); - m_ui->spinMaxConnecPerTorrent->setEnabled(true); - m_ui->spinMaxConnecPerTorrent->setValue(intValue); + m_ui->checkMaxConnectionsPerDownloadingTorrent->setChecked(true); + m_ui->spinMaxConnecPerDownloadingTorrent->setEnabled(true); + m_ui->spinMaxConnecPerDownloadingTorrent->setValue(intValue); } else { // disable - m_ui->checkMaxConnectionsPerTorrent->setChecked(false); - m_ui->spinMaxConnecPerTorrent->setEnabled(false); + m_ui->checkMaxConnectionsPerDownloadingTorrent->setChecked(false); + m_ui->spinMaxConnecPerDownloadingTorrent->setEnabled(false); } - intValue = session->maxSeedConnectionsPerTorrent(); + intValue = session->maxConnectionsPerSeedingTorrent(); if (intValue > 0) { // enable - m_ui->checkMaxSeedConnectionsPerTorrent->setChecked(true); - m_ui->spinMaxSeedConnecPerTorrent->setValue(intValue); + m_ui->checkMaxConnectionsPerSeedingTorrent->setChecked(true); + m_ui->spinMaxConnecPerSeedingTorrent->setValue(intValue); } else { // disable - m_ui->checkMaxSeedConnectionsPerTorrent->setChecked(false); - m_ui->spinMaxSeedConnecPerTorrent->setEnabled(false); + m_ui->checkMaxConnectionsPerSeedingTorrent->setChecked(false); + m_ui->spinMaxConnecPerSeedingTorrent->setEnabled(false); } intValue = session->maxUploads(); if (intValue > 0) @@ -949,17 +949,17 @@ void OptionsDialog::loadConnectionTabOptions() connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, m_ui->spinMaxConnec, &QWidget::setEnabled); connect(m_ui->checkMaxConnections, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); - connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerTorrent, &QWidget::setEnabled); - connect(m_ui->checkMaxConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); - connect(m_ui->checkMaxSeedConnectionsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxSeedConnecPerTorrent, &QWidget::setEnabled); - connect(m_ui->checkMaxSeedConnectionsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxConnectionsPerDownloadingTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerDownloadingTorrent, &QWidget::setEnabled); + connect(m_ui->checkMaxConnectionsPerDownloadingTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); + connect(m_ui->checkMaxConnectionsPerSeedingTorrent, &QAbstractButton::toggled, m_ui->spinMaxConnecPerSeedingTorrent, &QWidget::setEnabled); + connect(m_ui->checkMaxConnectionsPerSeedingTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, m_ui->spinMaxUploads, &QWidget::setEnabled); connect(m_ui->checkMaxUploads, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, m_ui->spinMaxUploadsPerTorrent, &QWidget::setEnabled); connect(m_ui->checkMaxUploadsPerTorrent, &QAbstractButton::toggled, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxConnec, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); - connect(m_ui->spinMaxConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); - connect(m_ui->spinMaxSeedConnecPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); + connect(m_ui->spinMaxConnecPerDownloadingTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); + connect(m_ui->spinMaxConnecPerSeedingTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxUploads, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); connect(m_ui->spinMaxUploadsPerTorrent, qSpinBoxValueChanged, this, &ThisType::enableApplyButton); @@ -1002,8 +1002,8 @@ void OptionsDialog::saveConnectionTabOptions() const Net::PortForwarder::instance()->setEnabled(isUPnPEnabled()); session->setMaxConnections(getMaxConnections()); - session->setMaxConnectionsPerTorrent(getMaxConnectionsPerTorrent()); - session->setMaxSeedConnectionsPerTorrent(getMaxSeedConnectionsPerTorrent()); + session->setMaxConnectionsPerDownloadingTorrent(getMaxConnectionsPerDownloadingTorrent()); + session->setMaxConnectionsPerSeedingTorrent(getMaxConnectionsPerSeedingTorrent()); session->setMaxUploads(getMaxUploads()); session->setMaxUploadsPerTorrent(getMaxUploadsPerTorrent()); @@ -1623,20 +1623,20 @@ int OptionsDialog::getMaxConnections() const return m_ui->spinMaxConnec->value(); } -int OptionsDialog::getMaxConnectionsPerTorrent() const +int OptionsDialog::getMaxConnectionsPerDownloadingTorrent() const { - if (!m_ui->checkMaxConnectionsPerTorrent->isChecked()) + if (!m_ui->checkMaxConnectionsPerDownloadingTorrent->isChecked()) return -1; - return m_ui->spinMaxConnecPerTorrent->value(); + return m_ui->spinMaxConnecPerDownloadingTorrent->value(); } -int OptionsDialog::getMaxSeedConnectionsPerTorrent() const +int OptionsDialog::getMaxConnectionsPerSeedingTorrent() const { - if (!m_ui->checkMaxSeedConnectionsPerTorrent->isChecked()) + if (!m_ui->checkMaxConnectionsPerSeedingTorrent->isChecked()) return -1; - return m_ui->spinMaxSeedConnecPerTorrent->value(); + return m_ui->spinMaxConnecPerSeedingTorrent->value(); } int OptionsDialog::getMaxUploads() const diff --git a/src/gui/optionsdialog.h b/src/gui/optionsdialog.h index 27fd8b15c..aad00a2c6 100644 --- a/src/gui/optionsdialog.h +++ b/src/gui/optionsdialog.h @@ -165,8 +165,8 @@ private: bool isUPnPEnabled() const; // Bittorrent options int getMaxConnections() const; - int getMaxConnectionsPerTorrent() const; - int getMaxSeedConnectionsPerTorrent() const; + int getMaxConnectionsPerDownloadingTorrent() const; + int getMaxConnectionsPerSeedingTorrent() const; int getMaxUploads() const; int getMaxUploadsPerTorrent() const; bool isDHTEnabled() const; diff --git a/src/gui/optionsdialog.ui b/src/gui/optionsdialog.ui index e9f6bcfaa..bac3857b1 100644 --- a/src/gui/optionsdialog.ui +++ b/src/gui/optionsdialog.ui @@ -1910,7 +1910,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + Maximum number of connections per torrent: @@ -1920,7 +1920,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + 2 @@ -1933,7 +1933,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + Maximum number of connections per seeding torrent: @@ -1943,7 +1943,7 @@ readme[0-9].txt: filter 'readme1.txt', 'readme2.txt' but not 'readme10.txt'. - + 2 diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 4c4322c15..4228452d3 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -229,8 +229,8 @@ void AppController::preferencesAction() data[u"upnp"_s] = Net::PortForwarder::instance()->isEnabled(); // Connections Limits data[u"max_connec"_s] = session->maxConnections(); - data[u"max_connec_per_torrent"_s] = session->maxConnectionsPerTorrent(); - data[u"max_seed_connec_per_torrent"_s] = session->maxSeedConnectionsPerTorrent(); + data[u"max_connec_per_downloading_torrent"_s] = session->maxConnectionsPerDownloadingTorrent(); + data[u"max_connec_per_seeding_torrent"_s] = session->maxConnectionsPerSeedingTorrent(); data[u"max_uploads"_s] = session->maxUploads(); data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent(); @@ -710,10 +710,10 @@ void AppController::setPreferencesAction() // Connections Limits if (hasKey(u"max_connec"_s)) session->setMaxConnections(it.value().toInt()); - if (hasKey(u"max_connec_per_torrent"_s)) - session->setMaxConnectionsPerTorrent(it.value().toInt()); - if (hasKey(u"max_seed_connec_per_torrent"_s)) - session->setMaxSeedConnectionsPerTorrent(it.value().toInt()); + if (hasKey(u"max_connec_per_downloading_torrent"_s)) + session->setMaxConnectionsPerDownloadingTorrent(it.value().toInt()); + if (hasKey(u"max_connec_per_seeding_torrent"_s)) + session->setMaxConnectionsPerSeedingTorrent(it.value().toInt()); if (hasKey(u"max_uploads"_s)) session->setMaxUploads(it.value().toInt()); if (hasKey(u"max_uploads_per_torrent"_s)) diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html index 5ba8fb8d9..4d2295d95 100644 --- a/src/webui/www/private/views/preferences.html +++ b/src/webui/www/private/views/preferences.html @@ -436,17 +436,17 @@ - - + + - + - - + + - + @@ -1778,8 +1778,8 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD updateAutoRunOnTorrentAdded: updateAutoRunOnTorrentAdded, generateRandomPort: generateRandomPort, updateMaxConnecEnabled: updateMaxConnecEnabled, - updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled, - updateMaxSeedConnecPerTorrentEnabled: updateMaxSeedConnecPerTorrentEnabled, + updateMaxConnecPerDownloadingTorrentEnabled: updateMaxConnecPerDownloadingTorrentEnabled, + updateMaxConnecPerSeedingTorrentEnabled: updateMaxConnecPerSeedingTorrentEnabled, updateMaxUploadsEnabled: updateMaxUploadsEnabled, updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled, updateI2PSettingsEnabled: updateI2PSettingsEnabled, @@ -1984,14 +1984,14 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD document.getElementById("maxConnectionsValue").disabled = !isMaxConnecEnabled; }; - const updateMaxConnecPerTorrentEnabled = () => { - const isMaxConnecPerTorrentEnabled = document.getElementById("maxConnectionsPerTorrentCheckbox").checked; - document.getElementById("maxConnectionsPerTorrentValue").disabled = !isMaxConnecPerTorrentEnabled; + const updateMaxConnecPerDownloadingTorrentEnabled = () => { + const isMaxConnecPerDownloadingTorrentEnabled = document.getElementById("maxConnectionsPerDownloadingTorrentCheckbox").checked; + document.getElementById("maxConnectionsPerDownloadingTorrentValue").disabled = !isMaxConnecPerDownloadingTorrentEnabled; }; - const updateMaxSeedConnecPerTorrentEnabled = () => { - const isMaxSeedConnecPerTorrentEnabled = document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked; - document.getElementById("maxSeedConnectionsPerTorrentValue").disabled = !isMaxSeedConnecPerTorrentEnabled; + const updateMaxConnecPerSeedingTorrentEnabled = () => { + const isMaxConnecPerSeedingTorrentEnabled = document.getElementById("maxConnectionsPerSeedingTorrentCheckbox").checked; + document.getElementById("maxConnectionsPerSeedingTorrentValue").disabled = !isMaxConnecPerSeedingTorrentEnabled; }; const updateMaxUploadsEnabled = () => { @@ -2390,27 +2390,27 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD } updateMaxConnecEnabled(); - const maxConnecPerTorrent = Number(pref.max_connec_per_torrent); - if (maxConnecPerTorrent <= 0) { - document.getElementById("maxConnectionsPerTorrentCheckbox").checked = false; - document.getElementById("maxConnectionsPerTorrentValue").value = 100; + const maxConnecPerDownloadingTorrent = Number(pref.max_connec_per_downloading_torrent); + if (maxConnecPerDownloadingTorrent <= 0) { + document.getElementById("maxConnectionsPerDownloadingTorrentCheckbox").checked = false; + document.getElementById("maxConnectionsPerDownloadingTorrentValue").value = 100; } else { - document.getElementById("maxConnectionsPerTorrentCheckbox").checked = true; - document.getElementById("maxConnectionsPerTorrentValue").value = maxConnecPerTorrent; + document.getElementById("maxConnectionsPerDownloadingTorrentCheckbox").checked = true; + document.getElementById("maxConnectionsPerDownloadingTorrentValue").value = maxConnecPerDownloadingTorrent; } - updateMaxConnecPerTorrentEnabled(); + updateMaxConnecPerDownloadingTorrentEnabled(); - const maxSeedConnecPerTorrent = Number(pref.max_seed_connec_per_torrent); - if (maxSeedConnecPerTorrent <= 0) { - document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked = false; - document.getElementById("maxSeedConnectionsPerTorrentValue").value = 100; + const maxConnecPerSeedingTorrent = Number(pref.max_connec_per_seeding_torrent); + if (maxConnecPerSeedingTorrent <= 0) { + document.getElementById("maxConnectionsPerSeedingTorrentCheckbox").checked = false; + document.getElementById("maxConnectionsPerSeedingTorrentValue").value = 100; } else { - document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked = true; - document.getElementById("maxSeedConnectionsPerTorrentValue").value = maxSeedConnecPerTorrent; + document.getElementById("maxConnectionsPerSeedingTorrentCheckbox").checked = true; + document.getElementById("maxConnectionsPerSeedingTorrentValue").value = maxConnecPerSeedingTorrent; } - updateMaxSeedConnecPerTorrentEnabled(); + updateMaxConnecPerSeedingTorrentEnabled(); const maxUploads = Number(pref.max_uploads); if (maxUploads <= 0) { @@ -2787,25 +2787,25 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD } settings["max_connec"] = maxConnec; - let maxConnecPerTorrent = -1; - if (document.getElementById("maxConnectionsPerTorrentCheckbox").checked) { - maxConnecPerTorrent = Number(document.getElementById("maxConnectionsPerTorrentValue").value); - if (Number.isNaN(maxConnecPerTorrent) || (maxConnecPerTorrent <= 0)) { + let maxConnecPerDownloadingTorrent = -1; + if (document.getElementById("maxConnectionsPerDownloadingTorrentCheckbox").checked) { + maxConnecPerDownloadingTorrent = Number(document.getElementById("maxConnectionsPerDownloadingTorrentValue").value); + if (Number.isNaN(maxConnecPerDownloadingTorrent) || (maxConnecPerDownloadingTorrent <= 0)) { alert("QBT_TR(Maximum number of connections per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); return; } } - settings["max_connec_per_torrent"] = maxConnecPerTorrent; + settings["max_connec_per_downloading_torrent"] = maxConnecPerDownloadingTorrent; - let maxSeedConnecPerTorrent = -1; - if (document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked) { - maxSeedConnecPerTorrent = Number(document.getElementById("maxSeedConnectionsPerTorrentValue").value); - if (Number.isNaN(maxSeedConnecPerTorrent) || (maxSeedConnecPerTorrent <= 0)) { + let maxConnecPerSeedingTorrent = -1; + if (document.getElementById("maxConnectionsPerSeedingTorrentCheckbox").checked) { + maxConnecPerSeedingTorrent = Number(document.getElementById("maxConnectionsPerSeedingTorrentValue").value); + if (Number.isNaN(maxConnecPerSeedingTorrent) || (maxConnecPerSeedingTorrent <= 0)) { alert("QBT_TR(Maximum number of seed connections per torrent limit must be greater than 0 or disabled.)QBT_TR[CONTEXT=HttpServer]"); return; } } - settings["max_seed_connec_per_torrent"] = maxSeedConnecPerTorrent; + settings["max_connec_per_seeding_torrent"] = maxConnecPerSeedingTorrent; let maxUploads = -1; if (document.getElementById("maxUploadsCheckbox").checked) { From 25b84e3414903fdf11f0311561fff3e92ac89f61 Mon Sep 17 00:00:00 2001 From: lstrsrt <79076531+lstrsrt@users.noreply.github.com> Date: Wed, 6 Aug 2025 20:59:42 +0200 Subject: [PATCH 6/6] Update DB --- src/app/upgrade.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/upgrade.cpp b/src/app/upgrade.cpp index 5a9d9b896..ee10916be 100644 --- a/src/app/upgrade.cpp +++ b/src/app/upgrade.cpp @@ -46,7 +46,7 @@ namespace { - const int MIGRATION_VERSION = 8; + const int MIGRATION_VERSION = 9; const QString MIGRATION_VERSION_KEY = u"Meta/MigrationVersion"_s; void exportWebUIHttpsFiles() @@ -283,7 +283,8 @@ namespace {u"BitTorrent/Session/MaxActiveTorrents"_s, u"Preferences/Queueing/MaxActiveTorrents"_s}, {u"BitTorrent/Session/MaxActiveUploads"_s, u"Preferences/Queueing/MaxActiveUploads"_s}, {u"BitTorrent/Session/MaxConnections"_s, u"Preferences/Bittorrent/MaxConnecs"_s}, - {u"BitTorrent/Session/MaxConnectionsPerTorrent"_s, u"Preferences/Bittorrent/MaxConnecsPerTorrent"_s}, + {u"BitTorrent/Session/MaxConnectionsPerDownloadingTorrent"_s, u"Preferences/Bittorrent/MaxConnecsPerTorrent"_s}, + {u"BitTorrent/Session/MaxConnectionsPerDownloadingTorrent"_s, u"BitTorrent/Session/MaxConnectionsPerTorrent"_s}, {u"BitTorrent/Session/MaxHalfOpenConnections"_s, u"Preferences/Connection/MaxHalfOpenConnec"_s}, {u"BitTorrent/Session/MaxRatioAction"_s, u"Preferences/Bittorrent/MaxRatioAction"_s}, {u"BitTorrent/Session/MaxUploads"_s, u"Preferences/Bittorrent/MaxUploads"_s},