mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 22:47:21 -06:00
WebUI: Allow to control the alternative speed limits
setGlobalDownloadLimit and setGlobalUploadLimit will now modify the alternative speed limits if they are currently enabled and the regular speed limits otherwise. Add also two new commands to toggle the state of the alternative speed limits and get their current state. Closes #2203.
This commit is contained in:
@@ -100,6 +100,8 @@ QMap<QString, QMap<QString, RequestHandler::Action> > RequestHandler::initialize
|
||||
ADD_ACTION(command, getTorrentDlLimit);
|
||||
ADD_ACTION(command, setTorrentUpLimit);
|
||||
ADD_ACTION(command, setTorrentDlLimit);
|
||||
ADD_ACTION(command, alternativeSpeedLimitsEnabled);
|
||||
ADD_ACTION(command, toggleAlternativeSpeedLimits);
|
||||
ADD_ACTION(command, toggleSequentialDownload);
|
||||
ADD_ACTION(command, toggleFirstLastPiecePrio);
|
||||
ADD_ACTION(command, delete);
|
||||
@@ -376,7 +378,10 @@ void RequestHandler::action_command_setGlobalUpLimit()
|
||||
if (limit == 0) limit = -1;
|
||||
|
||||
QBtSession::instance()->setUploadRateLimit(limit);
|
||||
Preferences::instance()->setGlobalUploadLimit(limit / 1024.);
|
||||
if (Preferences::instance()->isAltBandwidthEnabled())
|
||||
Preferences::instance()->setAltGlobalUploadLimit(limit / 1024.);
|
||||
else
|
||||
Preferences::instance()->setGlobalUploadLimit(limit / 1024.);
|
||||
}
|
||||
|
||||
void RequestHandler::action_command_setGlobalDlLimit()
|
||||
@@ -385,7 +390,10 @@ void RequestHandler::action_command_setGlobalDlLimit()
|
||||
if (limit == 0) limit = -1;
|
||||
|
||||
QBtSession::instance()->setDownloadRateLimit(limit);
|
||||
Preferences::instance()->setGlobalDownloadLimit(limit / 1024.);
|
||||
if (Preferences::instance()->isAltBandwidthEnabled())
|
||||
Preferences::instance()->setAltGlobalDownloadLimit(limit / 1024.);
|
||||
else
|
||||
Preferences::instance()->setGlobalDownloadLimit(limit / 1024.);
|
||||
}
|
||||
|
||||
void RequestHandler::action_command_getTorrentUpLimit()
|
||||
@@ -428,6 +436,16 @@ void RequestHandler::action_command_setTorrentDlLimit()
|
||||
h.set_download_limit(limit);
|
||||
}
|
||||
|
||||
void RequestHandler::action_command_toggleAlternativeSpeedLimits()
|
||||
{
|
||||
QBtSession::instance()->useAlternativeSpeedsLimit(!Preferences::instance()->isAltBandwidthEnabled());
|
||||
}
|
||||
|
||||
void RequestHandler::action_command_alternativeSpeedLimitsEnabled()
|
||||
{
|
||||
print(QByteArray::number(Preferences::instance()->isAltBandwidthEnabled()));
|
||||
}
|
||||
|
||||
void RequestHandler::action_command_toggleSequentialDownload()
|
||||
{
|
||||
QStringList hashes = request().posts["hashes"].split("|");
|
||||
|
||||
Reference in New Issue
Block a user