Ladybird: Show hovered link URLs in the status bar :^)

This commit is contained in:
Andreas Kling 2022-07-03 21:07:53 +02:00 committed by Andrew Kaster
parent 9b8fe16e3d
commit 88d256c109
Notes: sideshowbarker 2024-07-17 02:50:23 +09:00
3 changed files with 12 additions and 2 deletions

View file

@ -182,15 +182,17 @@ public:
{
}
virtual void page_did_hover_link(AK::URL const&) override
virtual void page_did_hover_link(AK::URL const& url) override
{
emit m_view.linkHovered(url.to_string().characters());
}
virtual void page_did_unhover_link() override
{
emit m_view.linkUnhovered();
}
virtual void page_did_invalidate(Gfx::IntRect const& rect) override
virtual void page_did_invalidate(Gfx::IntRect const&) override
{
m_view.viewport()->update();
}

View file

@ -28,6 +28,10 @@ public:
virtual void mousePressEvent(QMouseEvent*) override;
virtual void mouseReleaseEvent(QMouseEvent*) override;
signals:
void linkHovered(QString, int timeout = 0);
void linkUnhovered();
private:
OwnPtr<HeadlessBrowserPageClient> m_page_client;
};

View file

@ -11,6 +11,7 @@
#include <LibMain/Main.h>
#include <QApplication>
#include <QMainWindow>
#include <QStatusBar>
#include <QWidget>
extern void initialize_web_engine();
@ -36,6 +37,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
WebView view;
window.setCentralWidget(&view);
QObject::connect(&view, &WebView::linkHovered, window.statusBar(), &QStatusBar::showMessage);
QObject::connect(&view, &WebView::linkUnhovered, window.statusBar(), &QStatusBar::clearMessage);
auto qt_event_loop_driver = Core::Timer::create_repeating(50, [&] {
app.processEvents();
});