From 30b25da2735e597104f9f6b4fde6842261fcac86 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2017 13:09:44 -0700 Subject: [PATCH 1/9] Added protocol key to field --- qutebrowser/config/configdata.yml | 4 ++++ qutebrowser/mainwindow/tabwidget.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 08c854ed3..efcc07b35 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1292,6 +1292,7 @@ tabs.title.format: - host - private - current_url + - protocol none_ok: true desc: | Format to use for the tab title. @@ -1308,6 +1309,7 @@ tabs.title.format: * `{backend}`: Either ''webkit'' or ''webengine'' * `{private}` : Indicates when private mode is enabled. * `{current_url}` : URL of the current web page. + * `{protocol}` : Internet Protocol of the current web page. tabs.title.format_pinned: default: '{index}' @@ -1324,6 +1326,7 @@ tabs.title.format_pinned: - host - private - current_url + - protocol none_ok: true desc: Format to use for the tab title for pinned tabs. The same placeholders like for `tabs.title.format` are defined. @@ -1467,6 +1470,7 @@ window.title_format: - backend - private - current_url + - protocol default: '{perc}{title}{title_sep}qutebrowser' desc: | Format to use for the window title. The same placeholders like for diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index b14466337..31615cccc 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -181,6 +181,11 @@ class TabWidget(QTabWidget): except qtutils.QtValueError: fields['current_url'] = '' + try: + fields['protocol'] = self.tab_url(idx).url(options = QUrl.RemovePath) + except qtutils.QtValueError: + fields['protocol']= '' + y = tab.scroller.pos_perc()[1] if y is None: scroll_pos = '???' From 94809032a46dddbce62f279d0d9e5b85e50eb52b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2017 13:24:27 -0700 Subject: [PATCH 2/9] field[protocol] gives the right protocol] --- qutebrowser/mainwindow/tabwidget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 31615cccc..988455a08 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -182,7 +182,7 @@ class TabWidget(QTabWidget): fields['current_url'] = '' try: - fields['protocol'] = self.tab_url(idx).url(options = QUrl.RemovePath) + fields['protocol'] = self.tab_url(idx).scheme() except qtutils.QtValueError: fields['protocol']= '' From 02b24e8dfb4e7a2e65c363ba4e82708386e8e81a Mon Sep 17 00:00:00 2001 From: evanlee123 <31551958+evanlee123@users.noreply.github.com> Date: Wed, 6 Dec 2017 21:35:09 -0700 Subject: [PATCH 3/9] Update tabwidget.py --- qutebrowser/mainwindow/tabwidget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 988455a08..01b9f0728 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -184,7 +184,7 @@ class TabWidget(QTabWidget): try: fields['protocol'] = self.tab_url(idx).scheme() except qtutils.QtValueError: - fields['protocol']= '' + fields['protocol'] = '' y = tab.scroller.pos_perc()[1] if y is None: From 4d13941290f28dfe5de2ec3be3238fba41fb263b Mon Sep 17 00:00:00 2001 From: evanlee123 <31551958+evanlee123@users.noreply.github.com> Date: Wed, 6 Dec 2017 23:57:19 -0700 Subject: [PATCH 4/9] added the scheme field to FakeURL --- tests/helpers/stubs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index 878c9e166..cb3c85896 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -131,11 +131,12 @@ class FakeUrl: """QUrl stub which provides .path(), isValid() and host().""" - def __init__(self, path=None, valid=True, host=None, url=None): + def __init__(self, path=None, valid=True, host=None, url=None, scheme = None): self.path = mock.Mock(return_value=path) self.isValid = mock.Mock(returl_value=valid) self.host = mock.Mock(returl_value=host) self.url = mock.Mock(return_value=url) + self.scheme = mock.Mock(return_value=scheme) class FakeNetworkReply: From 20ac618752a6e33f7cd8ed51e6e8da8213eee29b Mon Sep 17 00:00:00 2001 From: evanlee123 <31551958+evanlee123@users.noreply.github.com> Date: Thu, 7 Dec 2017 02:04:02 -0700 Subject: [PATCH 5/9] Simplified code in get_tab_fields changed self.tab_url(idx) to url in get_tab_fields() --- qutebrowser/mainwindow/tabwidget.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 01b9f0728..9dc6cd9bf 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -165,6 +165,8 @@ class TabWidget(QTabWidget): fields['perc_raw'] = tab.progress() fields['backend'] = objects.backend.name fields['private'] = ' [Private Mode] ' if tab.private else '' + + url = self.tab_url(idx) if tab.load_status() == usertypes.LoadStatus.loading: fields['perc'] = '[{}%] '.format(tab.progress()) @@ -172,17 +174,17 @@ class TabWidget(QTabWidget): fields['perc'] = '' try: - fields['host'] = self.tab_url(idx).host() + fields['host'] = url.host() except qtutils.QtValueError: fields['host'] = '' try: - fields['current_url'] = self.tab_url(idx).url() + fields['current_url'] = url.url() except qtutils.QtValueError: fields['current_url'] = '' try: - fields['protocol'] = self.tab_url(idx).scheme() + fields['protocol'] = url.scheme() except qtutils.QtValueError: fields['protocol'] = '' From d1a00eb93446e501e97871485738b903668a89a5 Mon Sep 17 00:00:00 2001 From: evanlee123 <31551958+evanlee123@users.noreply.github.com> Date: Thu, 7 Dec 2017 02:35:34 -0700 Subject: [PATCH 6/9] Clarity on protocol field --- qutebrowser/config/configdata.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index efcc07b35..7c94d4701 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1307,9 +1307,9 @@ tabs.title.format: * `{scroll_pos}`: Page scroll position. * `{host}`: Host of the current web page. * `{backend}`: Either ''webkit'' or ''webengine'' - * `{private}` : Indicates when private mode is enabled. - * `{current_url}` : URL of the current web page. - * `{protocol}` : Internet Protocol of the current web page. + * `{private}`: Indicates when private mode is enabled. + * `{current_url}`: URL of the current web page. + * `{protocol}`: Protocol (http/https/...) of the current web page tabs.title.format_pinned: default: '{index}' From 18609f1a2444cc533c4fabdf046f3da9ff6e3278 Mon Sep 17 00:00:00 2001 From: evanlee123 <31551958+evanlee123@users.noreply.github.com> Date: Thu, 7 Dec 2017 02:36:31 -0700 Subject: [PATCH 7/9] fixed spacing on FakeURL --- tests/helpers/stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index cb3c85896..d2c0fd746 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -131,7 +131,7 @@ class FakeUrl: """QUrl stub which provides .path(), isValid() and host().""" - def __init__(self, path=None, valid=True, host=None, url=None, scheme = None): + def __init__(self, path=None, valid=True, host=None, url=None, scheme=None): self.path = mock.Mock(return_value=path) self.isValid = mock.Mock(returl_value=valid) self.host = mock.Mock(returl_value=host) From 25526f00bf959432c2d0d40606169a50173476b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Dec 2017 15:47:03 -0700 Subject: [PATCH 8/9] fixed catch error in tabwidget --- qutebrowser/mainwindow/tabwidget.py | 16 +++++----------- tests/helpers/stubs.py | 3 ++- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index 9dc6cd9bf..28cfac0fb 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -165,8 +165,6 @@ class TabWidget(QTabWidget): fields['perc_raw'] = tab.progress() fields['backend'] = objects.backend.name fields['private'] = ' [Private Mode] ' if tab.private else '' - - url = self.tab_url(idx) if tab.load_status() == usertypes.LoadStatus.loading: fields['perc'] = '[{}%] '.format(tab.progress()) @@ -174,19 +172,15 @@ class TabWidget(QTabWidget): fields['perc'] = '' try: - fields['host'] = url.host() + url = self.tab_url(idx) except qtutils.QtValueError: fields['host'] = '' - - try: - fields['current_url'] = url.url() - except qtutils.QtValueError: fields['current_url'] = '' - - try: - fields['protocol'] = url.scheme() - except qtutils.QtValueError: fields['protocol'] = '' + else: + fields['host'] = url.host() + fields['current_url'] = url.toDisplayString() + fields['protocol'] = url.scheme() y = tab.scroller.pos_perc()[1] if y is None: diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index d2c0fd746..ede073130 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -131,7 +131,8 @@ class FakeUrl: """QUrl stub which provides .path(), isValid() and host().""" - def __init__(self, path=None, valid=True, host=None, url=None, scheme=None): + def __init__(self, path=None, valid=True, host=None, url=None, + scheme=None): self.path = mock.Mock(return_value=path) self.isValid = mock.Mock(returl_value=valid) self.host = mock.Mock(returl_value=host) From 9685eb36b69e091cc99652f4cfc4f73d331d1aab Mon Sep 17 00:00:00 2001 From: evanlee123 <31551958+evanlee123@users.noreply.github.com> Date: Thu, 7 Dec 2017 16:30:34 -0700 Subject: [PATCH 9/9] Changed FakeUrl's url command to toDisplayString --- tests/helpers/stubs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py index ede073130..0fd2ba0ed 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -136,7 +136,7 @@ class FakeUrl: self.path = mock.Mock(return_value=path) self.isValid = mock.Mock(returl_value=valid) self.host = mock.Mock(returl_value=host) - self.url = mock.Mock(return_value=url) + self.toDisplayString = mock.Mock(return_value=url) self.scheme = mock.Mock(return_value=scheme)