mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
Ladybird: Show tooltips for <a title> text
This commit is contained in:
parent
ce38528fff
commit
4e3e5149d5
2 changed files with 16 additions and 5 deletions
|
@ -63,6 +63,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QToolTip>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
AK::String akstring_from_qstring(QString const& qstring)
|
AK::String akstring_from_qstring(QString const& qstring)
|
||||||
|
@ -235,14 +236,18 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void page_did_enter_tooltip_area(Gfx::IntPoint const&, String const&) override
|
virtual void page_did_enter_tooltip_area(Gfx::IntPoint const& content_position, String const& tooltip) override
|
||||||
{
|
{
|
||||||
m_view.setCursor(Qt::IBeamCursor);
|
auto widget_position = m_view.to_widget(content_position);
|
||||||
|
QToolTip::showText(
|
||||||
|
m_view.mapToGlobal(QPoint(widget_position.x(), widget_position.y())),
|
||||||
|
qstring_from_akstring(tooltip),
|
||||||
|
&m_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void page_did_leave_tooltip_area() override
|
virtual void page_did_leave_tooltip_area() override
|
||||||
{
|
{
|
||||||
m_view.setCursor(Qt::ArrowCursor);
|
QToolTip::hideText();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void page_did_hover_link(AK::URL const& url) override
|
virtual void page_did_hover_link(AK::URL const& url) override
|
||||||
|
@ -613,6 +618,11 @@ Gfx::IntPoint WebView::to_content(Gfx::IntPoint viewport_position) const
|
||||||
return viewport_position.translated(horizontalScrollBar()->value(), verticalScrollBar()->value());
|
return viewport_position.translated(horizontalScrollBar()->value(), verticalScrollBar()->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gfx::IntPoint WebView::to_widget(Gfx::IntPoint content_position) const
|
||||||
|
{
|
||||||
|
return content_position.translated(-horizontalScrollBar()->value(), -verticalScrollBar()->value());
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::paintEvent(QPaintEvent* event)
|
void WebView::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
QPainter painter(viewport());
|
QPainter painter(viewport());
|
||||||
|
|
|
@ -46,6 +46,9 @@ public:
|
||||||
|
|
||||||
void show_js_console();
|
void show_js_console();
|
||||||
|
|
||||||
|
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
||||||
|
Gfx::IntPoint to_widget(Gfx::IntPoint) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void linkHovered(QString, int timeout = 0);
|
void linkHovered(QString, int timeout = 0);
|
||||||
void linkUnhovered();
|
void linkUnhovered();
|
||||||
|
@ -54,8 +57,6 @@ signals:
|
||||||
void favicon_changed(QIcon);
|
void favicon_changed(QIcon);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
|
||||||
|
|
||||||
OwnPtr<HeadlessBrowserPageClient> m_page_client;
|
OwnPtr<HeadlessBrowserPageClient> m_page_client;
|
||||||
|
|
||||||
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue