diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 1eb5c4fd0..bc3539035 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -188,6 +188,9 @@ void AppController::preferencesAction() data["max_active_torrents"] = session->maxActiveTorrents(); data["max_active_uploads"] = session->maxActiveUploads(); data["dont_count_slow_torrents"] = session->ignoreSlowTorrentsForQueueing(); + data["slow_torrent_dl_rate_threshold"] = session->downloadRateForSlowTorrents(); + data["slow_torrent_ul_rate_threshold"] = session->uploadRateForSlowTorrents(); + data["slow_torrent_inactive_timer"] = session->slowTorrentsInactivityTimer(); // Share Ratio Limiting data["max_ratio_enabled"] = (session->globalMaxRatio() >= 0.); data["max_ratio"] = session->globalMaxRatio(); @@ -450,6 +453,12 @@ void AppController::setPreferencesAction() session->setMaxActiveUploads(m["max_active_uploads"].toInt()); if (m.contains("dont_count_slow_torrents")) session->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool()); + if ((it = m.find(QLatin1String("slow_torrent_dl_rate_threshold"))) != m.constEnd()) + session->setDownloadRateForSlowTorrents(it.value().toInt()); + if ((it = m.find(QLatin1String("slow_torrent_ul_rate_threshold"))) != m.constEnd()) + session->setUploadRateForSlowTorrents(it.value().toInt()); + if ((it = m.find(QLatin1String("slow_torrent_inactive_timer"))) != m.constEnd()) + session->setSlowTorrentsInactivityTimer(it.value().toInt()); // Share Ratio Limiting if (m.contains("max_ratio_enabled")) { if (m["max_ratio_enabled"].toBool()) diff --git a/src/webui/www/private/preferences_content.html b/src/webui/www/private/preferences_content.html index 6bcd0378d..cfedc1b48 100644 --- a/src/webui/www/private/preferences_content.html +++ b/src/webui/www/private/preferences_content.html @@ -521,10 +521,38 @@ -
- - -
+
+ + + + + + + + + + + + + + + + + +
+ + +   QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog] +
+ + +   QBT_TR(KiB/s)QBT_TR[CONTEXT=OptionsDialog] +
+ + +   QBT_TR(seconds)QBT_TR[CONTEXT=OptionsDialog] +
+
@@ -985,6 +1013,14 @@ $('max_active_up_value').setProperty('disabled', !isQueueingEnabled); $('max_active_to_value').setProperty('disabled', !isQueueingEnabled); $('dont_count_slow_torrents_checkbox').setProperty('disabled', !isQueueingEnabled); + updateSlowTorrentsSettings(); + }; + + updateSlowTorrentsSettings = function() { + var isDontCountSlowTorrentsEnabled = (!$('dont_count_slow_torrents_checkbox').getProperty('disabled')) && $('dont_count_slow_torrents_checkbox').getProperty('checked'); + $('dl_rate_threshold').setProperty('disabled', !isDontCountSlowTorrentsEnabled); + $('ul_rate_threshold').setProperty('disabled', !isDontCountSlowTorrentsEnabled); + $('torrent_inactive_timer').setProperty('disabled', !isDontCountSlowTorrentsEnabled); }; updateMaxRatioTimeEnabled = function() { @@ -1255,6 +1291,9 @@ $('max_active_up_value').setProperty('value', pref.max_active_uploads.toInt()); $('max_active_to_value').setProperty('value', pref.max_active_torrents.toInt()); $('dont_count_slow_torrents_checkbox').setProperty('checked', pref.dont_count_slow_torrents); + $('dl_rate_threshold').setProperty('value', pref.slow_torrent_dl_rate_threshold.toInt()); + $('ul_rate_threshold').setProperty('value', pref.slow_torrent_ul_rate_threshold.toInt()); + $('torrent_inactive_timer').setProperty('value', pref.slow_torrent_inactive_timer.toInt()); updateQueueingSystem(); // Share Limiting @@ -1540,6 +1579,24 @@ } settings.set('max_active_torrents', max_active_torrents); settings.set('dont_count_slow_torrents', $('dont_count_slow_torrents_checkbox').getProperty('checked')); + var dl_rate_threshold = $('dl_rate_threshold').getProperty('value').toInt(); + if (isNaN(dl_rate_threshold) || (dl_rate_threshold < 1)) { + alert("QBT_TR(Download rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]"); + return; + } + settings.set('slow_torrent_dl_rate_threshold', dl_rate_threshold); + var ul_rate_threshold = $('ul_rate_threshold').getProperty('value').toInt(); + if (isNaN(ul_rate_threshold) || (ul_rate_threshold < 1)) { + alert("QBT_TR(Upload rate threshold must be greater than 0.)QBT_TR[CONTEXT=HttpServer]"); + return; + } + settings.set('slow_torrent_ul_rate_threshold', ul_rate_threshold); + var torrent_inactive_timer = $('torrent_inactive_timer').getProperty('value').toInt(); + if (isNaN(torrent_inactive_timer) || (torrent_inactive_timer < 1)) { + alert("QBT_TR(Torrent inactivity timer must be greater than 0.)QBT_TR[CONTEXT=HttpServer]"); + return; + } + settings.set('slow_torrent_inactive_timer', torrent_inactive_timer); } // Share Ratio Limiting