diff options
author | Pierre Rossi <pierre.rossi@theqtcompany.com> | 2015-02-12 16:43:23 +0100 |
---|---|---|
committer | Pierre Rossi <pierre.rossi@theqtcompany.com> | 2015-02-13 14:11:31 +0000 |
commit | ebe4b5da40d8784351821ae0ba173f357bb519f8 (patch) | |
tree | f4a6d76a9ac536d71db046f511383da3ae5ffc03 /src/webengine/api/qquickwebengineview.cpp | |
parent | 53876e63be3a5aa1de038e3ecd593fdac721b78d (diff) | |
download | qtwebengine-ebe4b5da40d8784351821ae0ba173f357bb519f8.tar.gz |
Move webChannel property out of experimental
Add a notify signal to go with the setter.
Parent the default-provided channel to the view.
Comes with basic documentation.
Change-Id: I2bde8153df5928fc92ac36b7fa4d4b3b1da22f53
Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/webengine/api/qquickwebengineview.cpp')
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index a47defb7c..e70e7f790 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -812,21 +812,39 @@ QQuickWebEngineHistory *QQuickWebEngineViewExperimental::navigationHistory() con return d_ptr->m_history.data(); } -QQmlWebChannel *QQuickWebEngineViewExperimental::webChannel() const +/*! + * \qmlproperty QQmlWebChannel WebEngineView::webChannel + * \since QtWebEngine 1.1 + * + * The web channel instance used by this view. + * This channel is automatically using the internal QtWebEngine transport mechanism over Chromium IPC, + * and exposed in the javascript context of the page it is rendering as \c navigator.qtWebChannelTransport. + * This transport object is used when instantiating the JavaScript counterpart of QWebChannel using + * the \l{Qt WebChannel JavaScript API}. + * + * \note The view does not take ownership when explicitly setting a webChannel object. + */ + +QQmlWebChannel *QQuickWebEngineView::webChannel() { - d_ptr->ensureContentsAdapter(); - QQmlWebChannel *qmlWebChannel = qobject_cast<QQmlWebChannel *>(d_ptr->adapter->webChannel()); - Q_ASSERT(!d_ptr->adapter->webChannel() || qmlWebChannel); + Q_D(QQuickWebEngineView); + d->ensureContentsAdapter(); + QQmlWebChannel *qmlWebChannel = qobject_cast<QQmlWebChannel *>(d->adapter->webChannel()); + Q_ASSERT(!d->adapter->webChannel() || qmlWebChannel); if (!qmlWebChannel) { - qmlWebChannel = new QQmlWebChannel; - d_ptr->adapter->setWebChannel(qmlWebChannel); + qmlWebChannel = new QQmlWebChannel(this); + d->adapter->setWebChannel(qmlWebChannel); } return qmlWebChannel; } -void QQuickWebEngineViewExperimental::setWebChannel(QQmlWebChannel *webChannel) +void QQuickWebEngineView::setWebChannel(QQmlWebChannel *webChannel) { - d_ptr->adapter->setWebChannel(webChannel); + Q_D(QQuickWebEngineView); + bool notify = (d->adapter->webChannel() == webChannel); + d->adapter->setWebChannel(webChannel); + if (notify) + Q_EMIT webChannelChanged(); } void QQuickWebEngineViewExperimental::grantFeaturePermission(const QUrl &securityOrigin, QQuickWebEngineViewExperimental::Feature feature, bool granted) |