From 8f1de0d980deeeb6e697548ff0ae62d1eee662b8 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Thu, 31 Dec 2020 15:35:24 +1100 Subject: urlbar colour formatting algorithm improvement Now uses the more robust "authority" instead of hostname for determining format. This allows for proper highlighting when a port (e.g domain:1965) or user info (e.g joe@domain) is present. --- src/browsertab.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/browsertab.cpp') diff --git a/src/browsertab.cpp b/src/browsertab.cpp index d5aaeed..1446f20 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -1146,22 +1146,23 @@ void BrowserTab::updateUrlBarStyle() return; } - // Styling enabled: hostname of the URL is highlighted - // (i.e default colour), the rest is in grey-ish colour + // Styling enabled: 'authority' (hostname, port, etc) of + // the URL is highlighted (i.e default colour), + // the rest is in grey-ish colour // // Example: // - // gemini://an.example.com/index.gmi + // gemini://an.example.com:1965/index.gmi // ^-------^ - // grey ^------------^ - // default - // ^--------^ - // grey + // grey ^-----------------^ + // default + // ^--------^ + // grey QList formats; // We only need to create one style, which is the - // non-hostname colour text (grey-ish, we use the theme's + // non-authority colour text (grey-ish, we use the theme's // placeholder text colour for this). // The rest of the text is in default theme foreground colour. QTextCharFormat f; @@ -1179,7 +1180,8 @@ void BrowserTab::updateUrlBarStyle() if (url.scheme() != "file" && !url.path().isEmpty()) { QTextLayout::FormatRange fr_right; - fr_right.start = fr_left.length + url.host().length(); + + fr_right.start = fr_left.length + url.authority().length(); fr_right.length = url.path().length(); fr_right.format = f; formats.append(fr_right); -- cgit v1.2.3