diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-07 19:33:24 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-07 19:33:24 +0100 |
commit | a0fd64727bb98b815b318cc537954b3d0d1651bb (patch) | |
tree | b772d13a66f8bed389e92d61a154e75b9ce6df6d | |
parent | cafb5c371ff31c5d55617c7e4013215415cee214 (diff) | |
parent | 1f91d5c472dee19ec8c8eb2cf9f8a1375ab45a48 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I523562cca4edc403c387d54ee8e505f5d2c5195b
-rw-r--r-- | examples/webview/minibrowser/ios/Info.plist | 41 | ||||
-rw-r--r-- | examples/webview/minibrowser/main.qml | 2 | ||||
-rw-r--r-- | examples/webview/minibrowser/minibrowser.pro | 2 | ||||
-rw-r--r-- | src/imports/imports.pro | 11 | ||||
-rw-r--r-- | src/imports/webview.cpp | 15 | ||||
-rw-r--r-- | src/webview/qquickwebview.cpp | 9 | ||||
-rw-r--r-- | src/webview/qquickwebview_p.h | 3 | ||||
-rw-r--r-- | src/webview/qwebview_default.cpp | 45 | ||||
-rw-r--r-- | src/webview/qwebview_ios.mm | 28 | ||||
-rw-r--r-- | src/webview/qwebview_p.h | 2 | ||||
-rw-r--r-- | src/webview/qwebview_webengine.cpp | 259 | ||||
-rw-r--r-- | src/webview/qwebview_webengine_p.h | 108 | ||||
-rw-r--r-- | src/webview/webview-lib.pri | 9 | ||||
-rw-r--r-- | tests/auto/qml/qquickwebview/tst_qquickwebview.cpp | 2 |
14 files changed, 458 insertions, 78 deletions
diff --git a/examples/webview/minibrowser/ios/Info.plist b/examples/webview/minibrowser/ios/Info.plist new file mode 100644 index 0000000..9b06537 --- /dev/null +++ b/examples/webview/minibrowser/ios/Info.plist @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleExecutable</key> + <string>minibrowser</string> + <key>CFBundleIdentifier</key> + <string>sd.${PRODUCT_NAME:rfc1034identifier}</string> + <key>CFBundleDisplayName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>LSRequiresIPhoneOS</key> + <true/> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> + <key>UISupportedInterfaceOrientations</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationPortraitUpsideDown</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> + <key>NSAppTransportSecurity</key> + <!-- NOTE! For more information, see: https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33--> + <dict> + <key>NSAllowsArbitraryLoads</key> + <true/> + </dict> +</dict> +</plist> diff --git a/examples/webview/minibrowser/main.qml b/examples/webview/minibrowser/main.qml index 3bb834a..4ca09f1 100644 --- a/examples/webview/minibrowser/main.qml +++ b/examples/webview/minibrowser/main.qml @@ -115,7 +115,7 @@ ApplicationWindow { visible: showProgress minimumValue: 0 maximumValue: 100 - value: webView.loadProgress > 100 ? 0 : webView.loadProgress + value: webView.loadProgress == 100 ? 0 : webView.loadProgress } } diff --git a/examples/webview/minibrowser/minibrowser.pro b/examples/webview/minibrowser/minibrowser.pro index 827e87b..be7a348 100644 --- a/examples/webview/minibrowser/minibrowser.pro +++ b/examples/webview/minibrowser/minibrowser.pro @@ -11,5 +11,7 @@ RESOURCES += qml.qrc EXAMPLE_FILES += doc +ios:QMAKE_INFO_PLIST = ios/Info.plist + target.path = $$[QT_INSTALL_EXAMPLES]/webview/minibrowser INSTALLS += target diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 8686784..197f25b 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -3,19 +3,10 @@ TARGET = declarative_webview TARGETPATH = QtWebView IMPORT_VERSION = 1.0 -QT += qml quick +QT += qml quick webview-private SOURCES += \ $$PWD/webview.cpp -android|ios|winrt|osx_webview_experimental { - QT += webview-private -} else:qtHaveModule(webengine) { - QT += webengine webengine-private - DEFINES += QT_WEBVIEW_WEBENGINE_BACKEND -} else { - error(No WebView backend found!) -} - load(qml_plugin) OTHER_FILES += qmldir diff --git a/src/imports/webview.cpp b/src/imports/webview.cpp index b30ad77..22c80a1 100644 --- a/src/imports/webview.cpp +++ b/src/imports/webview.cpp @@ -37,14 +37,8 @@ #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> - -#if defined(QT_WEBVIEW_WEBENGINE_BACKEND) -# include <QtWebEngine/private/qquickwebengineloadrequest_p.h> -# include <QtWebEngine/private/qquickwebengineview_p.h> -#else -# include <QtWebView/private/qquickwebviewloadrequest_p.h> -# include <QtWebView/private/qquickwebview_p.h> -#endif // QT_WEBVIEW_WEBENGINE_BACKEND +#include <QtWebView/private/qquickwebviewloadrequest_p.h> +#include <QtWebView/private/qquickwebview_p.h> QT_BEGIN_NAMESPACE @@ -59,14 +53,9 @@ public: // @uri QtWebView const QString &msg = QObject::tr("Cannot create separate instance of WebViewLoadRequest"); -#if defined(QT_WEBVIEW_WEBENGINE_BACKEND) - qmlRegisterType<QQuickWebEngineView>(uri, 1, 0, "WebView"); - qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 1, "WebViewLoadRequest", msg); -#else qmlRegisterType<QQuickWebView>(uri, 1, 0, "WebView"); qmlRegisterType<QQuickWebView, 1>(uri, 1, 1, "WebView"); qmlRegisterUncreatableType<QQuickWebViewLoadRequest>(uri, 1, 1, "WebViewLoadRequest", msg); -#endif } void initializeEngine(QQmlEngine *engine, const char *uri) diff --git a/src/webview/qquickwebview.cpp b/src/webview/qquickwebview.cpp index 8a97d80..1729f83 100644 --- a/src/webview/qquickwebview.cpp +++ b/src/webview/qquickwebview.cpp @@ -111,6 +111,8 @@ QQuickWebView::~QQuickWebView() The URL is used as-is. URLs that originate from user input should be parsed with QUrl::fromUserInput(). + + \note The WebView does not support loading content through the Qt Resource system. */ void QQuickWebView::setUrl(const QUrl &url) @@ -253,6 +255,8 @@ void QQuickWebView::stop() is the base URL, then an image referenced with the relative url, \c diagram.png, should be at \c{http://www.example.com/documents/diagram.png}. + \note The WebView does not support loading content through the Qt Resource system. + \sa url */ void QQuickWebView::loadHtml(const QString &html, const QUrl &baseUrl) @@ -313,3 +317,8 @@ void QQuickWebView::onLoadingChanged(const QWebViewLoadRequestPrivate &loadReque QQuickWebViewLoadRequest qqLoadRequest(loadRequest); Q_EMIT loadingChanged(&qqLoadRequest); } + +QJSValue QQuickWebView::takeCallback(int id) +{ + return callbacks->takeCallback(id); +} diff --git a/src/webview/qquickwebview_p.h b/src/webview/qquickwebview_p.h index 236a06e..3d1a432 100644 --- a/src/webview/qquickwebview_p.h +++ b/src/webview/qquickwebview_p.h @@ -112,6 +112,9 @@ private Q_SLOTS: void onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest); private: + friend class QWebEngineWebViewPrivate; + static QJSValue takeCallback(int id); + QWebView* m_webView; }; diff --git a/src/webview/qwebview_default.cpp b/src/webview/qwebview_default.cpp deleted file mode 100644 index 5f56b6a..0000000 --- a/src/webview/qwebview_default.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtWebView module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwebview_global.h" - -QT_BEGIN_NAMESPACE - -struct QWebView {}; -struct Q_WEBVIEW_EXPORT QWebViewPrivate { static QWebViewPrivate *create(QWebView *q); }; -QWebViewPrivate *QWebViewPrivate::create(QWebView *) { return 0; } - -QT_END_NAMESPACE diff --git a/src/webview/qwebview_ios.mm b/src/webview/qwebview_ios.mm index f622b6b..ef0865b 100644 --- a/src/webview/qwebview_ios.mm +++ b/src/webview/qwebview_ios.mm @@ -38,7 +38,8 @@ #include "qwebview_p.h" #include "qwebviewloadrequest_p.h" -#include <QtQuick/qquickitem.h> +#include <QtQuick/qquickwindow.h> +#include <QtQuick/qquickrendercontrol.h> #include <QtCore/qmap.h> #include <CoreFoundation/CoreFoundation.h> @@ -252,9 +253,11 @@ void QIosWebViewPrivate::setParentView(QObject *view) if (!uiWebView) return; - QWindow *window = qobject_cast<QWindow *>(view); - if (window != 0) { - UIView *parentView = reinterpret_cast<UIView *>(window->winId()); + QQuickWindow *qw = qobject_cast<QQuickWindow *>(view); + if (qw) { + // Before setting the parent view, make sure we have the real window. + QWindow *rw = QQuickRenderControl::renderWindowFor(qw); + UIView *parentView = reinterpret_cast<UIView *>(rw ? rw->winId() : qw->winId()); [parentView addSubview:uiWebView]; } else { [uiWebView removeFromSuperview]; @@ -268,7 +271,22 @@ QObject *QIosWebViewPrivate::parentView() const void QIosWebViewPrivate::setGeometry(const QRect &geometry) { - [uiWebView setFrame:toCGRect(geometry)]; + if (!uiWebView) + return; + + QWindow *w = qobject_cast<QWindow *>(m_parentView); + if (w == 0) + return; + + // Find the top left position of this item in global coordinates. + const QPoint &tl = w->mapToGlobal(geometry.topLeft()); + // Map the top left position to the render windows coordinates. + QQuickWindow *qw = qobject_cast<QQuickWindow *>(m_parentView); + QWindow *rw = QQuickRenderControl::renderWindowFor(qw); + // New geometry + const QRect &newGeometry = rw ? QRect(rw->mapFromGlobal(tl), geometry.size()) : geometry; + // Sets location and size in the superviews coordinate system. + [uiWebView setFrame:toCGRect(newGeometry)]; } void QIosWebViewPrivate::setVisibility(QWindow::Visibility visibility) diff --git a/src/webview/qwebview_p.h b/src/webview/qwebview_p.h index c4b3fdf..abc8bbf 100644 --- a/src/webview/qwebview_p.h +++ b/src/webview/qwebview_p.h @@ -108,7 +108,7 @@ Q_SIGNALS: void requestFocus(bool focus); protected: - void init(); + void init() Q_DECL_OVERRIDE; void runJavaScriptPrivate(const QString &script, int callbackId) Q_DECL_OVERRIDE; diff --git a/src/webview/qwebview_webengine.cpp b/src/webview/qwebview_webengine.cpp new file mode 100644 index 0000000..ca782bb --- /dev/null +++ b/src/webview/qwebview_webengine.cpp @@ -0,0 +1,259 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebView module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebview_webengine_p.h" +#include "qwebview_p.h" +#include "qwebviewloadrequest_p.h" + +#include <QtWebView/private/qquickwebview_p.h> + +#include <QtCore/qmap.h> +#include <QtGui/qguiapplication.h> +#include <QtCore/qjsondocument.h> +#include <QtCore/qjsonobject.h> +#include <QtCore/qurl.h> +#include <QtCore/qdebug.h> +#include <QtCore/qrunnable.h> + +#include <QtQuick/qquickwindow.h> +#include <QtQuick/qquickview.h> +#include <QtQuick/qquickitem.h> + +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcontext.h> + +#include <QtWebEngine/private/qquickwebengineview_p.h> +#include <QtWebEngine/private/qquickwebengineloadrequest_p.h> + +QT_BEGIN_NAMESPACE + +static QByteArray qmlSource() +{ + return QByteArrayLiteral("import QtWebEngine 1.1\n" + " WebEngineView {\n" + "}\n"); +} + +QWebViewPrivate *QWebViewPrivate::create(QWebView *q) +{ + return new QWebEngineWebViewPrivate(q); +} + +QWebEngineWebViewPrivate::QWebEngineWebViewPrivate(QObject *p) + : QWebViewPrivate(p) + , m_webEngineView(0) +{ + +} + +QWebEngineWebViewPrivate::~QWebEngineWebViewPrivate() +{ +} + +QUrl QWebEngineWebViewPrivate::url() const +{ + if (!m_webEngineView) + return QUrl(); + + return m_webEngineView->url(); +} + +void QWebEngineWebViewPrivate::setUrl(const QUrl &url) +{ + if (m_webEngineView) + m_webEngineView->setUrl(url); +} + +void QWebEngineWebViewPrivate::loadHtml(const QString &html, const QUrl &baseUrl) +{ + if (m_webEngineView) + m_webEngineView->loadHtml(html, baseUrl); +} + +bool QWebEngineWebViewPrivate::canGoBack() const +{ + if (!m_webEngineView) + return false; + + return m_webEngineView->canGoBack(); +} + +void QWebEngineWebViewPrivate::goBack() +{ + if (m_webEngineView) + m_webEngineView->goBack(); +} + +bool QWebEngineWebViewPrivate::canGoForward() const +{ + if (!m_webEngineView) + return false; + + return m_webEngineView->canGoForward(); +} + +void QWebEngineWebViewPrivate::goForward() +{ + if (m_webEngineView) + m_webEngineView->goForward(); +} + +void QWebEngineWebViewPrivate::reload() +{ + if (m_webEngineView) + m_webEngineView->reload(); +} + +QString QWebEngineWebViewPrivate::title() const +{ + if (!m_webEngineView) + return QString(); + + return m_webEngineView->title(); +} + +void QWebEngineWebViewPrivate::setGeometry(const QRect &geometry) +{ + if (m_webEngineView) + m_webEngineView->setSize(geometry.size()); +} + +void QWebEngineWebViewPrivate::setVisibility(QWindow::Visibility visibility) +{ + setVisible(visibility != QWindow::Hidden ? true : false); +} + +void QWebEngineWebViewPrivate::runJavaScriptPrivate(const QString &script, + int callbackId) +{ + if (m_webEngineView) + m_webEngineView->runJavaScript(script, QQuickWebView::takeCallback(callbackId)); +} + +void QWebEngineWebViewPrivate::setVisible(bool visible) +{ + if (m_webEngineView) + m_webEngineView->setVisible(visible); +} + +int QWebEngineWebViewPrivate::loadProgress() const +{ + if (!m_webEngineView) + return 0; + + return m_webEngineView->loadProgress(); +} + +bool QWebEngineWebViewPrivate::isLoading() const +{ + if (!m_webEngineView) + return false; + + return m_webEngineView->isLoading(); +} + +void QWebEngineWebViewPrivate::setParentView(QObject *parentView) +{ + if (m_webEngineView != 0 || parentView == 0) + return; + + QObject *p = parent(); + QQuickItem *parentItem = 0; + while (p != 0) { + p = p->parent(); + parentItem = qobject_cast<QQuickWebView *>(p); + if (parentItem != 0) + break; + } + + if (!parentItem) + return; + + QQmlContext *ctx = QQmlEngine::contextForObject(parentItem); + if (!ctx) + return; + + QQmlEngine *engine = ctx->engine(); + if (!engine) + return; + + QQmlComponent *component = new QQmlComponent(engine); + component->setData(qmlSource(), QUrl::fromLocalFile(QLatin1String(""))); + QQuickWebEngineView *webEngineView = qobject_cast<QQuickWebEngineView *>(component->create()); + connect(webEngineView, &QQuickWebEngineView::urlChanged, this, &QWebEngineWebViewPrivate::q_urlChanged); + connect(webEngineView, &QQuickWebEngineView::loadProgressChanged, this, &QWebEngineWebViewPrivate::q_loadProgressChanged); + connect(webEngineView, &QQuickWebEngineView::loadingChanged, this, &QWebEngineWebViewPrivate::q_loadingChanged); + connect(webEngineView, &QQuickWebEngineView::titleChanged, this, &QWebEngineWebViewPrivate::q_titleChanged); + webEngineView->setParentItem(parentItem); + m_webEngineView.reset(webEngineView); +} + +QObject *QWebEngineWebViewPrivate::parentView() const +{ + return m_webEngineView ? m_webEngineView->window() : 0; +} + +void QWebEngineWebViewPrivate::stop() +{ + if (m_webEngineView) + m_webEngineView->stop(); +} + +void QWebEngineWebViewPrivate::q_urlChanged() +{ + Q_EMIT urlChanged(m_webEngineView->url()); +} + +void QWebEngineWebViewPrivate::q_loadProgressChanged() +{ + Q_EMIT loadProgressChanged(m_webEngineView->loadProgress()); +} + +void QWebEngineWebViewPrivate::q_titleChanged() +{ + Q_EMIT titleChanged(m_webEngineView->title()); +} + +void QWebEngineWebViewPrivate::q_loadingChanged(QQuickWebEngineLoadRequest *loadRequest) +{ + QWebViewLoadRequestPrivate lr(loadRequest->url(), + static_cast<QWebView::LoadStatus>(loadRequest->status()), // These "should" match... + loadRequest->errorString()); + + Q_EMIT loadingChanged(lr); +} + +QT_END_NAMESPACE diff --git a/src/webview/qwebview_webengine_p.h b/src/webview/qwebview_webengine_p.h new file mode 100644 index 0000000..f1f7b05 --- /dev/null +++ b/src/webview/qwebview_webengine_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebView module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBVIEW_ANDROID_P_H +#define QWEBVIEW_ANDROID_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtGui/qwindow.h> + +#include <QtQml/qqmlcomponent.h> + +#include "qwebview_p_p.h" + +QT_BEGIN_NAMESPACE + +class QQuickWebEngineView; +class QQuickWebEngineLoadRequest; + +class QWebEngineWebViewPrivate : public QWebViewPrivate +{ + Q_OBJECT +public: + explicit QWebEngineWebViewPrivate(QObject *p = 0); + ~QWebEngineWebViewPrivate() Q_DECL_OVERRIDE; + + QUrl url() const Q_DECL_OVERRIDE; + void setUrl(const QUrl &url) Q_DECL_OVERRIDE; + bool canGoBack() const Q_DECL_OVERRIDE; + bool canGoForward() const Q_DECL_OVERRIDE; + QString title() const Q_DECL_OVERRIDE; + int loadProgress() const Q_DECL_OVERRIDE; + bool isLoading() const Q_DECL_OVERRIDE; + + void setParentView(QObject *parentView) Q_DECL_OVERRIDE; + QObject *parentView() const Q_DECL_OVERRIDE; + void setGeometry(const QRect &geometry) Q_DECL_OVERRIDE; + void setVisibility(QWindow::Visibility visibility) Q_DECL_OVERRIDE; + void setVisible(bool visible) Q_DECL_OVERRIDE; + +public Q_SLOTS: + void goBack() Q_DECL_OVERRIDE; + void goForward() Q_DECL_OVERRIDE; + void reload() Q_DECL_OVERRIDE; + void stop() Q_DECL_OVERRIDE; + void loadHtml(const QString &html, const QUrl &baseUrl = QUrl()) Q_DECL_OVERRIDE; + +private Q_SLOTS: + void q_urlChanged(); + void q_loadProgressChanged(); + void q_titleChanged(); + void q_loadingChanged(QQuickWebEngineLoadRequest *loadRequest); + +protected: + void runJavaScriptPrivate(const QString& script, + int callbackId) Q_DECL_OVERRIDE; + +private: + QScopedPointer<QQuickWebEngineView> m_webEngineView; +}; + +QT_END_NAMESPACE + +#endif // QWEBVIEW_ANDROID_P_H diff --git a/src/webview/webview-lib.pri b/src/webview/webview-lib.pri index 3c6acda..e48c728 100644 --- a/src/webview/webview-lib.pri +++ b/src/webview/webview-lib.pri @@ -69,10 +69,13 @@ android { qwebview_winrt_p.h } else:qtHaveModule(webengine) { QT += webengine webengine-private - DEFINES += QT_WEBVIEW_WEBENGINE_BACKEND SOURCES += \ - qwebview_default.cpp - + $$COMMON_SOURCES \ + qwebview_webengine.cpp + PRIVATE_HEADERS += \ + $$COMMON_HEADERS \ + qwebview_webengine_p.h + DEFINES += QT_WEBVIEW_WEBENGINE_BACKEND } HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS diff --git a/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp b/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp index fd1f0d0..e3162bc 100644 --- a/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp +++ b/tests/auto/qml/qquickwebview/tst_qquickwebview.cpp @@ -26,6 +26,7 @@ #include <QtWebView/private/qquickwebview_p.h> #include <QtCore/qfile.h> #include <QtCore/qstandardpaths.h> +#include <QtWebView/qtwebviewfunctions.h> QString getTestFilePath(const QString &testFile) { @@ -95,6 +96,7 @@ QQuickWebView *tst_QQuickWebView::newWebView() void tst_QQuickWebView::init() { + QtWebView::initialize(); m_window.reset(new TestWindow(newWebView())); } |