QtWebEngine: Basic settings support

This commit is contained in:
Florian Bruhin 2016-08-03 11:35:08 +02:00
parent 2ee95df9e7
commit cae7eead6f
10 changed files with 331 additions and 45 deletions

View File

@ -367,6 +367,8 @@ Valid values:
Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[general-developer-extras]]
=== developer-extras
Enable extra tools for Web developers.
@ -380,6 +382,8 @@ Valid values:
Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[general-print-element-backgrounds]]
=== print-element-backgrounds
Whether the background color and images are also drawn when the page is printed.
@ -391,6 +395,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[general-xss-auditing]]
=== xss-auditing
Whether load requests should be monitored for cross-site scripting attempts.
@ -415,6 +421,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[general-default-encoding]]
=== default-encoding
Default encoding to use for websites.
@ -449,6 +457,8 @@ Valid values:
Default: +pass:[debug]+
This setting is only available with the QtWebKit backend.
[[general-save-session]]
=== save-session
Whether to always save the open pages.
@ -557,6 +567,8 @@ Valid values:
Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[ui-frame-flattening]]
=== frame-flattening
Whether to expand each subframe to its contents.
@ -570,18 +582,24 @@ Valid values:
Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[ui-user-stylesheet]]
=== user-stylesheet
User stylesheet to use (absolute filename, filename relative to the config directory or CSS string). Will expand environment variables.
Default: +pass:[::-webkit-scrollbar { width: 0px; height: 0px; }]+
This setting is only available with the QtWebKit backend.
[[ui-css-media-type]]
=== css-media-type
Set the CSS media type.
Default: empty
This setting is only available with the QtWebKit backend.
[[ui-smooth-scrolling]]
=== smooth-scrolling
Whether to enable smooth scrolling for webpages.
@ -685,12 +703,16 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[network-accept-language]]
=== accept-language
Value to send in the `accept-language` header.
Default: +pass:[en-US,en]+
This setting is only available with the QtWebKit backend.
[[network-referer-header]]
=== referer-header
Send the Referer header
@ -703,12 +725,16 @@ Valid values:
Default: +pass:[same-domain]+
This setting is only available with the QtWebKit backend.
[[network-user-agent]]
=== user-agent
User agent to send. Empty to send the default.
Default: empty
This setting is only available with the QtWebKit backend.
[[network-proxy]]
=== proxy
The proxy to use.
@ -722,6 +748,8 @@ Valid values:
Default: +pass:[system]+
This setting is only available with the QtWebKit backend.
[[network-proxy-dns-requests]]
=== proxy-dns-requests
Whether to send DNS requests over the configured proxy.
@ -733,6 +761,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[network-ssl-strict]]
=== ssl-strict
Whether to validate SSL handshakes.
@ -745,6 +775,8 @@ Valid values:
Default: +pass:[ask]+
This setting is only available with the QtWebKit backend.
[[network-dns-prefetch]]
=== dns-prefetch
Whether to try to pre-fetch DNS entries to speed up browsing.
@ -756,12 +788,16 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[network-custom-headers]]
=== custom-headers
Set custom headers for qutebrowser HTTP requests.
Default: empty
This setting is only available with the QtWebKit backend.
== completion
Options related to completion and command history.
@ -1224,6 +1260,8 @@ For more information about the feature, please refer to: http://webkit.org/blog/
Default: empty
This setting is only available with the QtWebKit backend.
[[storage-object-cache-capacities]]
=== object-cache-capacities
The capacities for the global memory cache for dead objects such as stylesheets or scripts. Syntax: cacheMinDeadCapacity, cacheMaxDead, totalCapacity.
@ -1236,18 +1274,24 @@ _totalCapacity_ specifies the maximum number of bytes that the cache should cons
Default: empty
This setting is only available with the QtWebKit backend.
[[storage-offline-storage-default-quota]]
=== offline-storage-default-quota
Default quota for new offline storage databases.
Default: empty
This setting is only available with the QtWebKit backend.
[[storage-offline-web-application-cache-quota]]
=== offline-web-application-cache-quota
Quota for the offline web application cache.
Default: empty
This setting is only available with the QtWebKit backend.
[[storage-offline-storage-database]]
=== offline-storage-database
Whether support for the HTML 5 offline storage feature is enabled.
@ -1259,6 +1303,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[storage-offline-web-application-storage]]
=== offline-web-application-storage
Whether support for the HTML 5 web application cache feature is enabled.
@ -1274,6 +1320,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[storage-local-storage]]
=== local-storage
Whether support for the HTML 5 local storage feature is enabled.
@ -1351,6 +1399,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[content-hyperlink-auditing]]
=== hyperlink-auditing
Enable or disable hyperlink auditing (<a ping>).
@ -1408,6 +1458,8 @@ Valid values:
Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[content-javascript-can-access-clipboard]]
=== javascript-can-access-clipboard
Whether JavaScript programs can read or write to the clipboard.
@ -1476,6 +1528,8 @@ Valid values:
Default: +pass:[no-3rdparty]+
This setting is only available with the QtWebKit backend.
[[content-cookies-store]]
=== cookies-store
Whether to store cookies.
@ -1487,6 +1541,8 @@ Valid values:
Default: +pass:[true]+
This setting is only available with the QtWebKit backend.
[[content-host-block-lists]]
=== host-block-lists
List of URLs of lists which contain hosts to block.
@ -1638,7 +1694,7 @@ Valid values:
* +javascript+: Better but slower
* +python+: Slightly worse but faster
Default: +pass:[javascript]+
Default: +pass:[python]+
== searchengines
Definitions of search engines which can be used via the address bar.

View File

@ -0,0 +1,178 @@
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Bridge from QWebEngineSettings to our own settings.
Module attributes:
ATTRIBUTES: A mapping from internal setting names to QWebEngineSetting enum
constants.
"""
import os.path
from PyQt5.QtWebEngineWidgets import QWebEngineSettings
from qutebrowser.config import config, websettings
from qutebrowser.utils import standarddir, objreg
class Attribute(websettings.Attribute):
GLOBAL_SETTINGS = QWebEngineSettings.globalSettings()
ENUM_BASE = QWebEngineSettings
class Setter(websettings.Setter):
GLOBAL_SETTINGS = QWebEngineSettings.globalSettings()
class NullStringSetter(websettings.NullStringSetter):
GLOBAL_SETTINGS = QWebEngineSettings.globalSettings()
class StaticSetter(websettings.StaticSetter):
GLOBAL_SETTINGS = QWebEngineSettings.globalSettings()
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
websettings.update_mappings(MAPPINGS, section, option)
def init():
"""Initialize the global QWebSettings."""
# FIXME:qtwebengine set paths in profile
websettings.init_mappings(MAPPINGS)
objreg.get('config').changed.connect(update_settings)
# Missing QtWebEngine attributes:
# - ErrorPageEnabled (should not be exposed, but set)
# - FullScreenSupportEnabled
# - ScreenCaptureEnabled
# - Accelerated2dCanvasEnabled
# - AutoLoadIconsForPage
# - TouchIconsEnabled
#
# Missing QtWebEngine fonts:
# - FantasyFont
# - PictographFont
#
# TODO settings on profile:
# - cachePath
# - httpAcceptLanguage
# - httpCacheMaximumSize
# - httpUserAgent
# - persistentCookiesPolicy
# - offTheRecord
# - persistentStoragePath
#
# TODO settings elsewhere:
# - proxy
# - custom headers
# - ssl-strict
MAPPINGS = {
'content': {
'allow-images':
Attribute(QWebEngineSettings.AutoLoadImages),
'allow-javascript':
Attribute(QWebEngineSettings.JavascriptEnabled),
'javascript-can-open-windows':
Attribute(QWebEngineSettings.JavascriptCanOpenWindows),
'javascript-can-access-clipboard':
Attribute(QWebEngineSettings.JavascriptCanAccessClipboard),
'allow-plugins':
Attribute(QWebEngineSettings.PluginsEnabled),
'webgl':
Attribute(QWebEngineSettings.WebGLEnabled),
'hyperlink-auditing':
Attribute(QWebEngineSettings.HyperlinkAuditingEnabled),
'local-content-can-access-remote-urls':
Attribute(QWebEngineSettings.LocalContentCanAccessRemoteUrls),
'local-content-can-access-file-urls':
Attribute(QWebEngineSettings.LocalContentCanAccessFileUrls),
},
'input': {
'spatial-navigation':
Attribute(QWebEngineSettings.SpatialNavigationEnabled),
'links-included-in-focus-chain':
Attribute(QWebEngineSettings.LinksIncludedInFocusChain),
},
'fonts': {
'web-family-standard':
Setter(getter=QWebEngineSettings.fontFamily,
setter=QWebEngineSettings.setFontFamily,
args=[QWebEngineSettings.StandardFont]),
'web-family-fixed':
Setter(getter=QWebEngineSettings.fontFamily,
setter=QWebEngineSettings.setFontFamily,
args=[QWebEngineSettings.FixedFont]),
'web-family-serif':
Setter(getter=QWebEngineSettings.fontFamily,
setter=QWebEngineSettings.setFontFamily,
args=[QWebEngineSettings.SerifFont]),
'web-family-sans-serif':
Setter(getter=QWebEngineSettings.fontFamily,
setter=QWebEngineSettings.setFontFamily,
args=[QWebEngineSettings.SansSerifFont]),
'web-family-cursive':
Setter(getter=QWebEngineSettings.fontFamily,
setter=QWebEngineSettings.setFontFamily,
args=[QWebEngineSettings.CursiveFont]),
'web-family-fantasy':
Setter(getter=QWebEngineSettings.fontFamily,
setter=QWebEngineSettings.setFontFamily,
args=[QWebEngineSettings.FantasyFont]),
'web-size-minimum':
Setter(getter=QWebEngineSettings.fontSize,
setter=QWebEngineSettings.setFontSize,
args=[QWebEngineSettings.MinimumFontSize]),
'web-size-minimum-logical':
Setter(getter=QWebEngineSettings.fontSize,
setter=QWebEngineSettings.setFontSize,
args=[QWebEngineSettings.MinimumLogicalFontSize]),
'web-size-default':
Setter(getter=QWebEngineSettings.fontSize,
setter=QWebEngineSettings.setFontSize,
args=[QWebEngineSettings.DefaultFontSize]),
'web-size-default-fixed':
Setter(getter=QWebEngineSettings.fontSize,
setter=QWebEngineSettings.setFontSize,
args=[QWebEngineSettings.DefaultFixedFontSize]),
},
'ui': {
'smooth-scrolling':
Attribute(QWebEngineSettings.ScrollAnimatorEnabled),
},
'storage': {
'local-storage':
Attribute(QWebEngineSettings.LocalStorageEnabled),
},
'general': {
'xss-auditing':
Attribute(QWebEngineSettings.XSSAuditingEnabled),
'default-encoding':
Setter(getter=QWebEngineSettings.defaultTextEncoding,
setter=QWebEngineSettings.setDefaultTextEncoding),
}
}

View File

@ -180,12 +180,7 @@ class Command:
QWebSettings.JavascriptEnabled):
raise cmdexc.PrerequisitesError(
"{}: This command needs javascript enabled.".format(self.name))
backend_mapping = {
'webkit': usertypes.Backend.QtWebKit,
'webengine': usertypes.Backend.QtWebEngine,
}
used_backend = backend_mapping[objreg.get('args').backend]
used_backend = usertypes.arg2backend[objreg.get('args').backend]
if self.backend is not None and used_backend != self.backend:
raise cmdexc.PrerequisitesError(
"{}: Only available with {} "

View File

@ -771,11 +771,18 @@ class ConfigManager(QObject):
except KeyError:
raise configexc.NoSectionError(sectname)
mapping = {key: val.value() for key, val in sect.values.items()}
if validate:
interpolated = self._interpolation.before_get(
self, sectname, optname, value, mapping)
allowed_backends = sect.values[optname].backends
used_backend = usertypes.arg2backend[objreg.get('args').backend]
if (allowed_backends is not None and
used_backend not in allowed_backends):
raise configexc.BackendError(used_backend)
else:
interpolated = None
try:
sect.setv(layer, optname, value, interpolated)
except KeyError:

View File

@ -35,6 +35,7 @@ from qutebrowser.config import configtypes as typ
from qutebrowser.config import sections as sect
from qutebrowser.config.value import SettingValue
from qutebrowser.utils.qtutils import MAXVALS
from qutebrowser.utils import usertypes
FIRST_COMMENT = r"""
@ -169,18 +170,21 @@ def data(readonly=False):
"Encoding to use for editor."),
('private-browsing',
SettingValue(typ.Bool(), 'false'),
SettingValue(typ.Bool(), 'false',
backends=[usertypes.Backend.QtWebKit]),
"Do not record visited pages in the history or store web page "
"icons."),
('developer-extras',
SettingValue(typ.Bool(), 'false'),
SettingValue(typ.Bool(), 'false',
backends=[usertypes.Backend.QtWebKit]),
"Enable extra tools for Web developers.\n\n"
"This needs to be enabled for `:inspector` to work and also adds "
"an _Inspect_ entry to the context menu."),
('print-element-backgrounds',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Whether the background color and images are also drawn when the "
"page is printed."),
@ -193,7 +197,8 @@ def data(readonly=False):
"have an impact on performance."),
('site-specific-quirks',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Enable workarounds for broken sites."),
('default-encoding',
@ -229,7 +234,7 @@ def data(readonly=False):
('none', "Don't log messages."),
('debug', "Log messages with debug level."),
('info', "Log messages with info level.")
)), 'debug'),
)), 'debug', backends=[usertypes.Backend.QtWebKit]),
"How to log javascript console messages."),
('save-session',
@ -284,25 +289,29 @@ def data(readonly=False):
"Whether to confirm quitting the application."),
('zoom-text-only',
SettingValue(typ.Bool(), 'false'),
SettingValue(typ.Bool(), 'false',
backends=[usertypes.Backend.QtWebKit]),
"Whether the zoom factor on a frame applies only to the text or "
"to all content."),
('frame-flattening',
SettingValue(typ.Bool(), 'false'),
SettingValue(typ.Bool(), 'false',
backends=[usertypes.Backend.QtWebKit]),
"Whether to expand each subframe to its contents.\n\n"
"This will flatten all the frames to become one scrollable "
"page."),
('user-stylesheet',
SettingValue(typ.UserStyleSheet(none_ok=True),
'::-webkit-scrollbar { width: 0px; height: 0px; }'),
'::-webkit-scrollbar { width: 0px; height: 0px; }',
backends=[usertypes.Backend.QtWebKit]),
"User stylesheet to use (absolute filename, filename relative to "
"the config directory or CSS string). Will expand environment "
"variables."),
('css-media-type',
SettingValue(typ.String(none_ok=True), ''),
SettingValue(typ.String(none_ok=True), '',
backends=[usertypes.Backend.QtWebKit]),
"Set the CSS media type."),
('smooth-scrolling',
@ -362,11 +371,13 @@ def data(readonly=False):
('network', sect.KeyValue(
('do-not-track',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Value to send in the `DNT` header."),
('accept-language',
SettingValue(typ.String(none_ok=True), 'en-US,en'),
SettingValue(typ.String(none_ok=True), 'en-US,en',
backends=[usertypes.Backend.QtWebKit]),
"Value to send in the `accept-language` header."),
('referer-header',
@ -378,33 +389,39 @@ def data(readonly=False):
('same-domain', "Only send for the same domain."
" This will still protect your privacy, but"
" shouldn't break any sites.")
)), 'same-domain'),
)), 'same-domain', backends=[usertypes.Backend.QtWebKit]),
"Send the Referer header"),
('user-agent',
SettingValue(typ.UserAgent(none_ok=True), ''),
SettingValue(typ.UserAgent(none_ok=True), '',
backends=[usertypes.Backend.QtWebKit]),
"User agent to send. Empty to send the default."),
('proxy',
SettingValue(typ.Proxy(), 'system'),
SettingValue(typ.Proxy(), 'system',
backends=[usertypes.Backend.QtWebKit]),
"The proxy to use.\n\n"
"In addition to the listed values, you can use a `socks://...` "
"or `http://...` URL."),
('proxy-dns-requests',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Whether to send DNS requests over the configured proxy."),
('ssl-strict',
SettingValue(typ.BoolAsk(), 'ask'),
SettingValue(typ.BoolAsk(), 'ask',
backends=[usertypes.Backend.QtWebKit]),
"Whether to validate SSL handshakes."),
('dns-prefetch',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Whether to try to pre-fetch DNS entries to speed up browsing."),
('custom-headers',
SettingValue(typ.HeaderDict(none_ok=True), ''),
SettingValue(typ.HeaderDict(none_ok=True), '',
backends=[usertypes.Backend.QtWebKit]),
"Set custom headers for qutebrowser HTTP requests."),
readonly=readonly
@ -673,7 +690,8 @@ def data(readonly=False):
('maximum-pages-in-cache',
SettingValue(
typ.Int(none_ok=True, minval=0, maxval=MAXVALS['int']), ''),
typ.Int(none_ok=True, minval=0, maxval=MAXVALS['int']), '',
backends=[usertypes.Backend.QtWebKit]),
"The maximum number of pages to hold in the global memory page "
"cache.\n\n"
"The Page Cache allows for a nicer user experience when "
@ -685,7 +703,8 @@ def data(readonly=False):
('object-cache-capacities',
SettingValue(
typ.List(typ.WebKitBytes(maxsize=MAXVALS['int'],
none_ok=True), none_ok=True, length=3), ''),
none_ok=True), none_ok=True, length=3), '',
backends=[usertypes.Backend.QtWebKit]),
"The capacities for the global memory cache for dead objects "
"such as stylesheets or scripts. Syntax: cacheMinDeadCapacity, "
"cacheMaxDead, totalCapacity.\n\n"
@ -699,21 +718,25 @@ def data(readonly=False):
('offline-storage-default-quota',
SettingValue(typ.WebKitBytes(maxsize=MAXVALS['int64'],
none_ok=True), ''),
none_ok=True), '',
backends=[usertypes.Backend.QtWebKit]),
"Default quota for new offline storage databases."),
('offline-web-application-cache-quota',
SettingValue(typ.WebKitBytes(maxsize=MAXVALS['int64'],
none_ok=True), ''),
none_ok=True), '',
backends=[usertypes.Backend.QtWebKit]),
"Quota for the offline web application cache."),
('offline-storage-database',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Whether support for the HTML 5 offline storage feature is "
"enabled."),
('offline-web-application-storage',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Whether support for the HTML 5 web application cache feature is "
"enabled.\n\n"
"An application cache acts like an HTTP cache in some sense. For "
@ -756,7 +779,8 @@ def data(readonly=False):
"Enables or disables WebGL."),
('css-regions',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Enable or disable support for CSS regions."),
('hyperlink-auditing',
@ -771,17 +795,13 @@ def data(readonly=False):
SettingValue(typ.BoolAsk(), 'ask'),
"Allow websites to show notifications."),
#('allow-java',
# SettingValue(typ.Bool(), 'true'),
# "Enables or disables Java applets. Currently Java applets are "
# "not supported"),
('javascript-can-open-windows',
SettingValue(typ.Bool(), 'false'),
"Whether JavaScript programs can open new windows."),
('javascript-can-close-windows',
SettingValue(typ.Bool(), 'false'),
SettingValue(typ.Bool(), 'false',
backends=[usertypes.Backend.QtWebKit]),
"Whether JavaScript programs can close windows."),
('javascript-can-access-clipboard',
@ -817,11 +837,12 @@ def data(readonly=False):
"the same origin only, unless a cookie is "
"already set for the domain."),
('never', "Don't accept cookies at all.")
)), 'no-3rdparty'),
)), 'no-3rdparty', backends=[usertypes.Backend.QtWebKit]),
"Control which cookies to accept."),
('cookies-store',
SettingValue(typ.Bool(), 'true'),
SettingValue(typ.Bool(), 'true',
backends=[usertypes.Backend.QtWebKit]),
"Whether to store cookies."),
('host-block-lists',

View File

@ -27,6 +27,15 @@ class Error(Exception):
pass
class BackendError(Error):
"""Raised when this setting is unavailable with the current backend."""
def __init__(self, backend):
super().__init__("This setting is not available with the {} "
"backend!".format(backend.name))
class ValidationError(Error):
"""Raised when a value for a config type was invalid.

View File

@ -35,17 +35,20 @@ class SettingValue:
most significant layer first.
"""
def __init__(self, typ, default=None):
def __init__(self, typ, default=None, *, backends=None):
"""Constructor.
Args:
typ: The BaseType to use.
default: Raw value to set.
backend: A list of usertypes.Backend enum members to mark this
setting as unsupported with other backends.
"""
self.typ = typ
self.values = collections.OrderedDict.fromkeys(
['temp', 'conf', 'default'])
self.values['default'] = default
self.backends = backends
def __str__(self):
"""Get raw string value."""

View File

@ -262,9 +262,8 @@ def update_mappings(mappings, section, option):
def init():
"""Initialize all QWeb(Engine)Settings."""
if objreg.get('args').backend == 'webengine':
# from qutebrowser.browser.webengine import webenginesettings
# webenginesettings.init()
log.stub('with QtWebEngine')
from qutebrowser.browser.webengine import webenginesettings
webenginesettings.init()
else:
from qutebrowser.browser.webkit import webkitsettings
webkitsettings.init()

View File

@ -254,6 +254,10 @@ LoadStatus = enum('LoadStatus', ['none', 'success', 'success_https', 'error',
# Backend of a tab
Backend = enum('Backend', ['QtWebKit', 'QtWebEngine'])
arg2backend = {
'webkit': Backend.QtWebKit,
'webengine': Backend.QtWebEngine,
}
# Where a download should be saved

View File

@ -40,7 +40,7 @@ from scripts import asciidoc2html, utils
from qutebrowser import qutebrowser
from qutebrowser.commands import cmdutils, argparser
from qutebrowser.config import configdata
from qutebrowser.utils import docutils
from qutebrowser.utils import docutils, usertypes
class UsageFormatter(argparse.HelpFormatter):
@ -357,6 +357,7 @@ def _generate_setting_section(f, sectname, sect):
f.write("=== {}".format(optname) + "\n")
f.write(sect.descriptions[optname] + "\n")
f.write("\n")
valid_values = option.typ.get_valid_values()
if valid_values is not None:
f.write("Valid values:\n")
@ -368,12 +369,25 @@ def _generate_setting_section(f, sectname, sect):
except KeyError:
f.write(" * +{}+".format(val) + "\n")
f.write("\n")
if option.default():
f.write("Default: +pass:[{}]+\n".format(html.escape(
option.default())))
else:
f.write("Default: empty\n")
if option.backends is None:
pass
elif option.backends == [usertypes.Backend.QtWebKit]:
f.write("\nThis setting is only available with the QtWebKit "
"backend.\n")
elif option.backends == [usertypes.Backend.QtWebEngine]:
f.write("\nThis setting is only available with the QtWebEngine "
"backend.\n")
else:
raise ValueError("Invalid value {!r} for option.backends".format(
option.backends))
def generate_settings(filename):
"""Generate the complete settings section."""