From 76ec465f6703bc7daa81ccb71a8331474dc99489 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 28 Apr 2017 17:39:36 +0200 Subject: [PATCH] Allow to set cookies-store at runtime with Qt 5.9 Fixes #2588 --- CHANGELOG.asciidoc | 2 ++ doc/help/settings.asciidoc | 4 ++-- qutebrowser/browser/webengine/webenginesettings.py | 14 +++++++++----- qutebrowser/config/configdata.py | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 5ec1d26be..dd79a1b2b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -50,6 +50,8 @@ Changed - When ui -> message-timeout is set to 0, messages are now never cleared. - Middle/right-clicking the blank parts of the tab bar (when vertical) now closes the current tab. +- With Qt 5.9, `content -> cookies-store` can now be set on QtWebEngine without + a restart. Fixed ~~~~~ diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 68ca0a118..b2479f959 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -175,7 +175,7 @@ |<>|Whether locally loaded documents are allowed to access remote urls. |<>|Whether locally loaded documents are allowed to access other local urls. |<>|Control which cookies to accept. -|<>|Whether to store cookies. Note this option needs a restart with QtWebEngine. +|<>|Whether to store cookies. Note this option needs a restart with QtWebEngine on Qt < 5.9. |<>|List of URLs of lists which contain hosts to block. |<>|Whether host blocking is enabled. |<>|List of domains that should always be loaded, despite being ad-blocked. @@ -1616,7 +1616,7 @@ This setting is only available with the QtWebKit backend. [[content-cookies-store]] === cookies-store -Whether to store cookies. Note this option needs a restart with QtWebEngine. +Whether to store cookies. Note this option needs a restart with QtWebEngine on Qt < 5.9. Valid values: diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py index b029b4fd5..740db489b 100644 --- a/qutebrowser/browser/webengine/webenginesettings.py +++ b/qutebrowser/browser/webengine/webenginesettings.py @@ -34,7 +34,8 @@ from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile, from qutebrowser.browser import shared from qutebrowser.config import config, websettings -from qutebrowser.utils import objreg, utils, standarddir, javascript, log +from qutebrowser.utils import (objreg, utils, standarddir, javascript, log, + qtutils) class Attribute(websettings.Attribute): @@ -177,7 +178,8 @@ def init(args): _init_stylesheet(profile) # We need to do this here as a WORKAROUND for # https://bugreports.qt.io/browse/QTBUG-58650 - PersistentCookiePolicy().set(config.get('content', 'cookies-store')) + if not qtutils.version_check('5.9'): + PersistentCookiePolicy().set(config.get('content', 'cookies-store')) Attribute(QWebEngineSettings.FullScreenSupportEnabled).set(True) @@ -221,9 +223,6 @@ MAPPINGS = { Attribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls), 'local-content-can-access-file-urls': Attribute(QWebEngineSettings.LocalContentCanAccessFileUrls), - # https://bugreports.qt.io/browse/QTBUG-58650 - # 'cookies-store': - # PersistentCookiePolicy(), 'webgl': Attribute(QWebEngineSettings.WebGLEnabled), }, @@ -301,3 +300,8 @@ try: except AttributeError: # Added in Qt 5.8 pass + + +if qtutils.version_check('5.9'): + # https://bugreports.qt.io/browse/QTBUG-58650 + MAPPINGS['content']['cookies-store'] = PersistentCookiePolicy() diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 2de0c3eb2..347edc53f 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -915,7 +915,7 @@ def data(readonly=False): ('cookies-store', SettingValue(typ.Bool(), 'true'), "Whether to store cookies. Note this option needs a restart with " - "QtWebEngine."), + "QtWebEngine on Qt < 5.9."), ('host-block-lists', SettingValue(