diff options
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebenginesettings.cpp | 15 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginesettings_p.h | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 5 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qtwebengineglobal.cpp | 17 | ||||
-rw-r--r-- | src/webengine/plugin/plugins.qmltypes | 164 |
7 files changed, 203 insertions, 7 deletions
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: diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index ce53d4f8a..3a6b8cb21 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -242,6 +242,7 @@ void QQuickWebEngineViewPrivate::urlChanged(const QUrl &url) { Q_Q(QQuickWebEngineView); Q_UNUSED(url); + explicitUrl = QUrl(); Q_EMIT q->urlChanged(); } @@ -310,6 +311,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; @@ -514,7 +516,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) @@ -523,6 +525,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.h b/src/webengine/api/qquickwebengineview_p.h index e2871a79e..9f6493022 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_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) Q_ENUMS(NavigationRequestAction); Q_ENUMS(NavigationType); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index a89de5556..c7ea6575e 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -190,6 +190,7 @@ public: QScopedPointer<QQuickWebEngineHistory> m_history; QScopedPointer<QQuickWebEngineSettings> m_settings; QQmlComponent *contextMenuExtraItems; + QUrl explicitUrl; QUrl icon; int loadProgress; bool inspectable; 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); diff --git a/src/webengine/plugin/plugins.qmltypes b/src/webengine/plugin/plugins.qmltypes new file mode 100644 index 000000000..cebf986d2 --- /dev/null +++ b/src/webengine/plugin/plugins.qmltypes @@ -0,0 +1,164 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -noinstantiate -nonrelocatable QtWebEngine 1.0' + +Module { + Component { + name: "QQuickWebEngineLoadRequest" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineLoadRequest 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "url"; type: "QUrl"; isReadonly: true } + Property { name: "status"; type: "QQuickWebEngineView::LoadStatus"; isReadonly: true } + Property { name: "errorString"; type: "string"; isReadonly: true } + Property { name: "errorDomain"; type: "QQuickWebEngineView::ErrorDomain"; isReadonly: true } + Property { name: "errorCode"; type: "int"; isReadonly: true } + } + Component { + name: "QQuickWebEngineNavigationRequest" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineNavigationRequest 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { name: "url"; type: "QUrl"; isReadonly: true } + Property { name: "isMainFrame"; type: "bool"; isReadonly: true } + Property { name: "action"; type: "QQuickWebEngineView::NavigationRequestAction" } + Property { + name: "navigationType" + type: "QQuickWebEngineView::NavigationType" + isReadonly: true + } + } + Component { + name: "QQuickWebEngineNewViewRequest" + prototype: "QObject" + exports: ["QtWebEngine/WebEngineNewViewRequest 1.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Property { + name: "destination" + type: "QQuickWebEngineView::NewViewDestination" + isReadonly: true + } + Property { name: "userInitiated"; type: "bool"; isReadonly: true } + Method { + name: "openIn" + Parameter { name: "view"; type: "QQuickWebEngineView"; isPointer: true } + } + } + Component { + name: "QQuickWebEngineView" + defaultProperty: "data" + prototype: "QQuickItem" + exports: ["QtWebEngine/WebEngineView 1.0"] + exportMetaObjectRevisions: [0] + Enum { + name: "NavigationRequestAction" + values: { + "AcceptRequest": 0, + "IgnoreRequest": 255 + } + } + Enum { + name: "NavigationType" + values: { + "LinkClickedNavigation": 0, + "TypedNavigation": 1, + "FormSubmittedNavigation": 2, + "BackForwardNavigation": 3, + "ReloadNavigation": 4, + "OtherNavigation": 5 + } + } + Enum { + name: "LoadStatus" + values: { + "LoadStartedStatus": 0, + "LoadStoppedStatus": 1, + "LoadSucceededStatus": 2, + "LoadFailedStatus": 3 + } + } + Enum { + name: "ErrorDomain" + values: { + "NoErrorDomain": 0, + "InternalErrorDomain": 1, + "ConnectionErrorDomain": 2, + "CertificateErrorDomain": 3, + "HttpErrorDomain": 4, + "FtpErrorDomain": 5, + "DnsErrorDomain": 6 + } + } + Enum { + name: "NewViewDestination" + values: { + "NewViewInWindow": 0, + "NewViewInTab": 1, + "NewViewInDialog": 2 + } + } + Enum { + name: "JavaScriptConsoleMessageLevel" + values: { + "InfoMessageLevel": 0, + "WarningMessageLevel": 1, + "ErrorMessageLevel": 2 + } + } + Property { name: "url"; type: "QUrl" } + Property { name: "icon"; type: "QUrl"; isReadonly: true } + Property { name: "loading"; type: "bool"; isReadonly: true } + Property { name: "loadProgress"; type: "int"; isReadonly: true } + Property { name: "title"; type: "string"; isReadonly: true } + Property { name: "canGoBack"; type: "bool"; isReadonly: true } + Property { name: "canGoForward"; type: "bool"; isReadonly: true } + Signal { + name: "loadingChanged" + Parameter { name: "loadRequest"; type: "QQuickWebEngineLoadRequest"; isPointer: true } + } + Signal { + name: "linkHovered" + Parameter { name: "hoveredUrl"; type: "QUrl" } + } + Signal { + name: "navigationRequested" + Parameter { name: "request"; type: "QQuickWebEngineNavigationRequest"; isPointer: true } + } + Signal { + name: "javaScriptConsoleMessage" + Parameter { name: "level"; type: "JavaScriptConsoleMessageLevel" } + Parameter { name: "message"; type: "string" } + Parameter { name: "lineNumber"; type: "int" } + Parameter { name: "sourceID"; type: "string" } + } + Method { + name: "runJavaScript" + Parameter { type: "string" } + Parameter { type: "QJSValue" } + } + Method { + name: "runJavaScript" + Parameter { type: "string" } + } + Method { + name: "loadHtml" + Parameter { name: "html"; type: "string" } + Parameter { name: "baseUrl"; type: "QUrl" } + } + Method { + name: "loadHtml" + Parameter { name: "html"; type: "string" } + } + Method { name: "goBack" } + Method { name: "goForward" } + Method { name: "reload" } + Method { name: "stop" } + } +} |