summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2021-03-22 13:27:33 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2021-03-22 14:35:50 +0100
commitc1ba8bdae978ffbdf55d95ce3b342b09bf6fb738 (patch)
tree5ca5d0e225ba32dfea9513cb8cd3ffe0c4ea062c /src
parent93a6cc9df0f012bc1e0ed96b6016e1ad1ad07f9d (diff)
Notify canGoBack/canGoForward changes based on web actions
Before, QQuickWebEngineView's canGoBack/canGoForward change signals are based on urlChanged. But the urlChanged signal may be emitted slightly before the value of canGoBack/canGoForwad actually changes, resulting in a missed change notification. After, they get their own signals, which are forwarded from the QQuickWebEngineAction::enabledChanged signal of the respective web actions. Fixes: QTBUG-91565 Change-Id: Id411eb146c776e2824fd2447660e8857974da32e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp5
-rw-r--r--src/webengine/api/qquickwebengineview_p.h6
2 files changed, 9 insertions, 2 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 1bb89ac68..6ab1c97cb 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -876,6 +876,11 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
d->q_ptr = this;
this->setActiveFocusOnTab(true);
this->setFlags(QQuickItem::ItemIsFocusScope | QQuickItem::ItemAcceptsDrops);
+
+ connect(action(WebAction::Back), &QQuickWebEngineAction::enabledChanged,
+ this, &QQuickWebEngineView::canGoBackChanged);
+ connect(action(WebAction::Forward), &QQuickWebEngineAction::enabledChanged,
+ this, &QQuickWebEngineView::canGoForwardChanged);
}
QQuickWebEngineView::~QQuickWebEngineView()
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index ab84b2600..3155bce37 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -116,8 +116,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged FINAL)
Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged FINAL)
Q_PROPERTY(QString title READ title NOTIFY titleChanged FINAL)
- Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged FINAL)
- Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged FINAL)
+ Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY canGoBackChanged FINAL)
+ Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY canGoForwardChanged FINAL)
Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged REVISION 1 FINAL)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged REVISION 1 FINAL)
Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile NOTIFY profileChanged FINAL REVISION 1)
@@ -581,6 +581,8 @@ Q_SIGNALS:
Q_REVISION(10) void recommendedStateChanged(LifecycleState state);
Q_REVISION(10) void findTextFinished(const QWebEngineFindTextResult &result);
Q_REVISION(11) void renderProcessPidChanged(qint64 pid);
+ Q_REVISION(11) void canGoBackChanged();
+ Q_REVISION(11) void canGoForwardChanged();
#if QT_CONFIG(webengine_testsupport)
void testSupportChanged();