aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp31
1 files changed, 21 insertions, 10 deletions
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)