show hovered links as tooltips

This commit is contained in:
Martin Rotter 2021-11-01 10:53:33 +01:00
parent 304fc1edfa
commit f6dd3f88e7
3 changed files with 11 additions and 1 deletions

View File

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.0.4" date="2021-10-29"/>
<release version="4.0.4" date="2021-11-01"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -17,6 +17,7 @@
#include <QFileIconProvider>
#include <QTimer>
#include <QToolTip>
#if QT_VERSION_MAJOR == 6
#include <QWebEngineContextMenuRequest>
@ -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);
}

View File

@ -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: