From 2cc9a92ad3796e6ec1e4cdfb3fe68eddc86ad4ac Mon Sep 17 00:00:00 2001 From: Jarred Nicholls Date: Thu, 9 Oct 2014 08:25:08 -0400 Subject: Notify canGoBack/canGoForward on urlChanged instead of loadingChanged. In order to support Fragment (#) based routing and history navigation together, canGoBack/canGoForward properties should be notified when the url is changed instead of when the page is loading. Task-number: QTBUG-41849 Change-Id: Ic995fffa5c683dade88fbd98ffea90527a77261b Reviewed-by: Michael Bruning Reviewed-by: Jocelyn Turcotte Reviewed-by: Jarred Nicholls --- src/webengine/api/qquickwebengineview_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/webengine/api') diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 402c2ce65..22713ee22 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -54,8 +54,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged) Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged) Q_PROPERTY(QString title READ title NOTIFY titleChanged) - Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY loadingChanged) - Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY loadingChanged) + Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged) + Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged) Q_ENUMS(NavigationRequestAction); Q_ENUMS(NavigationType); Q_ENUMS(LoadStatus); -- cgit v1.2.3 From f1e16024b7d608e5d4dc2144d2c97eca73c951ef Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Fri, 10 Oct 2014 18:29:27 +0200 Subject: Add setting ErrorPageEnabled This is required so that embedders can implement custom error pages, and is also needed for tests, where error-page loading has side-effects on subsequent page loads. Change-Id: I5ae276a58864a2fa9d7b608bea3340b482a92f4e Reviewed-by: Peter Varga --- src/webengine/api/qquickwebenginesettings.cpp | 15 +++++++++++++++ src/webengine/api/qquickwebenginesettings_p.h | 4 ++++ 2 files changed, 19 insertions(+) (limited to 'src/webengine/api') diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index aa6290aa8..7f36bad5e 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -140,6 +140,12 @@ bool QQuickWebEngineSettings::hyperlinkAuditingEnabled() const return d->coreSettings->testAttribute(WebEngineSettings::HyperlinkAuditingEnabled); } +bool QQuickWebEngineSettings::errorPageEnabled() const +{ + Q_D(const QQuickWebEngineSettings); + return d->coreSettings->testAttribute(WebEngineSettings::ErrorPageEnabled); +} + QString QQuickWebEngineSettings::defaultTextEncoding() const { Q_D(const QQuickWebEngineSettings); @@ -239,6 +245,15 @@ void QQuickWebEngineSettings::setHyperlinkAuditingEnabled(bool on) Q_EMIT hyperlinkAuditingEnabledChanged(on); } +void QQuickWebEngineSettings::setErrorPageEnabled(bool on) +{ + Q_D(QQuickWebEngineSettings); + bool wasOn = d->coreSettings->testAttribute(WebEngineSettings::ErrorPageEnabled); + d->coreSettings->setAttribute(WebEngineSettings::ErrorPageEnabled, on); + if (wasOn ^ on) + Q_EMIT errorPageEnabledChanged(on); +} + void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding) { Q_D(QQuickWebEngineSettings); diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h index 0fa44ef44..4a7c2f834 100644 --- a/src/webengine/api/qquickwebenginesettings_p.h +++ b/src/webengine/api/qquickwebenginesettings_p.h @@ -57,6 +57,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject { Q_PROPERTY(bool spatialNavigationEnabled READ spatialNavigationEnabled WRITE setSpatialNavigationEnabled NOTIFY spatialNavigationEnabledChanged) Q_PROPERTY(bool localContentCanAccessFileUrls READ localContentCanAccessFileUrls WRITE setLocalContentCanAccessFileUrls NOTIFY localContentCanAccessFileUrlsChanged) Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged) + Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged) Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged) public: @@ -74,6 +75,7 @@ public: bool spatialNavigationEnabled() const; bool localContentCanAccessFileUrls() const; bool hyperlinkAuditingEnabled() const; + bool errorPageEnabled() const; QString defaultTextEncoding() const; void setAutoLoadImages(bool on); @@ -86,6 +88,7 @@ public: void setSpatialNavigationEnabled(bool on); void setLocalContentCanAccessFileUrls(bool on); void setHyperlinkAuditingEnabled(bool on); + void setErrorPageEnabled(bool on); void setDefaultTextEncoding(QString encoding); signals: @@ -99,6 +102,7 @@ signals: void spatialNavigationEnabledChanged(bool on); void localContentCanAccessFileUrlsChanged(bool on); void hyperlinkAuditingEnabledChanged(bool on); + void errorPageEnabledChanged(bool on); void defaultTextEncodingChanged(QString encoding); private: -- cgit v1.2.3 From 2282c6605bc554ca610239f3dbc4d6d067c25763 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 22 Oct 2014 12:34:17 +0200 Subject: Make url handling consistent in widget and quick API Use explicit url in quick API too and use GetLastCommittedURL instead of GetVisibleURL for getting the expected urls in tests. Change-Id: If3251323645979643f3dc0e16491fe35b584f51c Reviewed-by: Andras Becsi --- src/webengine/api/qquickwebengineview.cpp | 5 ++++- src/webengine/api/qquickwebengineview_p_p.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/webengine/api') diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index b466c8566..ad850e84e 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -241,6 +241,7 @@ void QQuickWebEngineViewPrivate::urlChanged(const QUrl &url) { Q_Q(QQuickWebEngineView); Q_UNUSED(url); + explicitUrl = QUrl(); Q_EMIT q->urlChanged(); } @@ -309,6 +310,7 @@ void QQuickWebEngineViewPrivate::loadFinished(bool success, const QUrl &url, int return; } if (success) { + explicitUrl = QUrl(); QQuickWebEngineLoadRequest loadRequest(url, QQuickWebEngineView::LoadSucceededStatus); Q_EMIT q->loadingChanged(&loadRequest); return; @@ -506,7 +508,7 @@ QQuickWebEngineView::~QQuickWebEngineView() QUrl QQuickWebEngineView::url() const { Q_D(const QQuickWebEngineView); - return d->adapter->activeUrl(); + return d->explicitUrl.isValid() ? d->explicitUrl : d->adapter->activeUrl(); } void QQuickWebEngineView::setUrl(const QUrl& url) @@ -515,6 +517,7 @@ void QQuickWebEngineView::setUrl(const QUrl& url) return; Q_D(QQuickWebEngineView); + d->explicitUrl = url; d->adapter->load(url); } diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index ac8b8564f..6662f1f02 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -188,6 +188,7 @@ public: QScopedPointer m_history; QScopedPointer m_settings; QQmlComponent *contextMenuExtraItems; + QUrl explicitUrl; QUrl icon; int loadProgress; bool inspectable; -- cgit v1.2.3 From ff6b175a50dd936f4cb1a32eceedc4d63aea1ca7 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Tue, 28 Oct 2014 15:22:05 +0100 Subject: Support Qt::AA_ShareOpenGLContexts QtWebEngine::initialize happens after QGuiApplication instantiation, so it is too late to simply set the application attribute. In that scenario, we don't want to override the shared context and risk a double free when both QGuiApplication and our cleanup handler try to delete it. Change-Id: Id52884abbb0c2380208876d9c00e8ddbfbc21eda Reviewed-by: Jocelyn Turcotte Reviewed-by: Andras Becsi --- src/webengine/api/qtwebengineglobal.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/webengine/api') diff --git a/src/webengine/api/qtwebengineglobal.cpp b/src/webengine/api/qtwebengineglobal.cpp index ea119bba6..b179da2fe 100644 --- a/src/webengine/api/qtwebengineglobal.cpp +++ b/src/webengine/api/qtwebengineglobal.cpp @@ -43,6 +43,7 @@ QT_BEGIN_NAMESPACE Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context); +Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); namespace QtWebEngine { @@ -54,8 +55,20 @@ static void deleteShareContext() shareContext = 0; } +// ### Qt 6: unify this logic and Qt::AA_ShareOpenGLContexts. +// QtWebEngine::initialize was introduced first and meant to be called +// after the QGuiApplication creation, when AA_ShareOpenGLContexts fills +// the same need but the flag has to be set earlier. void initialize() { +#ifdef Q_OS_WIN32 + qputenv("QT_D3DCREATE_MULTITHREADED", "1"); +#endif + + // No need to override the shared context if QApplication already set one (e.g with Qt::AA_ShareOpenGLContexts). + if (qt_gl_global_share_context()) + return; + QCoreApplication *app = QCoreApplication::instance(); if (!app) { qFatal("QWebEngine(Widgets)::initialize() must be called after the construction of the application object."); @@ -69,10 +82,6 @@ void initialize() if (shareContext) return; -#ifdef Q_OS_WIN32 - qputenv("QT_D3DCREATE_MULTITHREADED", "1"); -#endif - shareContext = new QOpenGLContext; shareContext->create(); qAddPostRoutine(deleteShareContext); -- cgit v1.2.3