From 39e135e40af0aae375b1dd60f54c7d47767f8e5e Mon Sep 17 00:00:00 2001 From: buinsky Date: Tue, 25 Nov 2014 02:20:58 +0300 Subject: [PATCH 1/5] Fix menu width --- src/webui/www/public/css/Layout.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/webui/www/public/css/Layout.css b/src/webui/www/public/css/Layout.css index 9de4d720b..54b615ef8 100644 --- a/src/webui/www/public/css/Layout.css +++ b/src/webui/www/public/css/Layout.css @@ -119,7 +119,7 @@ body { font-size: 12px; } -#desktopNavbar li { +#desktopNavbar>ul>li { float: left; } @@ -151,7 +151,6 @@ body { border: 1px solid #3f3f3f; background: #fff url(../images/skin/bg-dropdown.gif) repeat-y; position: absolute; - width: 164px; left: -999em; z-index: 8000; /* Fix by Chris */ @@ -184,7 +183,7 @@ body { #desktopNavbar li ul li a { position: relative; /*padding: 1px 9px 1px 25px;*/ - width: 134px; + min-width: 120px; color: #3f3f3f; font-weight: normal; /* Fix By Chris */ From 632fd84e5456c764850d94c1cea7187f36b01876 Mon Sep 17 00:00:00 2001 From: buinsky Date: Tue, 25 Nov 2014 10:46:00 +0300 Subject: [PATCH 2/5] Fix context menu width --- src/webui/www/public/css/style.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webui/www/public/css/style.css b/src/webui/www/public/css/style.css index f5b8f7c16..aae22b6da 100644 --- a/src/webui/www/public/css/style.css +++ b/src/webui/www/public/css/style.css @@ -162,7 +162,7 @@ a.propButton img { } /* context menu specific */ -#contextmenu { border:1px solid #999; padding:0; background:#eee; list-style-type:none; display:none; width: 164px;} +#contextmenu { border:1px solid #999; padding:0; background:#eee; list-style-type:none; display:none;} #contextmenu .separator { border-top:1px solid #999; } #contextmenu li { margin:0; padding:0;} #contextmenu li a { display:block; padding:5px 10px 5px 5px; font-size:12px; text-decoration:none; font-family:tahoma,arial,sans-serif; color:#000; } @@ -176,7 +176,7 @@ a.propButton img { position: absolute; left: -999em; z-index: 8000; - margin: -29px 0 0 164px; + margin: -29px 0 0 100%; width: 164px; } #contextmenu li ul li a { From b0e138d6694410a25b99e324d08d8fd11cbfe3d9 Mon Sep 17 00:00:00 2001 From: buinsky Date: Tue, 25 Nov 2014 12:50:14 +0300 Subject: [PATCH 3/5] Set images cache expiry time to 300000 seconds --- src/webui/abstractrequesthandler.cpp | 3 +++ src/webui/httptypes.h | 1 + 2 files changed, 4 insertions(+) diff --git a/src/webui/abstractrequesthandler.cpp b/src/webui/abstractrequesthandler.cpp index 0ec2b73c8..3152532de 100644 --- a/src/webui/abstractrequesthandler.cpp +++ b/src/webui/abstractrequesthandler.cpp @@ -94,6 +94,9 @@ void AbstractRequestHandler::print_impl(const QByteArray& data, const QString& t if (!response_.headers.contains(HEADER_CONTENT_TYPE)) response_.headers[HEADER_CONTENT_TYPE] = type; + if (type.indexOf("image") > -1) + response_.headers[HEADER_CACHE_CONTROL] = "max-age=3000000"; + response_.content += data; } diff --git a/src/webui/httptypes.h b/src/webui/httptypes.h index 9eabf577c..7fd95c310 100644 --- a/src/webui/httptypes.h +++ b/src/webui/httptypes.h @@ -39,6 +39,7 @@ const QString HEADER_SET_COOKIE = "Set-Cookie"; const QString HEADER_CONTENT_TYPE = "Content-Type"; const QString HEADER_CONTENT_ENCODING = "Content-Encoding"; const QString HEADER_CONTENT_LENGTH = "Content-Length"; +const QString HEADER_CACHE_CONTROL = "Cache-Control"; const QString CONTENT_TYPE_CSS = "text/css; charset=UTF-8"; const QString CONTENT_TYPE_GIF = "image/gif"; From 5e8c62e539b6218fe592b7d582aaf9b69827ed86 Mon Sep 17 00:00:00 2001 From: buinsky Date: Tue, 25 Nov 2014 12:58:44 +0300 Subject: [PATCH 4/5] Add "Speed in title bar" item to menu * file: src/Icons/oxygen/checked.png copyright: Victor Buinsky --- AUTHORS | 3 +++ src/Icons/oxygen/checked.png | Bin 0 -> 300 bytes src/icons.qrc | 1 + src/webui/btjson.cpp | 3 --- src/webui/www/private/index.html | 6 ++++++ src/webui/www/public/scripts/client.js | 7 +++---- src/webui/www/public/scripts/mocha-init.js | 18 ++++++++++++++++++ 7 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 src/Icons/oxygen/checked.png diff --git a/AUTHORS b/AUTHORS index 80e733b83..f4db303d9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -77,6 +77,9 @@ Images Authors: * file: src/search_engine/engines/torrentreactor.png copyright: Downloaded from torrentreactor.net +* file: src/Icons/oxygen/checked.png + copyright: Victor Buinsky + Translations authors: * files: src/lang/*.ts * file: src/Icons/qBittorrent.desktop diff --git a/src/Icons/oxygen/checked.png b/src/Icons/oxygen/checked.png new file mode 100644 index 0000000000000000000000000000000000000000..82bd006a605e2b475d6bef84d3ae6ff1212f087c GIT binary patch literal 300 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P^!c=q9iy!t)x7$D3u`~F*C13&(AePq0Cs%RL{`R{j-xfP}K@g z7sn6_|EuRW@;Mqxv^})CJ&$LxI@z2jtUe4xs;RBy(%GQ>)e2EO@(9M62 z9qS06pQ(IRro5+XY9x1hMn$*Qq_+#_KUQ2_RO>3A|M~#~udTp(yQ9ay7PPRXHgj!y rgTe~DWM4fD8_El literal 0 HcmV?d00001 diff --git a/src/icons.qrc b/src/icons.qrc index c67e6c0b6..b6f4593e2 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -365,5 +365,6 @@ Icons/oxygen/system-log-out.png Icons/oxygen/go-bottom.png Icons/oxygen/go-top.png + Icons/oxygen/checked.png diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 84deae766..5faa1f4c3 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -33,7 +33,6 @@ #include "qbtsession.h" #include "torrentpersistentdata.h" #include "jsonutils.h" -#include "preferences.h" #include #include @@ -132,7 +131,6 @@ 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) { @@ -396,6 +394,5 @@ 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/private/index.html b/src/webui/www/private/index.html index c8e246073..7bb4d6d26 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -52,6 +52,12 @@
  • _(&Delete)_(&Delete)
  • +
  • + _(&View) + +
  • _(&Tools)
      diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 606cf1079..89dda29b6 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -112,11 +112,10 @@ 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) { + if(Cookie.read('speed_in_browser_title_bar') == 'true') document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true)); - } else { + else document.title = "_(qBittorrent web User Interface)"; - } waitingTrInfo=false; loadTransferInfo.delay(3000); } @@ -253,7 +252,7 @@ window.addEvent('load', function(){ $("all_filter").removeClass("selectedFilter"); $("downloading_filter").removeClass("selectedFilter"); $("completed_filter").removeClass("selectedFilter"); - $("paused_filter").removeClass("selectedFilter"); + $("paused_filter").removeClass("selectedFilter"); $("active_filter").removeClass("selectedFilter"); $("inactive_filter").removeClass("selectedFilter"); $(f+"_filter").addClass("selectedFilter"); diff --git a/src/webui/www/public/scripts/mocha-init.js b/src/webui/www/public/scripts/mocha-init.js index 95ed025e4..6eac507f3 100644 --- a/src/webui/www/public/scripts/mocha-init.js +++ b/src/webui/www/public/scripts/mocha-init.js @@ -269,6 +269,24 @@ initializeWindows = function(){ }).send(); }); + updateSpeedInBrowserTitleBarLinkCheckState = function() + { + if (Cookie.read('speed_in_browser_title_bar') == 'true') + $(speedInBrowserTitleBarLink).firstChild.style.opacity = '1'; + else + $(speedInBrowserTitleBarLink).firstChild.style.opacity = '0'; + } + + updateSpeedInBrowserTitleBarLinkCheckState(); + + addClickEvent('speedInBrowserTitleBar', function(e){ + new Event(e).stop(); + var speed_in_browser_title_bar = Cookie.read('speed_in_browser_title_bar'); + speed_in_browser_title_bar = speed_in_browser_title_bar == 'true' ? 'false' : 'true'; + Cookie.write('speed_in_browser_title_bar', speed_in_browser_title_bar, {duration: 365 * 10}); + updateSpeedInBrowserTitleBarLinkCheckState(true); + }); + // Deactivate menu header links $$('a.returnFalse').each(function(el){ el.addEvent('click', function(e){ From 740617e5ce7f8b76233dac3ac02c8ce4b29c5302 Mon Sep 17 00:00:00 2001 From: buinsky Date: Sun, 30 Nov 2014 01:40:26 +0300 Subject: [PATCH 5/5] Use localStorage instead of cookies --- src/webui/www/public/scripts/client.js | 14 +++---- src/webui/www/public/scripts/dynamicTable.js | 2 +- src/webui/www/public/scripts/mocha-init.js | 42 +++++++++++++------- 3 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 89dda29b6..b69f979e1 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -33,9 +33,8 @@ window.addEvent('load', function(){ var saveColumnSizes = function() { var filters_width = $('Filters').getSize().x; var properties_height = $('propertiesPanel').getSize().y; - // Save it in a cookie - Cookie.write('filters_width', filters_width); - Cookie.write('properties_height', properties_height); + localStorage.setItem('filters_width', filters_width); + localStorage.setItem('properties_height', properties_height); } /*MochaUI.Desktop = new MochaUI.Desktop(); @@ -45,7 +44,7 @@ window.addEvent('load', function(){ });*/ MochaUI.Desktop.initialize(); - var filt_w = Cookie.read('filters_width'); + var filt_w = localStorage.getItem('filters_width'); if($defined(filt_w)) filt_w = filt_w.toInt(); else @@ -112,7 +111,7 @@ 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(Cookie.read('speed_in_browser_title_bar') == 'true') + if(localStorage.getItem('speed_in_browser_title_bar') == 'true') 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)"; @@ -226,7 +225,7 @@ window.addEvent('load', function(){ onResize: saveColumnSizes, height: null }); - var prop_h = Cookie.read('properties_height'); + var prop_h = localStorage.getItem('properties_height'); if($defined(prop_h)) prop_h = prop_h.toInt(); else @@ -258,8 +257,7 @@ window.addEvent('load', function(){ $(f+"_filter").addClass("selectedFilter"); myTable.setFilter(f); ajaxfn(); - // Remember this via Cookie - Cookie.write('selected_filter', f); + localStorage.setItem('selected_filter', f); } }); diff --git a/src/webui/www/public/scripts/dynamicTable.js b/src/webui/www/public/scripts/dynamicTable.js index a05f69caa..7792c9958 100644 --- a/src/webui/www/public/scripts/dynamicTable.js +++ b/src/webui/www/public/scripts/dynamicTable.js @@ -42,7 +42,7 @@ var dynamicTable = new Class ({ this.cur = new Array(); this.priority_hidden = false; this.progressIndex = progressIndex; - this.filter = Cookie.read('selected_filter'); + this.filter = localStorage.getItem('selected_filter'); if(!$defined(this.filter)) { this.filter = 'all'; } diff --git a/src/webui/www/public/scripts/mocha-init.js b/src/webui/www/public/scripts/mocha-init.js index 6eac507f3..eb6a56bfe 100644 --- a/src/webui/www/public/scripts/mocha-init.js +++ b/src/webui/www/public/scripts/mocha-init.js @@ -9,6 +9,18 @@ ----------------------------------------------------------------- */ +/* Define localStorage object for older browsers */ +if (typeof localStorage == 'undefined') { + window['localStorage'] = { + getItem: function(name) { + return Cookie.read(name); + }, + setItem: function(name, value) { + Cookie.write(name, value, {duration: 365 * 10}); + } + } +} + initializeWindows = function(){ function addClickEvent(el, fn){ @@ -269,23 +281,23 @@ initializeWindows = function(){ }).send(); }); - updateSpeedInBrowserTitleBarLinkCheckState = function() - { - if (Cookie.read('speed_in_browser_title_bar') == 'true') - $(speedInBrowserTitleBarLink).firstChild.style.opacity = '1'; - else - $(speedInBrowserTitleBarLink).firstChild.style.opacity = '0'; - } + updateSpeedInBrowserTitleBarLinkCheckState = function() + { + if (localStorage.getItem('speed_in_browser_title_bar') == 'true') + $(speedInBrowserTitleBarLink).firstChild.style.opacity = '1'; + else + $(speedInBrowserTitleBarLink).firstChild.style.opacity = '0'; + } - updateSpeedInBrowserTitleBarLinkCheckState(); + updateSpeedInBrowserTitleBarLinkCheckState(); - addClickEvent('speedInBrowserTitleBar', function(e){ - new Event(e).stop(); - var speed_in_browser_title_bar = Cookie.read('speed_in_browser_title_bar'); - speed_in_browser_title_bar = speed_in_browser_title_bar == 'true' ? 'false' : 'true'; - Cookie.write('speed_in_browser_title_bar', speed_in_browser_title_bar, {duration: 365 * 10}); - updateSpeedInBrowserTitleBarLinkCheckState(true); - }); + addClickEvent('speedInBrowserTitleBar', function(e){ + new Event(e).stop(); + var speed_in_browser_title_bar = localStorage.getItem('speed_in_browser_title_bar'); + speed_in_browser_title_bar = speed_in_browser_title_bar == 'true' ? 'false' : 'true'; + localStorage.setItem('speed_in_browser_title_bar', speed_in_browser_title_bar); + updateSpeedInBrowserTitleBarLinkCheckState(); + }); // Deactivate menu header links $$('a.returnFalse').each(function(el){