mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
WebAPI: Add endpoint to set speed limit mode
This commit is contained in:
parent
3dd616f6ff
commit
7d97905716
@ -117,6 +117,18 @@ void TransferController::speedLimitsModeAction()
|
||||
setResult(QString::number(BitTorrent::Session::instance()->isAltGlobalSpeedLimitEnabled()));
|
||||
}
|
||||
|
||||
void TransferController::setSpeedLimitsModeAction()
|
||||
{
|
||||
requireParams({u"mode"_qs});
|
||||
|
||||
const std::optional<int> mode = Utils::String::parseInt(params().value(u"mode"_qs));
|
||||
if (!mode)
|
||||
throw APIError(APIErrorType::BadParams, tr("'mode': invalid argument"));
|
||||
|
||||
// Any non-zero values are considered as alternative mode
|
||||
BitTorrent::Session::instance()->setAltGlobalSpeedLimitEnabled(mode != 0);
|
||||
}
|
||||
|
||||
void TransferController::banPeersAction()
|
||||
{
|
||||
requireParams({u"peers"_qs});
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
private slots:
|
||||
void infoAction();
|
||||
void speedLimitsModeAction();
|
||||
void setSpeedLimitsModeAction();
|
||||
void toggleSpeedLimitsModeAction();
|
||||
void uploadLimitAction();
|
||||
void downloadLimitAction();
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "base/utils/version.h"
|
||||
#include "api/isessionmanager.h"
|
||||
|
||||
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 13};
|
||||
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 14};
|
||||
|
||||
class APIController;
|
||||
class AuthController;
|
||||
|
Loading…
Reference in New Issue
Block a user