From ffab9e263f6903315ef76261c006c39f37a9a84d Mon Sep 17 00:00:00 2001 From: Kimat Boven Date: Fri, 13 Oct 2017 22:44:02 +0200 Subject: [PATCH 1/2] it was not possible to show the current_url in tab or window title note that I couldn't use {url} as field for the FormatString --- doc/help/settings.asciidoc | 2 ++ qutebrowser/config/configdata.yml | 5 +++++ qutebrowser/mainwindow/tabwidget.py | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 1973418ad..55f8af99a 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -2792,6 +2792,7 @@ The following placeholders are defined: * `{host}`: The host of the current web page. * `{backend}`: Either ''webkit'' or ''webengine'' * `{private}` : Indicates when private mode is enabled. +* `{current_url}` : The url of the current web page. Type: <> @@ -2928,6 +2929,7 @@ The following placeholders are defined: * `{host}`: The host of the current web page. * `{backend}`: Either ''webkit'' or ''webengine'' * `{private}` : Indicates when private mode is enabled. +* `{current_url}` : The url of the current web page. Type: <> diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 7e7f024f3..3cfc1ced5 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -1224,6 +1224,7 @@ tabs.title.format: - scroll_pos - host - private + - current_url none_ok: true desc: | The format to use for the tab title. @@ -1239,6 +1240,7 @@ tabs.title.format: * `{host}`: The host of the current web page. * `{backend}`: Either ''webkit'' or ''webengine'' * `{private}` : Indicates when private mode is enabled. + * `{current_url}` : The url of the current web page. tabs.title.format_pinned: default: '{index}' @@ -1254,6 +1256,7 @@ tabs.title.format_pinned: - scroll_pos - host - private + - current_url none_ok: true desc: The format to use for the tab title for pinned tabs. The same placeholders like for `tabs.title.format` are defined. @@ -1371,6 +1374,7 @@ window.title_format: - host - backend - private + - current_url default: '{perc}{title}{title_sep}qutebrowser' desc: | The format to use for the window title. @@ -1385,6 +1389,7 @@ window.title_format: * `{host}`: The host of the current web page. * `{backend}`: Either ''webkit'' or ''webengine'' * `{private}` : Indicates when private mode is enabled. + * `{current_url}` : The url of the current web page. ## zoom diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index c5566f877..a8bc45cc0 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -164,6 +164,11 @@ class TabWidget(QTabWidget): except qtutils.QtValueError: fields['host'] = '' + try: + fields['current_url'] = self.tab_url(idx).url() + except qtutils.QtValueError: + fields['current_url'] = '' + y = tab.scroller.pos_perc()[1] if y is None: scroll_pos = '???' From 8ca0c87b1ffb0e7b3cf3906f1490b4b3a7123ed8 Mon Sep 17 00:00:00 2001 From: Kimat Boven Date: Sat, 14 Oct 2017 20:03:58 +0200 Subject: [PATCH 2/2] FakeUrl had no url --- 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 15d2ce8a0..1313649bc 100644 --- a/tests/helpers/stubs.py +++ b/tests/helpers/stubs.py @@ -131,10 +131,11 @@ class FakeUrl: """QUrl stub which provides .path(), isValid() and host().""" - def __init__(self, path=None, valid=True, host=None): + def __init__(self, path=None, valid=True, host=None, url=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) class FakeNetworkReply: