mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-03 22:59:13 +00:00
Ladybird/Qt: Implement history state change mechanics
We now appropriately update the current history item or create a new history item in the chrome process.
This commit is contained in:
parent
245489e68c
commit
2830bdf04a
Notes:
sideshowbarker
2024-07-17 01:12:07 +09:00
Author: https://github.com/trflynn89
Commit: 2830bdf04a
Pull-request: https://github.com/SerenityOS/serenity/pull/23758
Reviewed-by: https://github.com/kalenikaliaksandr ✅
2 changed files with 24 additions and 3 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <AK/TemporaryChange.h>
|
#include <AK/TemporaryChange.h>
|
||||||
#include <LibGfx/ImageFormats/BMPWriter.h>
|
#include <LibGfx/ImageFormats/BMPWriter.h>
|
||||||
#include <LibGfx/Painter.h>
|
#include <LibGfx/Painter.h>
|
||||||
|
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
|
||||||
#include <LibWeb/HTML/SelectedFile.h>
|
#include <LibWeb/HTML/SelectedFile.h>
|
||||||
#include <LibWebView/SearchEngine.h>
|
#include <LibWebView/SearchEngine.h>
|
||||||
#include <LibWebView/SourceHighlighter.h>
|
#include <LibWebView/SourceHighlighter.h>
|
||||||
|
@ -144,9 +145,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
|
||||||
}
|
}
|
||||||
m_is_history_navigation = false;
|
m_is_history_navigation = false;
|
||||||
|
|
||||||
m_window->go_back_action().setEnabled(m_history.can_go_back());
|
update_navigation_button_states();
|
||||||
m_window->go_forward_action().setEnabled(m_history.can_go_forward());
|
|
||||||
m_window->reload_action().setEnabled(!m_history.is_empty());
|
|
||||||
|
|
||||||
if (m_inspector_widget)
|
if (m_inspector_widget)
|
||||||
m_inspector_widget->reset();
|
m_inspector_widget->reset();
|
||||||
|
@ -157,6 +156,20 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
|
||||||
m_inspector_widget->inspect();
|
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);
|
QObject::connect(m_location_edit, &QLineEdit::returnPressed, this, &Tab::location_edit_return_pressed);
|
||||||
|
|
||||||
view().on_title_change = [this](auto const& title) {
|
view().on_title_change = [this](auto const& title) {
|
||||||
|
@ -842,6 +855,13 @@ void Tab::update_hover_label()
|
||||||
m_hover_label->raise();
|
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)
|
bool Tab::event(QEvent* event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::PaletteChange) {
|
if (event->type() == QEvent::PaletteChange) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ private:
|
||||||
|
|
||||||
void recreate_toolbar_icons();
|
void recreate_toolbar_icons();
|
||||||
void update_hover_label();
|
void update_hover_label();
|
||||||
|
void update_navigation_button_states();
|
||||||
|
|
||||||
void open_link(URL::URL const&);
|
void open_link(URL::URL const&);
|
||||||
void open_link_in_new_tab(URL::URL const&);
|
void open_link_in_new_tab(URL::URL const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue