mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 21:38:51 +03:00
Show upload and download limits in status bar
This commit is contained in:
parent
1b4dad214a
commit
364e4277ec
2 changed files with 20 additions and 4 deletions
|
@ -45,6 +45,7 @@
|
|||
#endif
|
||||
|
||||
#include <libtorrent/session_status.hpp>
|
||||
#include <libtorrent/session.hpp>
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
|
@ -135,8 +136,10 @@ static const char KEY_FILE_IS_SEED[] = "is_seed";
|
|||
// TransferInfo keys
|
||||
static const char KEY_TRANSFER_DLSPEED[] = "dl_info_speed";
|
||||
static const char KEY_TRANSFER_DLDATA[] = "dl_info_data";
|
||||
static const char KEY_TRANSFER_DLRATELIMIT[] = "dl_rate_limit";
|
||||
static const char KEY_TRANSFER_UPSPEED[] = "up_info_speed";
|
||||
static const char KEY_TRANSFER_UPDATA[] = "up_info_data";
|
||||
static const char KEY_TRANSFER_UPRATELIMIT[] = "up_rate_limit";
|
||||
|
||||
class QTorrentCompare
|
||||
{
|
||||
|
@ -448,9 +451,14 @@ QByteArray btjson::getTransferInfo()
|
|||
{
|
||||
CACHED_VARIABLE(QVariantMap, info, CACHE_DURATION_MS);
|
||||
session_status sessionStatus = QBtSession::instance()->getSessionStatus();
|
||||
session_settings sessionSettings = QBtSession::instance()->getSession()->settings();
|
||||
info[KEY_TRANSFER_DLSPEED] = sessionStatus.payload_download_rate;
|
||||
info[KEY_TRANSFER_DLDATA] = static_cast<qlonglong>(sessionStatus.total_payload_download);
|
||||
info[KEY_TRANSFER_UPSPEED] = sessionStatus.payload_upload_rate;
|
||||
info[KEY_TRANSFER_UPDATA] = static_cast<qlonglong>(sessionStatus.total_payload_upload);
|
||||
if (sessionSettings.download_rate_limit)
|
||||
info[KEY_TRANSFER_DLRATELIMIT] = sessionSettings.download_rate_limit;
|
||||
if (sessionSettings.upload_rate_limit)
|
||||
info[KEY_TRANSFER_UPRATELIMIT] = sessionSettings.upload_rate_limit;
|
||||
return json::toJson(info);
|
||||
}
|
||||
|
|
|
@ -240,12 +240,20 @@ window.addEvent('load', function () {
|
|||
},
|
||||
onSuccess : function (info) {
|
||||
if (info) {
|
||||
$("DlInfos").set('html', "_(D: %1 - T: %2)"
|
||||
dl_limit = "";
|
||||
if (info.dl_rate_limit != undefined)
|
||||
dl_limit = "[%1] ".replace("%1", friendlyUnit(info.dl_rate_limit, true));
|
||||
$("DlInfos").set('html', "%3_(D: %1 - T: %2)"
|
||||
.replace("%1", friendlyUnit(info.dl_info_speed, true))
|
||||
.replace("%2", friendlyUnit(info.dl_info_data, false)));
|
||||
$("UpInfos").set('html', "_(U: %1 - T: %2)"
|
||||
.replace("%2", friendlyUnit(info.dl_info_data, false))
|
||||
.replace("%3", dl_limit));
|
||||
up_limit = "";
|
||||
if (info.up_rate_limit != undefined)
|
||||
up_limit = "[%1] ".replace("%1", friendlyUnit(info.up_rate_limit, true));
|
||||
$("UpInfos").set('html', "%3_(U: %1 - T: %2)"
|
||||
.replace("%1", friendlyUnit(info.up_info_speed, true))
|
||||
.replace("%2", friendlyUnit(info.up_info_data, false)));
|
||||
.replace("%2", friendlyUnit(info.up_info_data, false))
|
||||
.replace("%3", up_limit));
|
||||
if (speedInTitle)
|
||||
document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue