Coverage for qutebrowser/config/websettings.py : 40%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
# Copyright 2014-2018 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/>.
# We get various "abstract but not overridden" warnings # pylint: disable=abstract-method
"""Base class for QWeb(Engine)Settings wrappers."""
"""Get a list of global QWeb(Engine)Settings to use.""" raise NotImplementedError
"""Get a list of QWeb(Engine)Settings objects to use.
Args: settings: The QWeb(Engine)Settings instance to use, or None to use the global instance.
Return: A list of QWeb(Engine)Settings objects. The first one should be used for reading. """ if settings is None: return self._get_global_settings() else: return [settings]
"""Set the value of this setting.
Args: value: The value to set, or None to restore the default. settings: The QWeb(Engine)Settings instance to use, or None to use the global instance. """ self.set_default(settings=settings) else:
"""Set the default value for this setting.
Not implemented for most settings. """ if self._default is UNSET: raise ValueError("No default set for {!r}".format(self)) else: self._set(self._default, settings=settings)
"""Inner function to set the value of this setting.
Must be overridden by subclasses.
Args: value: The value to set. settings: The QWeb(Engine)Settings instance to use, or None to use the global instance. """ raise NotImplementedError
"""A setting set via QWeb(Engine)Settings::setAttribute.
Attributes: self._attributes: A list of QWeb(Engine)Settings::WebAttribute members. """
def __repr__(self): attributes = [debug.qenum_key(self.ENUM_BASE, attr) for attr in self._attributes] return utils.get_repr(self, attributes=attributes, constructor=True)
for obj in self._get_settings(settings): for attribute in self._attributes: obj.setAttribute(attribute, value)
"""A setting set via a QWeb(Engine)Settings setter method.
This will pass the QWeb(Engine)Settings instance ("self") as first argument to the methods, so self._setter is the *unbound* method.
Attributes: _setter: The unbound QWeb(Engine)Settings method to set this value. _args: An iterable of the arguments to pass to the setter (before the value). _unpack: Whether to unpack args (True) or pass them directly (False). """
def __repr__(self): return utils.get_repr(self, setter=self._setter, args=self._args, unpack=self._unpack, constructor=True)
for obj in self._get_settings(settings): args = [obj] args.extend(self._args) if self._unpack: args.extend(value) else: args.append(value) self._setter(*args)
"""A setting set via a static QWeb(Engine)Settings method.
self._setter is the *bound* method. """
if settings is not None: raise ValueError("'settings' may not be set with StaticSetters!") args = list(self._args) if self._unpack: args.extend(value) else: args.append(value) self._setter(*args)
"""A setter for a font family.
Gets the default value from QFont. """
font = QFont() font.setStyleHint(self._qfont) value = font.defaultFamily() self._set(value, settings=settings)
"""Initialize all settings based on a settings mapping.""" for option, mapping in mappings.items(): value = config.instance.get(option) log.config.vdebug("Setting {} to {!r}".format(option, value)) mapping.set(value)
"""Update global settings when QWeb(Engine)Settings changed.""" except KeyError: return
"""Initialize all QWeb(Engine)Settings.""" if objects.backend == usertypes.Backend.QtWebEngine: from qutebrowser.browser.webengine import webenginesettings webenginesettings.init(args) else: from qutebrowser.browser.webkit import webkitsettings webkitsettings.init(args)
"""Shut down QWeb(Engine)Settings.""" if objects.backend == usertypes.Backend.QtWebEngine: from qutebrowser.browser.webengine import webenginesettings webenginesettings.shutdown() else: from qutebrowser.browser.webkit import webkitsettings webkitsettings.shutdown() |