diff --git a/Ladybird/Qt/Tab.cpp b/Ladybird/Qt/Tab.cpp index a67d8223b4c..e5dd1e785b2 100644 --- a/Ladybird/Qt/Tab.cpp +++ b/Ladybird/Qt/Tab.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -144,9 +145,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St } m_is_history_navigation = false; - m_window->go_back_action().setEnabled(m_history.can_go_back()); - m_window->go_forward_action().setEnabled(m_history.can_go_forward()); - m_window->reload_action().setEnabled(!m_history.is_empty()); + update_navigation_button_states(); if (m_inspector_widget) m_inspector_widget->reset(); @@ -157,6 +156,20 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St m_inspector_widget->inspect(); }; + view().on_url_updated = [this](auto const& url, auto history_behavior) { + switch (history_behavior) { + case Web::HTML::HistoryHandlingBehavior::Push: + m_history.push(url, m_title.toUtf8().data()); + break; + case Web::HTML::HistoryHandlingBehavior::Replace: + m_history.replace_current(url, m_title.toUtf8().data()); + break; + } + + m_location_edit->setText(qstring_from_ak_string(url.serialize())); + update_navigation_button_states(); + }; + QObject::connect(m_location_edit, &QLineEdit::returnPressed, this, &Tab::location_edit_return_pressed); view().on_title_change = [this](auto const& title) { @@ -842,6 +855,13 @@ void Tab::update_hover_label() m_hover_label->raise(); } +void Tab::update_navigation_button_states() +{ + m_window->go_back_action().setEnabled(m_history.can_go_back()); + m_window->go_forward_action().setEnabled(m_history.can_go_forward()); + m_window->reload_action().setEnabled(!m_history.is_empty()); +} + bool Tab::event(QEvent* event) { if (event->type() == QEvent::PaletteChange) { diff --git a/Ladybird/Qt/Tab.h b/Ladybird/Qt/Tab.h index d13ddf56842..c31d316ba5d 100644 --- a/Ladybird/Qt/Tab.h +++ b/Ladybird/Qt/Tab.h @@ -72,6 +72,7 @@ private: void recreate_toolbar_icons(); void update_hover_label(); + void update_navigation_button_states(); void open_link(URL::URL const&); void open_link_in_new_tab(URL::URL const&);