From fc6f378dd73f0bb6cff8f6d7400bfaf572f7e341 Mon Sep 17 00:00:00 2001
From: Szabolcs David <davidsz@inf.u-szeged.hu>
Date: Thu, 15 May 2014 05:45:47 -0700
Subject: [PATCH] Add linkHovered support for Widgets API

Drop hovered title and link text parameters, as we did
in the Quick API.

Change-Id: Ia1a38e0d728afbcbb6858a890486772da74aa813
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
---
 examples/webenginewidgets/browser/tabwidget.cpp | 8 ++------
 src/webenginewidgets/api/qwebenginepage.cpp     | 6 ++++++
 src/webenginewidgets/api/qwebenginepage.h       | 1 +
 src/webenginewidgets/api/qwebenginepage_p.h     | 2 +-
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/examples/webenginewidgets/browser/tabwidget.cpp b/examples/webenginewidgets/browser/tabwidget.cpp
index af18b5a37..efc7c438f 100644
--- a/examples/webenginewidgets/browser/tabwidget.cpp
+++ b/examples/webenginewidgets/browser/tabwidget.cpp
@@ -310,10 +310,8 @@ void TabWidget::currentChanged(int index)
         disconnect(oldWebView, SIGNAL(statusBarMessage(QString)),
                 this, SIGNAL(showStatusBarMessage(QString)));
 #endif
-#if defined(QWEBENGINEVIEW_LINKHOVERED)
-        disconnect(oldWebView->page(), SIGNAL(linkHovered(QString,QString,QString)),
+        disconnect(oldWebView->page(), SIGNAL(linkHovered(QString)),
                 this, SIGNAL(linkHovered(QString)));
-#endif
         disconnect(oldWebView, SIGNAL(loadProgress(int)),
                 this, SIGNAL(loadProgress(int)));
     }
@@ -322,10 +320,8 @@ void TabWidget::currentChanged(int index)
     connect(webView, SIGNAL(statusBarMessage(QString)),
             this, SIGNAL(showStatusBarMessage(QString)));
 #endif
-#if defined(QWEBENGINEVIEW_LINKHOVERED)
-    connect(webView->page(), SIGNAL(linkHovered(QString,QString,QString)),
+    connect(webView->page(), SIGNAL(linkHovered(QString)),
             this, SIGNAL(linkHovered(QString)));
-#endif
     connect(webView, SIGNAL(loadProgress(int)),
             this, SIGNAL(loadProgress(int)));
 
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 4bd97c07e..bbdcb25df 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -205,6 +205,12 @@ void QWebEnginePagePrivate::loadProgressChanged(int progress)
     Q_EMIT q->loadProgress(progress);
 }
 
+void QWebEnginePagePrivate::didUpdateTargetURL(const QUrl &hoveredUrl)
+{
+    Q_Q(QWebEnginePage);
+    Q_EMIT q->linkHovered(hoveredUrl.toString());
+}
+
 void QWebEnginePagePrivate::selectionChanged()
 {
     Q_Q(QWebEnginePage);
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index be5e4c527..eaeae9a78 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -183,6 +183,7 @@ Q_SIGNALS:
     void loadProgress(int progress);
     void loadFinished(bool ok);
 
+    void linkHovered(const QString &url);
     void selectionChanged();
     void geometryChangeRequested(const QRect& geom);
     void windowCloseRequested();
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index d94b47fd9..db0da05e9 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -114,7 +114,7 @@ public:
     virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE;
     virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE;
     virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE;
-    virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE { };
+    virtual void didUpdateTargetURL(const QUrl&) Q_DECL_OVERRIDE;
     virtual void selectionChanged() Q_DECL_OVERRIDE;
     virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
     virtual QPoint mapToGlobal(const QPoint &posInView) const Q_DECL_OVERRIDE;
-- 
GitLab