diff options
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 34 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 4 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 2 |
3 files changed, 40 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 { diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index 5db15e873..e26e4f360 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -92,6 +92,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem { Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1) Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL) Q_PROPERTY(bool activeFocusOnPress READ activeFocusOnPress WRITE setActiveFocusOnPress NOTIFY activeFocusOnPressChanged REVISION 2) + Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 3) #ifdef ENABLE_QML_TESTSUPPORT_API Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL) @@ -122,6 +123,8 @@ public: bool isFullScreen() const; qreal zoomFactor() const; void setZoomFactor(qreal arg); + QColor backgroundColor() const; + void setBackgroundColor(const QColor &color); QQuickWebEngineViewExperimental *experimental() const; @@ -274,6 +277,7 @@ Q_SIGNALS: Q_REVISION(1) void profileChanged(); Q_REVISION(1) void webChannelChanged(); Q_REVISION(2) void activeFocusOnPressChanged(bool); + Q_REVISION(3) void backgroundColorChanged(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 7e411d349..4d95de84e 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -123,6 +123,7 @@ public: virtual void selectionChanged() Q_DECL_OVERRIDE { } virtual QRectF viewportRect() const Q_DECL_OVERRIDE; virtual qreal dpiScale() const Q_DECL_OVERRIDE; + virtual QColor backgroundColor() const Q_DECL_OVERRIDE; virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE; virtual void loadCommitted() Q_DECL_OVERRIDE; virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE; @@ -194,6 +195,7 @@ private: QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager; QList<QQuickWebEngineScript *> m_userScripts; qreal m_dpiScale; + QColor m_backgroundColor; }; #ifndef QT_NO_ACCESSIBILITY |