diff options
author | Jocelyn Turcotte <jturcotte@woboq.com> | 2015-07-09 21:52:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-07-14 13:06:19 +0000 |
commit | 99e98f7bf6aec78fe0d647fb898e65d13ff522e4 (patch) | |
tree | 64a38d99e5f6287e80f92df1d9ac125cc2325b87 /src/webengine/api/qquickwebengineview.cpp | |
parent | 8d6b933a971476abe91e72728d997aa5dd2a71be (diff) | |
download | qtwebengine-99e98f7bf6aec78fe0d647fb898e65d13ff522e4.tar.gz |
Add a backgroundColor property
This also allows setting a transparent color to see through
the web view's body if its background color isn't specified.
The color is initially held by the top API view and is pulled
by the WebContentsAdapter in order to set it on the RenderView.
Since both blink and our local compositors (in the QOpenGLWidget
case) need to know about this color, RWHVQt takes care of pushing
it to both. The former through an IPC message and the latter
directly on the RWHVQtDelegate.
Task-number: QTBUG-41960
Change-Id: Ie13317b2d087f5612ad9c5fb0e05ca3e91aec9af
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
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, 34 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index eea584d4d..1f5e56bdb 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -108,6 +108,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() , m_activeFocusOnPress(true) , devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio()) , m_dpiScale(1.0) + , m_backgroundColor(Qt::white) { // The gold standard for mobile web content is 160 dpi, and the devicePixelRatio expected // is the (possibly quantized) ratio of device dpi to 160 dpi. @@ -365,6 +366,11 @@ qreal QQuickWebEngineViewPrivate::dpiScale() const return m_dpiScale; } +QColor QQuickWebEngineViewPrivate::backgroundColor() const +{ + return m_backgroundColor; +} + void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage) { Q_Q(QQuickWebEngineView); @@ -928,6 +934,34 @@ qreal QQuickWebEngineView::zoomFactor() const return d->adapter->currentZoomFactor(); } +/*! + \qmlproperty bool WebEngineView::backgroundColor + \since QtWebEngine 1.3 + + Sets this property to change the color of the WebEngineView's background, + behing the document's body. You can set it to "transparent" or to a translucent + color to see through the document, or you can set this color to match your + web content in an hybrid app to prevent the white flashes that may appear + during loading. + + The default value is white. +*/ +QColor QQuickWebEngineView::backgroundColor() const +{ + Q_D(const QQuickWebEngineView); + return d->m_backgroundColor; +} + +void QQuickWebEngineView::setBackgroundColor(const QColor &color) +{ + Q_D(QQuickWebEngineView); + if (color == d->m_backgroundColor) + return; + d->m_backgroundColor = color; + d->ensureContentsAdapter(); + d->adapter->backgroundColorChanged(); + emit backgroundColorChanged(); +} bool QQuickWebEngineView::isFullScreen() const { |