Browse Source

Merge pull request #3040 from ngosang/webui_global_slot

Web UI: New config - Global maximum number of upload slots. Closes #2997
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
736f20538d
  1. 3
      src/webui/prefjson.cpp
  2. 34
      src/webui/www/public/preferences_content.html

3
src/webui/prefjson.cpp

@ -92,6 +92,7 @@ QByteArray prefjson::getPreferences()
data["up_limit"] = pref->getGlobalUploadLimit(); data["up_limit"] = pref->getGlobalUploadLimit();
data["max_connec"] = pref->getMaxConnecs(); data["max_connec"] = pref->getMaxConnecs();
data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent(); data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent();
data["max_uploads"] = pref->getMaxUploads();
data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent(); data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent();
data["enable_utp"] = pref->isuTPEnabled(); data["enable_utp"] = pref->isuTPEnabled();
data["limit_utp_rate"] = pref->isuTPRateLimited(); data["limit_utp_rate"] = pref->isuTPRateLimited();
@ -243,6 +244,8 @@ void prefjson::setPreferences(const QString& json)
pref->setMaxConnecs(m["max_connec"].toInt()); pref->setMaxConnecs(m["max_connec"].toInt());
if (m.contains("max_connec_per_torrent")) if (m.contains("max_connec_per_torrent"))
pref->setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt()); pref->setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
if (m.contains("max_uploads"))
pref->setMaxUploads(m["max_uploads"].toInt());
if (m.contains("max_uploads_per_torrent")) if (m.contains("max_uploads_per_torrent"))
pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt()); pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
if (m.contains("enable_utp")) if (m.contains("enable_utp"))

34
src/webui/www/public/preferences_content.html

@ -24,6 +24,13 @@
<td><input type="text" id="max_connec_per_torrent_value" style="width: 4em;"/></td> <td><input type="text" id="max_connec_per_torrent_value" style="width: 4em;"/></td>
</tr> </tr>
<tr> <tr>
<td>
<input type="checkbox" id="max_uploads_checkbox" onClick="updateMaxUploadsEnabled();"/>
<label for="max_uploads_checkbox">QBT_TR(Global maximum number of upload slots:)QBT_TR</label>
</td>
<td><input type="text" id="max_uploads_value" style="width: 4em;"/></td>
</tr>
<tr>
<td> <td>
<input type="checkbox" id="max_uploads_per_torrent_checkbox" onClick="updateMaxUploadsPerTorrentEnabled();"/> <input type="checkbox" id="max_uploads_per_torrent_checkbox" onClick="updateMaxUploadsPerTorrentEnabled();"/>
<label for="max_uploads_per_torrent_checkbox">QBT_TR(Maximum number of upload slots per torrent:)QBT_TR</label> <label for="max_uploads_per_torrent_checkbox">QBT_TR(Maximum number of upload slots per torrent:)QBT_TR</label>
@ -445,6 +452,14 @@ updateMaxConnecPerTorrentEnabled = function() {
} }
} }
updateMaxUploadsEnabled = function() {
if($('max_uploads_checkbox').getProperty('checked')) {
$('max_uploads_value').setProperty('disabled', false);
} else {
$('max_uploads_value').setProperty('disabled', true);
}
}
updateMaxUploadsPerTorrentEnabled = function() { updateMaxUploadsPerTorrentEnabled = function() {
if($('max_uploads_per_torrent_checkbox').getProperty('checked')) { if($('max_uploads_per_torrent_checkbox').getProperty('checked')) {
$('max_uploads_per_torrent_value').setProperty('disabled', false); $('max_uploads_per_torrent_value').setProperty('disabled', false);
@ -707,6 +722,15 @@ loadPreferences = function() {
$('max_connec_per_torrent_value').setProperty('value', max_connec_per_torrent); $('max_connec_per_torrent_value').setProperty('value', max_connec_per_torrent);
} }
updateMaxConnecPerTorrentEnabled(); updateMaxConnecPerTorrentEnabled();
var max_uploads = pref.max_uploads.toInt();
if(max_uploads <= 0) {
$('max_uploads_checkbox').setProperty('checked', false);
$('max_uploads_value').setProperty('value', 8);
} else {
$('max_uploads_checkbox').setProperty('checked', true);
$('max_uploads_value').setProperty('value', max_uploads);
}
updateMaxUploadsEnabled();
var max_uploads_per_torrent = pref.max_uploads_per_torrent.toInt(); var max_uploads_per_torrent = pref.max_uploads_per_torrent.toInt();
if(max_uploads_per_torrent <= 0) { if(max_uploads_per_torrent <= 0) {
$('max_uploads_per_torrent_checkbox').setProperty('checked', false); $('max_uploads_per_torrent_checkbox').setProperty('checked', false);
@ -888,6 +912,16 @@ applyPreferences = function() {
} }
settings.set('max_connec_per_torrent', max_connec_per_torrent); settings.set('max_connec_per_torrent', max_connec_per_torrent);
var max_uploads = -1;
if($('max_uploads_checkbox').getProperty('checked')) {
max_uploads = $('max_uploads_value').getProperty('value').toInt();
if(max_uploads <= 0) {
alert("QBT_TR(Global number of upload slots limit must be greater than 0 or disabled.)QBT_TR");
return;
}
}
settings.set('max_uploads', max_uploads);
var max_uploads_per_torrent = -1; var max_uploads_per_torrent = -1;
if($('max_uploads_per_torrent_checkbox').getProperty('checked')) { if($('max_uploads_per_torrent_checkbox').getProperty('checked')) {
max_uploads_per_torrent = $('max_uploads_per_torrent_value').getProperty('value').toInt(); max_uploads_per_torrent = $('max_uploads_per_torrent_value').getProperty('value').toInt();

Loading…
Cancel
Save