mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Ladybird: Show tooltips for <a title> text
This commit is contained in:
parent
ce38528fff
commit
4e3e5149d5
Notes:
sideshowbarker
2024-07-17 02:45:35 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4e3e5149d5 Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/linusg
2 changed files with 16 additions and 5 deletions
|
@ -63,6 +63,7 @@
|
|||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QTextEdit>
|
||||
#include <QToolTip>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
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
|
||||
{
|
||||
m_view.setCursor(Qt::ArrowCursor);
|
||||
QToolTip::hideText();
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
Gfx::IntPoint WebView::to_widget(Gfx::IntPoint content_position) const
|
||||
{
|
||||
return content_position.translated(-horizontalScrollBar()->value(), -verticalScrollBar()->value());
|
||||
}
|
||||
|
||||
void WebView::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
QPainter painter(viewport());
|
||||
|
|
|
@ -46,6 +46,9 @@ public:
|
|||
|
||||
void show_js_console();
|
||||
|
||||
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
||||
Gfx::IntPoint to_widget(Gfx::IntPoint) const;
|
||||
|
||||
signals:
|
||||
void linkHovered(QString, int timeout = 0);
|
||||
void linkUnhovered();
|
||||
|
@ -54,8 +57,6 @@ signals:
|
|||
void favicon_changed(QIcon);
|
||||
|
||||
private:
|
||||
Gfx::IntPoint to_content(Gfx::IntPoint) const;
|
||||
|
||||
OwnPtr<HeadlessBrowserPageClient> m_page_client;
|
||||
|
||||
qreal m_inverse_pixel_scaling_ratio { 1.0 };
|
||||
|
|
Loading…
Reference in a new issue