From 99e98f7bf6aec78fe0d647fb898e65d13ff522e4 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 9 Jul 2015 21:52:43 +0200 Subject: 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 Reviewed-by: Andras Becsi --- src/webenginewidgets/api/qwebenginepage.cpp | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/webenginewidgets/api/qwebenginepage.cpp') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index f93227297..e7d4e60e5 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -87,6 +87,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , view(0) , isLoading(false) , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data())) + , m_backgroundColor(Qt::white) { memset(actions, 0, sizeof(actions)); } @@ -149,6 +150,11 @@ qreal QWebEnginePagePrivate::dpiScale() const return 1.0; } +QColor QWebEnginePagePrivate::backgroundColor() const +{ + return m_backgroundColor; +} + void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage) { Q_UNUSED(provisionalUrl); @@ -433,6 +439,33 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel) d->adapter->setWebChannel(channel); } +/*! + \property QWebEnginePage::backgroundColor + \brief the page's background color, behing the document's body. + \since 5.6 + + You can set it to Qt::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 QWebEnginePage::backgroundColor() const +{ + Q_D(const QWebEnginePage); + return d->m_backgroundColor; +} + +void QWebEnginePage::setBackgroundColor(const QColor &color) +{ + Q_D(QWebEnginePage); + if (d->m_backgroundColor == color) + return; + d->m_backgroundColor = color; + d->adapter->backgroundColorChanged(); +} + void QWebEnginePage::setView(QWidget *view) { QWebEngineViewPrivate::bind(qobject_cast(view), this); -- cgit v1.2.1