make BrowserView::onLinkHovered() working with QtWebKit

This commit is contained in:
wmayer
2019-11-06 00:29:25 +01:00
parent e4a7349947
commit 17b2cf2e96
2 changed files with 19 additions and 7 deletions

View File

@@ -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);

View File

@@ -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&);