From b2876b7f66b3b149685de454893659eab29e9746 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sun, 23 Nov 2014 15:17:08 +0300 Subject: [PATCH] Show speed in title --- src/webui/btjson.cpp | 3 +++ src/webui/www/public/scripts/client.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 5faa1f4c3..84deae766 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -33,6 +33,7 @@ #include "qbtsession.h" #include "torrentpersistentdata.h" #include "jsonutils.h" +#include "preferences.h" #include #include @@ -131,6 +132,7 @@ static const char KEY_TRANSFER_DLSPEED[] = "dl_info_speed"; static const char KEY_TRANSFER_DLDATA[] = "dl_info_data"; static const char KEY_TRANSFER_UPSPEED[] = "up_info_speed"; static const char KEY_TRANSFER_UPDATA[] = "up_info_data"; +static const char KEY_SHOW_SPEED_IN_TITLE[] = "show_speed_in_title"; static QVariantMap toMap(const QTorrentHandle& h) { @@ -394,5 +396,6 @@ QByteArray btjson::getTransferInfo() info[KEY_TRANSFER_DLDATA] = static_cast(sessionStatus.total_payload_download); info[KEY_TRANSFER_UPSPEED] = sessionStatus.payload_upload_rate; info[KEY_TRANSFER_UPDATA] = static_cast(sessionStatus.total_payload_upload); + info[KEY_SHOW_SPEED_IN_TITLE] = Preferences::instance()->speedInTitleBar(); return json::toJson(info); } diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 0e9bfe33a..606cf1079 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -112,6 +112,11 @@ window.addEvent('load', function(){ .replace("%2", friendlyUnit(info.dl_info_data, false))); $("UpInfos").set('html', "_(U: %1 - T: %2)".replace("%1", friendlyUnit(info.up_info_speed, true)) .replace("%2", friendlyUnit(info.up_info_data, false))); + if(info.show_speed_in_title) { + document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true)); + } else { + document.title = "_(qBittorrent web User Interface)"; + } waitingTrInfo=false; loadTransferInfo.delay(3000); }