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] 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);