diff --git a/Ladybird/Qt/BrowserWindow.cpp b/Ladybird/Qt/BrowserWindow.cpp index b00a5395548..98a69e2e484 100644 --- a/Ladybird/Qt/BrowserWindow.cpp +++ b/Ladybird/Qt/BrowserWindow.cpp @@ -534,7 +534,6 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab) void BrowserWindow::initialize_tab(Tab* tab) { - QObject::connect(tab, &Tab::title_changed, this, &BrowserWindow::tab_title_changed); QObject::connect(tab, &Tab::favicon_changed, this, &BrowserWindow::tab_favicon_changed); @@ -592,6 +591,8 @@ void BrowserWindow::initialize_tab(Tab* tab) m_cookie_jar.update_cookie(cookie); }; + m_tabs_container->setTabIcon(m_tabs_container->indexOf(tab), tab->favicon()); + tab->focus_location_editor(); } diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index b0a30662497..afefb320e62 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -82,6 +82,8 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St recreate_toolbar_icons(); + m_favicon = load_icon_from_uri("resource://icons/16x16/app-browser.png"sv); + m_toolbar->addAction(&m_window->go_back_action()); m_toolbar->addAction(&m_window->go_forward_action()); m_toolbar->addAction(&m_window->reload_action()); @@ -128,7 +130,12 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St m_history.replace_current(url, m_title.toUtf8().data()); } - m_location_edit->setText(url.to_byte_string().characters()); + auto url_serialized = qstring_from_ak_string(url.serialize()); + + m_title = url_serialized; + emit title_changed(tab_index(), url_serialized); + + m_location_edit->setText(url_serialized); m_location_edit->setCursorPosition(0); // Don't add to history if back or forward is pressed @@ -166,7 +173,9 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St auto qpixmap = QPixmap::fromImage(qimage); if (qpixmap.isNull()) return; - emit favicon_changed(tab_index(), QIcon(qpixmap)); + + m_favicon = qpixmap; + emit favicon_changed(tab_index(), m_favicon); }; view().on_request_alert = [this](auto const& message) { diff --git a/Ladybird/Qt/Tab.h b/Ladybird/Qt/Tab.h index ce97eba64f4..0464b36ec5d 100644 --- a/Ladybird/Qt/Tab.h +++ b/Ladybird/Qt/Tab.h @@ -51,14 +51,16 @@ public: }; void show_inspector_window(InspectorTarget = InspectorTarget::Document); + QIcon const& favicon() const { return m_favicon; } + public slots: void focus_location_editor(); void location_edit_return_pressed(); void select_dropdown_action(); signals: - void title_changed(int id, QString); - void favicon_changed(int id, QIcon); + void title_changed(int id, QString const&); + void favicon_changed(int id, QIcon const&); private: void select_dropdown_add_item(QMenu* menu, Web::HTML::SelectItem const& item); @@ -85,6 +87,7 @@ private: WebView::History m_history; QString m_title; QLabel* m_hover_label { nullptr }; + QIcon m_favicon; QMenu* m_page_context_menu { nullptr }; Optional m_page_context_menu_search_text;