diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 98b0b7220..27b68a318 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -27,6 +27,7 @@ Added - Proxy support for QtWebEngine with Qt >= 5.8 - Support for the `content -> cookies-store` option with QtWebEngine - Support for the `storage -> cache-size` option with QtWebEngine +- Support for the `colors -> webpage.bg` option with QtWebEngine - Support for the HTML5 fullscreen API (e.g. youtube videos) with QtWebEngine Changed diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index f365df7b3..63503d049 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -2151,8 +2151,6 @@ Background color for webpages if unset (or empty to use the theme's color) Default: +pass:[white]+ -This setting is only available with the QtWebKit backend. - [[colors-keyhint.fg]] === keyhint.fg Text color for the keyhint widget. diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index f3e9d6a94..2d9c2eb0a 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -23,6 +23,7 @@ import os import functools from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, PYQT_VERSION +from PyQt5.QtGui import QPalette # pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage # pylint: enable=no-name-in-module,import-error,useless-suppression @@ -31,7 +32,7 @@ from qutebrowser.browser import shared from qutebrowser.browser.webengine import certificateerror from qutebrowser.config import config from qutebrowser.utils import (log, debug, usertypes, qtutils, jinja, urlutils, - message) + message, objreg) class WebEngineView(QWebEngineView): @@ -42,7 +43,10 @@ class WebEngineView(QWebEngineView): super().__init__(parent) self._win_id = win_id self._tabdata = tabdata - self.setPage(WebEnginePage(parent=self)) + + theme_color = self.style().standardPalette().color(QPalette.Base) + page = WebEnginePage(theme_color=theme_color, parent=self) + self.setPage(page) def shutdown(self): self.page().shutdown() @@ -127,6 +131,7 @@ class WebEnginePage(QWebEnginePage): Attributes: _is_shutting_down: Whether the page is currently shutting down. + _theme_color: The theme background color. Signals: certificate_error: Emitted on certificate errors. @@ -136,11 +141,21 @@ class WebEnginePage(QWebEnginePage): certificate_error = pyqtSignal() shutting_down = pyqtSignal() - def __init__(self, parent=None): + def __init__(self, theme_color, parent=None): super().__init__(parent) self._is_shutting_down = False self.featurePermissionRequested.connect( self._on_feature_permission_requested) + self._theme_color = theme_color + self._set_bg_color() + objreg.get('config').changed.connect(self._set_bg_color) + + @config.change_filter('colors', 'webpage.bg') + def _set_bg_color(self): + col = config.get('colors', 'webpage.bg') + if col is None: + col = self._theme_color + self.setBackgroundColor(col) @pyqtSlot(QUrl, 'QWebEnginePage::Feature') def _on_feature_permission_requested(self, url, feature): diff --git a/qutebrowser/browser/webkit/webview.py b/qutebrowser/browser/webkit/webview.py index 6494b04b8..12670be4f 100644 --- a/qutebrowser/browser/webkit/webview.py +++ b/qutebrowser/browser/webkit/webview.py @@ -108,11 +108,7 @@ class WebView(QWebView): @config.change_filter('colors', 'webpage.bg') def _set_bg_color(self): - """Set the webpage background color as configured. - - FIXME:qtwebengine - For QtWebEngine, doing the same has no effect, so we do it in here. - """ + """Set the webpage background color as configured.""" col = config.get('colors', 'webpage.bg') palette = self.palette() if col is None: diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index d08766af5..d27a3763a 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1274,8 +1274,7 @@ def data(readonly=False): "Background color for downloads with errors."), ('webpage.bg', - SettingValue(typ.QtColor(none_ok=True), 'white', - backends=[usertypes.Backend.QtWebKit]), + SettingValue(typ.QtColor(none_ok=True), 'white'), "Background color for webpages if unset (or empty to use the " "theme's color)"),