From c2829ce2a0982dbcf265b378f96fd97eff1bd3d6 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Sat, 27 Apr 2024 14:33:09 +0100 Subject: [PATCH] Ladybird: Retreive the tab title from the underlying Tab Rather than getting the tab name from the tab container. This resolves an issue where ampersands were being introduced to the window title when changing tabs. --- Ladybird/Qt/BrowserWindow.cpp | 7 +++++-- Ladybird/Qt/Tab.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index 41c8ce22573..afdba38901a 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -402,8 +402,11 @@ BrowserWindow::BrowserWindow(Vector const& initial_urls, WebView::Cook }); QObject::connect(quit_action, &QAction::triggered, this, &QMainWindow::close); QObject::connect(m_tabs_container, &QTabWidget::currentChanged, [this](int index) { - setWindowTitle(QString("%1 - Ladybird").arg(m_tabs_container->tabText(index))); - set_current_tab(verify_cast(m_tabs_container->widget(index))); + auto* tab = verify_cast(m_tabs_container->widget(index)); + if (tab) + setWindowTitle(QString("%1 - Ladybird").arg(tab->title())); + + set_current_tab(tab); }); QObject::connect(m_tabs_container, &QTabWidget::tabCloseRequested, this, &BrowserWindow::close_tab); QObject::connect(close_current_tab_action, &QAction::triggered, this, &BrowserWindow::close_current_tab); diff --git a/Ladybird/Qt/Tab.h b/Ladybird/Qt/Tab.h index 99ef5fa2fb6..b7af225e2b7 100644 --- a/Ladybird/Qt/Tab.h +++ b/Ladybird/Qt/Tab.h @@ -52,6 +52,7 @@ public: void show_inspector_window(InspectorTarget = InspectorTarget::Document); QIcon const& favicon() const { return m_favicon; } + QString const& title() const { return m_title; } void update_navigation_buttons_state();