aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp6
-rw-r--r--src/mainwindow.cpp31
2 files changed, 26 insertions, 11 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp
index 92f3b7d..997f10b 100644
--- a/src/browsertab.cpp
+++ b/src/browsertab.cpp
@@ -805,7 +805,11 @@ void BrowserTab::updatePageTitle()
}
}
- // TODO: Shorten lengthy titles?
+ // This will strip new-line characters from the title, in case
+ // there are any.
+ static const QRegularExpression NL_REGEX = QRegularExpression("\n");
+ page_title.replace(NL_REGEX, "");
+ page_title = page_title.trimmed();
emit this->titleChanged(this->page_title);
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d2623eb..3008c0b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -356,19 +356,30 @@ void MainWindow::on_history_view_doubleClicked(const QModelIndex &index)
void MainWindow::on_tab_titleChanged(const QString &title)
{
- auto * tab = qobject_cast<BrowserTab*>(sender());
- if(tab != nullptr) {
- int index = this->ui->browser_tabs->indexOf(tab);
- assert(index >= 0);
+ auto * tab = qobject_cast<BrowserTab*>(sender());
+ if(tab != nullptr) {
+ int index = this->ui->browser_tabs->indexOf(tab);
+ assert(index >= 0);
- QString escapedTitle = title;
- this->ui->browser_tabs->setTabText(index, escapedTitle.replace("&", "&&"));
+ QString escapedTitle = title;
- if (tab == this->curTab())
- {
+ // Set the window title to full title
+ if (tab == this->curTab())
+ {
updateWindowTitle();
- }
- }
+ }
+
+ // Shorten lengthy titles for tab bar (45 chars max for now - we assume
+ // that Gemini surfers don't usually have loads of tabs open, so the
+ // limit is fairly high)
+ const int MAX_TITLE_LEN = 45;
+ if (escapedTitle.length() > MAX_TITLE_LEN)
+ {
+ escapedTitle = escapedTitle.mid(0, MAX_TITLE_LEN - 3).trimmed() + "...";
+ }
+
+ this->ui->browser_tabs->setTabText(index, escapedTitle.replace("&", "&&"));
+ }
}
void MainWindow::on_tab_locationChanged(const QUrl &url)