diff options
| author | Mike Skec <skec@protonmail.ch> | 2021-02-16 17:01:08 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2021-02-16 11:11:23 +0100 |
| commit | 7820c0fb5cbfb5d41fa484aa5f9d0481318cfbeb (patch) | |
| tree | 7cace788cd42843eae9f0a1ce2a1bf9a66e349cb /src/browsertab.cpp | |
| parent | 2d5e076e13a7c81cf597b98a53504065c950046f (diff) | |
BrowserTab: use cleaner titles for pages without them
For sites that do not have a page title (i.e no '#' heading) the document's filename is used. If no filename exists, then the hostname of the page is used.
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 1bcc20c..92f3b7d 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -793,7 +793,16 @@ void BrowserTab::updatePageTitle() { if (page_title.isEmpty()) { - page_title = this->current_location.toString(); + // Use document filename as title instead. + page_title = this->current_location.path(); + auto parts = page_title.split("/"); + page_title = parts[parts.length() - 1]; + + if (page_title.isEmpty()) + { + // Just use the hostname if we can't find anything else + page_title = this->current_location.host(); + } } // TODO: Shorten lengthy titles? |
