From 2e05777dc57c8b656509510e621157ce6ae8bdc4 Mon Sep 17 00:00:00 2001 From: ngosang Date: Sun, 17 May 2015 14:40:34 +0200 Subject: [PATCH] Web UI: New config - Global maximum number of upload slots --- src/webui/prefjson.cpp | 3 ++ src/webui/www/public/preferences_content.html | 34 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/webui/prefjson.cpp b/src/webui/prefjson.cpp index 61e52a3a2..e5e0709a3 100644 --- a/src/webui/prefjson.cpp +++ b/src/webui/prefjson.cpp @@ -92,6 +92,7 @@ QByteArray prefjson::getPreferences() data["up_limit"] = pref->getGlobalUploadLimit(); data["max_connec"] = pref->getMaxConnecs(); data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent(); + data["max_uploads"] = pref->getMaxUploads(); data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent(); data["enable_utp"] = pref->isuTPEnabled(); data["limit_utp_rate"] = pref->isuTPRateLimited(); @@ -243,6 +244,8 @@ void prefjson::setPreferences(const QString& json) pref->setMaxConnecs(m["max_connec"].toInt()); if (m.contains("max_connec_per_torrent")) 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")) pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt()); if (m.contains("enable_utp")) diff --git a/src/webui/www/public/preferences_content.html b/src/webui/www/public/preferences_content.html index b61b41cfd..13cbbd4d4 100644 --- a/src/webui/www/public/preferences_content.html +++ b/src/webui/www/public/preferences_content.html @@ -24,6 +24,13 @@ + + + + + + + @@ -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() { if($('max_uploads_per_torrent_checkbox').getProperty('checked')) { $('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); } 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(); if(max_uploads_per_torrent <= 0) { $('max_uploads_per_torrent_checkbox').setProperty('checked', false); @@ -888,6 +912,16 @@ applyPreferences = function() { } 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; if($('max_uploads_per_torrent_checkbox').getProperty('checked')) { max_uploads_per_torrent = $('max_uploads_per_torrent_value').getProperty('value').toInt();