Browse Source

Show upload and download limits in status bar

adaptive-webui-19844
buinsky 10 years ago
parent
commit
364e4277ec
  1. 8
      src/webui/btjson.cpp
  2. 16
      src/webui/www/public/scripts/client.js

8
src/webui/btjson.cpp

@ -45,6 +45,7 @@ @@ -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"; @@ -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() @@ -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);
}

16
src/webui/www/public/scripts/client.js

@ -240,12 +240,20 @@ window.addEvent('load', function () { @@ -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…
Cancel
Save