From 17b2cf2e96f2384fb26fe49b2a069f54c36e03f4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 6 Nov 2019 00:29:25 +0100 Subject: [PATCH] make BrowserView::onLinkHovered() working with QtWebKit --- src/Mod/Web/Gui/BrowserView.cpp | 23 +++++++++++++++++------ src/Mod/Web/Gui/BrowserView.h | 3 ++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 278c918999..cb4a265af7 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -411,6 +411,8 @@ BrowserView::BrowserView(QWidget* parent) palette.setBrush(QPalette::Base, Qt::white); view->page()->setPalette(palette); + connect(view->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)), + this, SLOT(onLinkHovered(const QString &, const QString &, const QString &))); connect(view, SIGNAL(linkClicked(const QUrl &)), this, SLOT(onLinkClicked(const QUrl &))); connect(view->page(), SIGNAL(downloadRequested(const QNetworkRequest &)), @@ -439,9 +441,9 @@ BrowserView::BrowserView(QWidget* parent) this, SLOT(onDownloadRequested(QWebEngineDownloadItem*))); connect(view->page(), SIGNAL(iconChanged(const QIcon &)), this, SLOT(setWindowIcon(const QIcon &))); -#endif connect(view->page(), SIGNAL(linkHovered(const QString &)), this, SLOT(onLinkHovered(const QString &))); +#endif connect(view, SIGNAL(viewSource(const QUrl&)), this, SLOT(onViewSource(const QUrl&))); connect(view, SIGNAL(loadStarted()), @@ -465,11 +467,6 @@ BrowserView::~BrowserView() delete view; } -void BrowserView::onLinkHovered(const QString& url) -{ - Gui::getMainWindow()->statusBar()->showMessage(url); -} - #ifdef QTWEBENGINE void BrowserView::urlFilter(const QUrl &url) #else @@ -570,6 +567,11 @@ void BrowserView::setWindowIcon(const QIcon &icon) Gui::MDIView::setWindowIcon(icon); } +void BrowserView::onLinkHovered(const QString& url) +{ + Gui::getMainWindow()->statusBar()->showMessage(url); +} + void BrowserView::onViewSource(const QUrl &url) { Q_UNUSED(url); @@ -601,6 +603,15 @@ void BrowserView::onUnsupportedContent(QNetworkReply* reply) view->reload(); } +void BrowserView::onLinkHovered(const QString& link, const QString& title, const QString& textContent) +{ + Q_UNUSED(title) + Q_UNUSED(textContent) + QUrl url = QUrl::fromEncoded(link.toLatin1()); + QString str = url.isValid() ? url.toString() : link; + Gui::getMainWindow()->statusBar()->showMessage(str); +} + void BrowserView::onViewSource(const QUrl &url) { Q_UNUSED(url); diff --git a/src/Mod/Web/Gui/BrowserView.h b/src/Mod/Web/Gui/BrowserView.h index c3b436d4c0..d869ece741 100644 --- a/src/Mod/Web/Gui/BrowserView.h +++ b/src/Mod/Web/Gui/BrowserView.h @@ -114,12 +114,13 @@ protected Q_SLOTS: void onDownloadRequested(QWebEngineDownloadItem *request); void setWindowIcon(const QIcon &icon); void urlFilter(const QUrl &url); + void onLinkHovered(const QString& url); #else void onDownloadRequested(const QNetworkRequest& request); void onUnsupportedContent(QNetworkReply* reply); void onLinkClicked (const QUrl& url); + void onLinkHovered(const QString& link, const QString& title, const QString& textContent); #endif - void onLinkHovered(const QString& url); void onViewSource(const QUrl &url); void onOpenLinkInExternalBrowser(const QUrl& url); void onOpenLinkInNewWindow(const QUrl&);