aboutsummaryrefslogtreecommitdiff
path: root/src/browsertab.cpp
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2020-12-31 15:35:24 +1100
committerFelix Queißner <felix@ib-queissner.de>2020-12-31 10:57:55 +0100
commit8f1de0d980deeeb6e697548ff0ae62d1eee662b8 (patch)
tree4fcc3cc65d4f7e5d780e44b891a3138aab385b4c /src/browsertab.cpp
parenteabbbebed714f4d54f57fb9065ecbeb303f08f9b (diff)
downloadkristall-8f1de0d980deeeb6e697548ff0ae62d1eee662b8.tar.gz
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.
Diffstat (limited to 'src/browsertab.cpp')
-rw-r--r--src/browsertab.cpp20
1 files changed, 11 insertions, 9 deletions
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<QTextLayout::FormatRange> 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);