mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +00:00
Ladybird: Add a "Reload" action to reload the current URL
This commit is contained in:
parent
7bf3010185
commit
69d264828f
|
@ -1,12 +1,21 @@
|
|||
#include "BrowserWindow.h"
|
||||
#include "WebView.h"
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <QAction>
|
||||
#include <QStatusBar>
|
||||
|
||||
extern String s_serenity_resource_root;
|
||||
|
||||
BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
|
||||
: m_event_loop(event_loop)
|
||||
{
|
||||
m_toolbar = new QToolBar;
|
||||
|
||||
auto reload_icon_path = QString("%1/res/icons/16x16/reload.png").arg(s_serenity_resource_root.characters());
|
||||
auto* reload_action = new QAction(QIcon(reload_icon_path), "Reload");
|
||||
reload_action->setShortcut(QKeySequence("Ctrl+R"));
|
||||
m_toolbar->addAction(reload_action);
|
||||
|
||||
m_location_edit = new QLineEdit;
|
||||
m_toolbar->addWidget(m_location_edit);
|
||||
|
||||
|
@ -22,6 +31,8 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
|
|||
QObject::connect(m_location_edit, &QLineEdit::returnPressed, this, &BrowserWindow::location_edit_return_pressed);
|
||||
QObject::connect(m_view, &WebView::title_changed, this, &BrowserWindow::page_title_changed);
|
||||
QObject::connect(m_view, &WebView::favicon_changed, this, &BrowserWindow::page_favicon_changed);
|
||||
|
||||
QObject::connect(reload_action, &QAction::triggered, this, &BrowserWindow::reload);
|
||||
}
|
||||
|
||||
void BrowserWindow::location_edit_return_pressed()
|
||||
|
@ -51,3 +62,8 @@ void BrowserWindow::closeEvent(QCloseEvent* event)
|
|||
// all of the browser windows have closed.
|
||||
m_event_loop.quit(0);
|
||||
}
|
||||
|
||||
void BrowserWindow::reload()
|
||||
{
|
||||
view().reload();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@ public slots:
|
|||
void page_title_changed(QString);
|
||||
void page_favicon_changed(QIcon);
|
||||
|
||||
public slots:
|
||||
void reload();
|
||||
|
||||
private:
|
||||
QToolBar* m_toolbar { nullptr };
|
||||
QLineEdit* m_location_edit { nullptr };
|
||||
|
|
|
@ -298,6 +298,12 @@ WebView::~WebView()
|
|||
{
|
||||
}
|
||||
|
||||
void WebView::reload()
|
||||
{
|
||||
auto url = m_page_client->page().top_level_browsing_context().active_document()->url();
|
||||
m_page_client->load(url);
|
||||
}
|
||||
|
||||
void WebView::load(String const& url)
|
||||
{
|
||||
m_page_client->load(AK::URL(url));
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
virtual ~WebView() override;
|
||||
|
||||
void load(String const& url);
|
||||
void reload();
|
||||
|
||||
virtual void paintEvent(QPaintEvent*) override;
|
||||
virtual void resizeEvent(QResizeEvent*) override;
|
||||
|
|
Loading…
Reference in a new issue