From f6dd3f88e7225a9fa9b2da4d16b0ab044ea01e4c Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 1 Nov 2021 10:53:33 +0100 Subject: [PATCH] show hovered links as tooltips --- resources/desktop/com.github.rssguard.appdata.xml | 2 +- src/librssguard/gui/webviewer.cpp | 9 +++++++++ src/librssguard/gui/webviewer.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/desktop/com.github.rssguard.appdata.xml b/resources/desktop/com.github.rssguard.appdata.xml index 362f50728..90175f9a6 100644 --- a/resources/desktop/com.github.rssguard.appdata.xml +++ b/resources/desktop/com.github.rssguard.appdata.xml @@ -26,7 +26,7 @@ https://github.com/sponsors/martinrotter - + none diff --git a/src/librssguard/gui/webviewer.cpp b/src/librssguard/gui/webviewer.cpp index afc36c601..5fd5b329e 100644 --- a/src/librssguard/gui/webviewer.cpp +++ b/src/librssguard/gui/webviewer.cpp @@ -17,6 +17,7 @@ #include #include +#include #if QT_VERSION_MAJOR == 6 #include @@ -32,6 +33,8 @@ WebViewer::WebViewer(QWidget* parent) : QWebEngineView(parent), m_root(nullptr) setPage(page); resetWebPageZoom(); + + connect(page, &WebPage::linkHovered, this, &WebViewer::onLinkHovered); } bool WebViewer::canIncreaseZoom() { @@ -312,6 +315,12 @@ bool WebViewer::eventFilter(QObject* object, QEvent* event) { return false; } +void WebViewer::onLinkHovered(const QString& url) { + qDebugNN << LOGSEC_GUI << "Hovered link:" << QUOTE_W_SPACE_DOT(url); + + QToolTip::showText(QCursor::pos(), url, {}, {}, 6000); +} + void WebViewer::openUrlWithExternalTool(ExternalTool tool, const QString& target_url) { tool.run(target_url); } diff --git a/src/librssguard/gui/webviewer.h b/src/librssguard/gui/webviewer.h index aa08d2915..c26e5d1c9 100644 --- a/src/librssguard/gui/webviewer.h +++ b/src/librssguard/gui/webviewer.h @@ -41,6 +41,7 @@ class WebViewer : public QWebEngineView { virtual bool eventFilter(QObject* object, QEvent* event); private slots: + void onLinkHovered(const QString& url); void openUrlWithExternalTool(ExternalTool tool, const QString& target_url); private: