mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 22:03:27 -07:00
Add WebUI interface
This commit is contained in:
parent
2e711bff9f
commit
28900f3fb6
2 changed files with 37 additions and 0 deletions
|
@ -230,6 +230,7 @@ void AppController::preferencesAction()
|
||||||
// Connections Limits
|
// Connections Limits
|
||||||
data[u"max_connec"_s] = session->maxConnections();
|
data[u"max_connec"_s] = session->maxConnections();
|
||||||
data[u"max_connec_per_torrent"_s] = session->maxConnectionsPerTorrent();
|
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"_s] = session->maxUploads();
|
||||||
data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent();
|
data[u"max_uploads_per_torrent"_s] = session->maxUploadsPerTorrent();
|
||||||
|
|
||||||
|
@ -711,6 +712,8 @@ void AppController::setPreferencesAction()
|
||||||
session->setMaxConnections(it.value().toInt());
|
session->setMaxConnections(it.value().toInt());
|
||||||
if (hasKey(u"max_connec_per_torrent"_s))
|
if (hasKey(u"max_connec_per_torrent"_s))
|
||||||
session->setMaxConnectionsPerTorrent(it.value().toInt());
|
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))
|
if (hasKey(u"max_uploads"_s))
|
||||||
session->setMaxUploads(it.value().toInt());
|
session->setMaxUploads(it.value().toInt());
|
||||||
if (hasKey(u"max_uploads_per_torrent"_s))
|
if (hasKey(u"max_uploads_per_torrent"_s))
|
||||||
|
|
|
@ -441,6 +441,13 @@
|
||||||
</td>
|
</td>
|
||||||
<td><input type="text" id="maxConnectionsPerTorrentValue" aria-labelledby="maxConnectionsPerTorrentLabel" style="width: 6em;"></td>
|
<td><input type="text" id="maxConnectionsPerTorrentValue" aria-labelledby="maxConnectionsPerTorrentLabel" style="width: 6em;"></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" id="maxSeedConnectionsPerTorrentCheckbox" onclick="qBittorrent.Preferences.updateMaxSeedConnecPerTorrentEnabled();">
|
||||||
|
<label id="maxSeedConnectionsPerTorrentLabel" for="maxSeedConnectionsPerTorrentCheckbox">QBT_TR(Maximum number of connections per seeding torrent:)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||||
|
</td>
|
||||||
|
<td><input type="text" id="maxSeedConnectionsPerTorrentValue" aria-labelledby="maxSeedConnectionsPerTorrentLabel" style="width: 6em;"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" id="maxUploadsCheckbox" onclick="qBittorrent.Preferences.updateMaxUploadsEnabled();">
|
<input type="checkbox" id="maxUploadsCheckbox" onclick="qBittorrent.Preferences.updateMaxUploadsEnabled();">
|
||||||
|
@ -1772,6 +1779,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
generateRandomPort: generateRandomPort,
|
generateRandomPort: generateRandomPort,
|
||||||
updateMaxConnecEnabled: updateMaxConnecEnabled,
|
updateMaxConnecEnabled: updateMaxConnecEnabled,
|
||||||
updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled,
|
updateMaxConnecPerTorrentEnabled: updateMaxConnecPerTorrentEnabled,
|
||||||
|
updateMaxSeedConnecPerTorrentEnabled: updateMaxSeedConnecPerTorrentEnabled,
|
||||||
updateMaxUploadsEnabled: updateMaxUploadsEnabled,
|
updateMaxUploadsEnabled: updateMaxUploadsEnabled,
|
||||||
updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled,
|
updateMaxUploadsPerTorrentEnabled: updateMaxUploadsPerTorrentEnabled,
|
||||||
updateI2PSettingsEnabled: updateI2PSettingsEnabled,
|
updateI2PSettingsEnabled: updateI2PSettingsEnabled,
|
||||||
|
@ -1981,6 +1989,11 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
document.getElementById("maxConnectionsPerTorrentValue").disabled = !isMaxConnecPerTorrentEnabled;
|
document.getElementById("maxConnectionsPerTorrentValue").disabled = !isMaxConnecPerTorrentEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateMaxSeedConnecPerTorrentEnabled = () => {
|
||||||
|
const isMaxSeedConnecPerTorrentEnabled = document.getElementById("maxSeedConnectionsPerTorrentCheckbox").checked;
|
||||||
|
document.getElementById("maxSeedConnectionsPerTorrentValue").disabled = !isMaxSeedConnecPerTorrentEnabled;
|
||||||
|
};
|
||||||
|
|
||||||
const updateMaxUploadsEnabled = () => {
|
const updateMaxUploadsEnabled = () => {
|
||||||
const isMaxUploadsEnabled = document.getElementById("maxUploadsCheckbox").checked;
|
const isMaxUploadsEnabled = document.getElementById("maxUploadsCheckbox").checked;
|
||||||
document.getElementById("max_uploads_value").disabled = !isMaxUploadsEnabled;
|
document.getElementById("max_uploads_value").disabled = !isMaxUploadsEnabled;
|
||||||
|
@ -2388,6 +2401,17 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
||||||
}
|
}
|
||||||
updateMaxConnecPerTorrentEnabled();
|
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);
|
const maxUploads = Number(pref.max_uploads);
|
||||||
if (maxUploads <= 0) {
|
if (maxUploads <= 0) {
|
||||||
document.getElementById("maxUploadsCheckbox").checked = false;
|
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;
|
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;
|
let maxUploads = -1;
|
||||||
if (document.getElementById("maxUploadsCheckbox").checked) {
|
if (document.getElementById("maxUploadsCheckbox").checked) {
|
||||||
maxUploads = Number(document.getElementById("max_uploads_value").value);
|
maxUploads = Number(document.getElementById("max_uploads_value").value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue