Repository: qutebrowser/qutebrowser

Issue:
window.title_format protocol field
Couldn't find anything about this, so I'm trying an issue. Would it be possible/easy to implement a {protocol} field or something like it for window.title_format so that you could include "http(s)://" (and other protocols)?

The reason I'm asking is that I'm using KeepassXC and the autotype works perfectly with the URL field if I set the title_format to {host} and match it in the URL field for an entry. I did something similar with plugins for other browsers, but there I could also include "https" in the URL fiels to ensure no passwords would be provided unless the page is loaded using encryption. Hope that was more or less understandable...

I could try to take a look at this myself, although I have a bad habit of saying that and never getting around to actually doing something about it.... 😄 


Discussion:
Shouldn't be hard, it's just a matter of putting a `protocol` key with the correct value in [field](https://github.com/qutebrowser/qutebrowser/blob/master/qutebrowser/mainwindow/tabwidget.py#L152-L194).
See ffab9e263f6903315ef76261c006c39f37a9a84d for a similar example.

In the long run, this should be fixed by #1578 though, which would allow accessing any part of an URL.
Hi! I am new to open source projects and contributing, can I take this project?
@evanlee123: Just open a (WIP) PR.
I have not gotten around to start looking into this (as previously predicted), so please do 😄 
@evanlee123 Welcome! Yeah, please do - and if you get stuck somewhere, drop by in the [IRC channel](https://github.com/qutebrowser/qutebrowser#getting-help)! You might also want to take a look at the [contribution docs](https://github.com/qutebrowser/qutebrowser/blob/master/doc/contributing.asciidoc) for some helpful hints if you haven't yet :wink:
Will do! @marza91 Just to be clear , are you trying to implement a command that shows the protocol in the title bar (of the main window) or inside the tab titles?
I think the idea wasn't providing a command, but a field for the `window.title_format` and `tabs.title.format` settings.

Resolving patch:
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -172,14 +172,15 @@ def get_tab_fields(self, idx):
             fields['perc'] = ''
 
         try:
-            fields['host'] = self.tab_url(idx).host()
+            url = self.tab_url(idx)
         except qtutils.QtValueError:
             fields['host'] = ''
-
-        try:
-            fields['current_url'] = self.tab_url(idx).url()
-        except qtutils.QtValueError:
             fields['current_url'] = ''
+            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:


Test patch:
diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py
--- a/tests/helpers/stubs.py
+++ b/tests/helpers/stubs.py
@@ -131,11 +131,13 @@ 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.toDisplayString = mock.Mock(return_value=url)
+        self.scheme = mock.Mock(return_value=scheme)
 
 
 class FakeNetworkReply: