diff --git a/qutebrowser/app.py b/qutebrowser/app.py
index 59aff9476..bdffc2921 100644
--- a/qutebrowser/app.py
+++ b/qutebrowser/app.py
@@ -274,7 +274,7 @@ def process_pos_args(args, via_ipc=False, cwd=None, target_arg=None):
if via_ipc and target_arg and target_arg != 'auto':
open_target = target_arg
else:
- open_target = config.get('general', 'new-instance-open-target')
+ open_target = config.val.new_instance_open_target
win_id = mainwindow.get_window(via_ipc, force_target=open_target)
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
@@ -310,7 +310,7 @@ def _open_startpage(win_id=None):
window=cur_win_id)
if tabbed_browser.count() == 0:
log.init.debug("Opening startpage")
- for urlstr in config.get('general', 'startpage'):
+ for urlstr in config.val.startpage:
try:
url = urlutils.fuzzy_url(urlstr, do_search=False)
except urlutils.InvalidUrlError as e:
@@ -464,7 +464,7 @@ def _init_modules(args, crash_handler):
completionmodels.init()
log.init.debug("Misc initialization...")
- if config.get('ui', 'hide-wayland-decoration'):
+ if config.val.ui.hide_wayland_decoration:
os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
else:
os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
@@ -674,7 +674,7 @@ class Quitter:
if session is not None:
session_manager.save(session, last_window=last_window,
load_next_time=True)
- elif config.get('general', 'save-session'):
+ elif config.val.save_session:
session_manager.save(sessions.default, last_window=last_window,
load_next_time=True)
diff --git a/qutebrowser/browser/adblock.py b/qutebrowser/browser/adblock.py
index 276dec08b..b27a54424 100644
--- a/qutebrowser/browser/adblock.py
+++ b/qutebrowser/browser/adblock.py
@@ -67,7 +67,7 @@ def is_whitelisted_host(host):
Args:
host: The host of the request as string.
"""
- whitelist = config.get('content', 'host-blocking-whitelist')
+ whitelist = config.val.content.host_blocking_whitelist
if whitelist is None:
return False
@@ -123,7 +123,7 @@ class HostBlocker:
def is_blocked(self, url):
"""Check if the given URL (as QUrl) is blocked."""
- if not config.get('content', 'host-blocking-enabled'):
+ if not config.val.content.host_blocking_enabled:
return False
host = url.host()
return ((host in self._blocked_hosts or
@@ -164,9 +164,9 @@ class HostBlocker:
if not found:
args = objreg.get('args')
- if (config.get('content', 'host-block-lists') is not None and
+ if (config.val.content.host_block_lists is not None and
args.basedir is None and
- config.get('content', 'host-blocking-enabled')):
+ config.val.content.host_blocking_enabled):
message.info("Run :adblock-update to get adblock lists.")
@cmdutils.register(instance='host-blocker')
@@ -180,7 +180,7 @@ class HostBlocker:
self._config_blocked_hosts)
self._blocked_hosts = set()
self._done_count = 0
- urls = config.get('content', 'host-block-lists')
+ urls = config.val.content.host_block_lists
download_manager = objreg.get('qtnetwork-download-manager',
scope='window', window='last-focused')
if urls is None:
@@ -295,7 +295,7 @@ class HostBlocker:
@config.change_filter('content', 'host-block-lists')
def on_config_changed(self):
"""Update files when the config changed."""
- urls = config.get('content', 'host-block-lists')
+ urls = config.val.content.host_block_lists
if urls is None:
try:
os.remove(self._local_hosts_file)
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py
index b36b5d1c3..7adb9608e 100644
--- a/qutebrowser/browser/browsertab.py
+++ b/qutebrowser/browser/browsertab.py
@@ -249,17 +249,17 @@ class AbstractZoom(QObject):
def _on_config_changed(self, section, option):
if section == 'ui' and option in ['zoom-levels', 'default-zoom']:
if not self._default_zoom_changed:
- factor = float(config.get('ui', 'default-zoom')) / 100
+ factor = float(config.val.ui.default_zoom) / 100
self._set_factor_internal(factor)
self._default_zoom_changed = False
self._init_neighborlist()
def _init_neighborlist(self):
"""Initialize self._neighborlist."""
- levels = config.get('ui', 'zoom-levels')
+ levels = config.val.ui.zoom_levels
self._neighborlist = usertypes.NeighborList(
levels, mode=usertypes.NeighborList.Modes.edge)
- self._neighborlist.fuzzyval = config.get('ui', 'default-zoom')
+ self._neighborlist.fuzzyval = config.val.ui.default_zoom
def offset(self, offset):
"""Increase/Decrease the zoom level by the given offset.
@@ -295,7 +295,7 @@ class AbstractZoom(QObject):
raise NotImplementedError
def set_default(self):
- default_zoom = config.get('ui', 'default-zoom')
+ default_zoom = config.val.ui.default_zoom
self._set_factor_internal(float(default_zoom) / 100)
@@ -690,7 +690,7 @@ class AbstractTab(QWidget):
def _handle_auto_insert_mode(self, ok):
"""Handle auto-insert-mode after loading finished."""
- if not config.get('input', 'auto-insert-mode') or not ok:
+ if not config.val.input.auto_insert_mode or not ok:
return
cur_mode = self._mode_manager.mode
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index 3d8516fe2..c375188f4 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -190,7 +190,7 @@ class CommandDispatcher:
elif next_:
return QTabBar.SelectRightTab
elif opposite:
- conf_selection = config.get('tabs', 'select-on-remove')
+ conf_selection = config.val.tabs.select_on_remove
if conf_selection == QTabBar.SelectLeftTab:
return QTabBar.SelectRightTab
elif conf_selection == QTabBar.SelectRightTab:
@@ -307,7 +307,7 @@ class CommandDispatcher:
private: Open a new window in private browsing mode.
"""
if url is None:
- urls = [config.get('general', 'default-page')]
+ urls = [config.val.default_page]
else:
urls = self._parse_url_input(url)
@@ -507,9 +507,9 @@ class CommandDispatcher:
idx = new_tabbed_browser.indexOf(newtab)
new_tabbed_browser.set_page_title(idx, cur_title)
- if config.get('tabs', 'show-favicons'):
+ if config.val.tabs.show_favicons:
new_tabbed_browser.setTabIcon(idx, curtab.icon())
- if config.get('tabs', 'tabs-are-windows'):
+ if config.val.tabs.tabs_are_windows:
new_tabbed_browser.window().setWindowIcon(curtab.icon())
newtab.data.keep_icon = True
@@ -778,7 +778,7 @@ class CommandDispatcher:
url_query.setQueryDelimiters('=', ';')
url_query.setQuery(url_query_str)
for key in dict(url_query.queryItems()):
- if key in config.get('general', 'yank-ignored-url-parameters'):
+ if key in config.val.yank_ignored_url_parameters:
url_query.removeQueryItem(key)
url.setQuery(url_query)
return url.toString(flags)
@@ -888,7 +888,7 @@ class CommandDispatcher:
level = count if count is not None else zoom
if level is None:
- level = config.get('ui', 'default-zoom')
+ level = config.val.ui.default_zoom
tab = self._current_widget()
try:
@@ -953,7 +953,7 @@ class CommandDispatcher:
newidx = self._current_index() - count
if newidx >= 0:
self._set_current_index(newidx)
- elif config.get('tabs', 'wrap'):
+ elif config.val.tabs.wrap:
self._set_current_index(newidx % self._count())
else:
raise cmdexc.CommandError("First tab")
@@ -973,7 +973,7 @@ class CommandDispatcher:
newidx = self._current_index() + count
if newidx < self._count():
self._set_current_index(newidx)
- elif config.get('tabs', 'wrap'):
+ elif config.val.tabs.wrap:
self._set_current_index(newidx % self._count())
else:
raise cmdexc.CommandError("Last tab")
@@ -1131,7 +1131,7 @@ class CommandDispatcher:
elif index == '+': # pragma: no branch
new_idx += delta
- if config.get('tabs', 'wrap'):
+ if config.val.tabs.wrap:
new_idx %= self._count()
else:
# absolute moving
@@ -1192,7 +1192,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
def home(self):
"""Open main startpage in current tab."""
- self.openurl(config.get('general', 'startpage')[0])
+ self.openurl(config.val.startpage[0])
def _run_userscript(self, cmd, *args, verbose=False):
"""Run a userscript given as argument.
@@ -1746,7 +1746,7 @@ class CommandDispatcher:
return
options = {
- 'ignore_case': config.get('general', 'ignore-case'),
+ 'ignore_case': config.val.ignore_case,
'reverse': reverse,
}
diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py
index c7cb5ad8e..b70d5ca45 100644
--- a/qutebrowser/browser/downloads.py
+++ b/qutebrowser/browser/downloads.py
@@ -69,8 +69,8 @@ class UnsupportedOperationError(Exception):
def download_dir():
"""Get the download directory to use."""
- directory = config.get('storage', 'download-directory')
- remember_dir = config.get('storage', 'remember-download-directory')
+ directory = config.val.storage.download_directory
+ remember_dir = config.val.storage.remember_download_directory
if remember_dir and last_used_directory is not None:
return last_used_directory
@@ -104,7 +104,7 @@ def _path_suggestion(filename):
Args:
filename: The filename to use if included in the suggestion.
"""
- suggestion = config.get('completion', 'download-path-suggestion')
+ suggestion = config.val.completion.download_path_suggestion
if suggestion == 'path':
# add trailing '/' if not present
return os.path.join(download_dir(), '')
@@ -735,7 +735,7 @@ class AbstractDownloadManager(QObject):
download.remove_requested.connect(functools.partial(
self._remove_item, download))
- delay = config.get('ui', 'remove-finished-downloads')
+ delay = config.val.ui.remove_finished_downloads
if delay > -1:
download.finished.connect(
lambda: QTimer.singleShot(delay, download.remove))
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 3cc70f434..aed554d9f 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -68,7 +68,7 @@ class HintLabel(QLabel):
background-color: {{ color['hints.bg'] }};
color: {{ color['hints.fg'] }};
font: {{ font['hints'] }};
- border: {{ config.get('hints', 'border') }};
+ border: {{ config.val.hints.border }};
padding-left: -3px;
padding-right: -3px;
}
@@ -100,7 +100,7 @@ class HintLabel(QLabel):
matched: The part of the text which was typed.
unmatched: The part of the text which was not typed yet.
"""
- if (config.get('hints', 'uppercase') and
+ if (config.val.hints.uppercase and
self._context.hint_mode in ['letter', 'word']):
matched = html.escape(matched.upper())
unmatched = html.escape(unmatched.upper())
@@ -108,7 +108,7 @@ class HintLabel(QLabel):
matched = html.escape(matched)
unmatched = html.escape(unmatched)
- match_color = html.escape(config.get('colors', 'hints.fg.match'))
+ match_color = html.escape(config.val.colors.hints.fg.match)
self.setText('{}{}'.format(
match_color, matched, unmatched))
self.adjustSize()
@@ -121,7 +121,7 @@ class HintLabel(QLabel):
log.hints.debug("Frame for {!r} vanished!".format(self))
self.hide()
return
- no_js = config.get('hints', 'find-implementation') != 'javascript'
+ no_js = config.val.hints.find_implementation != 'javascript'
rect = self.elem.rect_on_view(no_js=no_js)
self.move(rect.x(), rect.y())
@@ -203,7 +203,7 @@ class HintActions:
Target.window: usertypes.ClickTarget.window,
Target.hover: usertypes.ClickTarget.normal,
}
- if config.get('tabs', 'background-tabs'):
+ if config.val.tabs.background_tabs:
target_mapping[Target.tab] = usertypes.ClickTarget.tab_bg
else:
target_mapping[Target.tab] = usertypes.ClickTarget.tab
@@ -421,9 +421,9 @@ class HintManager(QObject):
if hint_mode == 'number':
chars = '0123456789'
else:
- chars = config.get('hints', 'chars')
- min_chars = config.get('hints', 'min-chars')
- if config.get('hints', 'scatter') and hint_mode != 'number':
+ chars = config.val.hints.chars
+ min_chars = config.val.hints.min_chars
+ if config.val.hints.scatter and hint_mode != 'number':
return self._hint_scattered(min_chars, chars, elems)
else:
return self._hint_linear(min_chars, chars, elems)
@@ -685,7 +685,7 @@ class HintManager(QObject):
Target.download, Target.normal, Target.current]:
pass
elif (target == Target.tab and
- config.get('tabs', 'background-tabs')):
+ config.val.tabs.background_tabs):
pass
else:
name = target.name.replace('_', '-')
@@ -693,7 +693,7 @@ class HintManager(QObject):
"target {}!".format(name))
if mode is None:
- mode = config.get('hints', 'mode')
+ mode = config.val.hints.mode
self._check_args(target, *args)
self._context = HintContext()
@@ -729,7 +729,7 @@ class HintManager(QObject):
if len(visible) != 1:
return
- auto_follow = config.get('hints', 'auto-follow')
+ auto_follow = config.val.hints.auto_follow
if auto_follow == "always":
follow = True
@@ -747,7 +747,7 @@ class HintManager(QObject):
if follow:
# apply auto-follow-timeout
- timeout = config.get('hints', 'auto-follow-timeout')
+ timeout = config.val.hints.auto_follow_timeout
keyparsers = objreg.get('keyparsers', scope='window',
window=self._win_id)
normal_parser = keyparsers[usertypes.KeyMode.normal]
@@ -773,7 +773,7 @@ class HintManager(QObject):
# element doesn't match anymore -> hide it, unless in rapid
# mode and hide-unmatched-rapid-hints is false (see #1799)
if (not self._context.rapid or
- config.get('hints', 'hide-unmatched-rapid-hints')):
+ config.val.hints.hide_unmatched_rapid_hints):
label.hide()
except webelem.Error:
pass
diff --git a/qutebrowser/browser/mouse.py b/qutebrowser/browser/mouse.py
index d1cd889d3..18069a003 100644
--- a/qutebrowser/browser/mouse.py
+++ b/qutebrowser/browser/mouse.py
@@ -85,7 +85,7 @@ class MouseEventFilter(QObject):
def _handle_mouse_press(self, e):
"""Handle pressing of a mouse button."""
- is_rocker_gesture = (config.get('input', 'rocker-gestures') and
+ is_rocker_gesture = (config.val.input.rocker_gestures and
e.buttons() == Qt.LeftButton | Qt.RightButton)
if e.button() in [Qt.XButton1, Qt.XButton2] or is_rocker_gesture:
@@ -119,7 +119,7 @@ class MouseEventFilter(QObject):
return True
if e.modifiers() & Qt.ControlModifier:
- divider = config.get('input', 'mouse-zoom-divider')
+ divider = config.val.input.mouse_zoom_divider
if divider == 0:
return False
factor = self._tab.zoom.factor() + (e.angleDelta().y() / divider)
@@ -139,7 +139,7 @@ class MouseEventFilter(QObject):
def _handle_context_menu(self, _e):
"""Suppress context menus if rocker gestures are turned on."""
- return config.get('input', 'rocker-gestures')
+ return config.val.input.rocker_gestures
def _mousepress_insertmode_cb(self, elem):
"""Check if the clicked element is editable."""
@@ -157,7 +157,7 @@ class MouseEventFilter(QObject):
'click', only_if_normal=True)
else:
log.mouse.debug("Clicked non-editable element!")
- if config.get('input', 'auto-leave-insert-mode'):
+ if config.val.input.auto_leave_insert_mode:
modeman.leave(self._tab.win_id, usertypes.KeyMode.insert,
'click', maybe=True)
@@ -179,7 +179,7 @@ class MouseEventFilter(QObject):
'click-delayed', only_if_normal=True)
else:
log.mouse.debug("Clicked non-editable element (delayed)!")
- if config.get('input', 'auto-leave-insert-mode'):
+ if config.val.input.auto_leave_insert_mode:
modeman.leave(self._tab.win_id, usertypes.KeyMode.insert,
'click-delayed', maybe=True)
diff --git a/qutebrowser/browser/navigate.py b/qutebrowser/browser/navigate.py
index 4443c6a47..92126c6ad 100644
--- a/qutebrowser/browser/navigate.py
+++ b/qutebrowser/browser/navigate.py
@@ -42,7 +42,7 @@ def incdec(url, count, inc_or_dec):
background: Open the link in a new background tab.
window: Open the link in a new window.
"""
- segments = set(config.get('general', 'url-incdec-segments'))
+ segments = set(config.val.url_incdec_segments)
try:
new_url = urlutils.incdec_number(url, inc_or_dec, count,
segments=segments)
diff --git a/qutebrowser/browser/network/proxy.py b/qutebrowser/browser/network/proxy.py
index 1bdbc7b0b..037c9c712 100644
--- a/qutebrowser/browser/network/proxy.py
+++ b/qutebrowser/browser/network/proxy.py
@@ -44,7 +44,7 @@ class ProxyFactory(QNetworkProxyFactory):
Return:
None if proxy is correct, otherwise an error message.
"""
- proxy = config.get('network', 'proxy')
+ proxy = config.val.network.proxy
if isinstance(proxy, pac.PACFetcher):
return proxy.fetch_error()
else:
@@ -59,7 +59,7 @@ class ProxyFactory(QNetworkProxyFactory):
Return:
A list of QNetworkProxy objects in order of preference.
"""
- proxy = config.get('network', 'proxy')
+ proxy = config.val.network.proxy
if proxy is configtypes.SYSTEM_PROXY:
proxies = QNetworkProxyFactory.systemProxyForQuery(query)
elif isinstance(proxy, pac.PACFetcher):
@@ -69,7 +69,7 @@ class ProxyFactory(QNetworkProxyFactory):
for p in proxies:
if p.type() != QNetworkProxy.NoProxy:
capabilities = p.capabilities()
- if config.get('network', 'proxy-dns-requests'):
+ if config.val.network.proxy_dns_requests:
capabilities |= QNetworkProxy.HostNameLookupCapability
else:
capabilities &= ~QNetworkProxy.HostNameLookupCapability
diff --git a/qutebrowser/browser/qtnetworkdownloads.py b/qutebrowser/browser/qtnetworkdownloads.py
index 71039dc2d..9aba6d335 100644
--- a/qutebrowser/browser/qtnetworkdownloads.py
+++ b/qutebrowser/browser/qtnetworkdownloads.py
@@ -368,7 +368,7 @@ class DownloadManager(downloads.AbstractDownloadManager):
super().__init__(parent)
self._networkmanager = networkmanager.NetworkManager(
win_id=win_id, tab_id=None,
- private=config.get('general', 'private-browsing'), parent=self)
+ private=config.val.private_browsing, parent=self)
@pyqtSlot('QUrl')
def get(self, url, *, user_agent=None, **kwargs):
diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py
index 652c58726..552ced168 100644
--- a/qutebrowser/browser/qutescheme.py
+++ b/qutebrowser/browser/qutescheme.py
@@ -278,14 +278,14 @@ def qute_history(url):
return 'text/html', json.dumps(history_data(start_time))
else:
if (
- config.get('content', 'allow-javascript') and
+ config.val.content.allow_javascript and
(objects.backend == usertypes.Backend.QtWebEngine or
qtutils.is_qtwebkit_ng())
):
return 'text/html', jinja.render(
'history.html',
title='History',
- session_interval=config.get('ui', 'history-session-interval')
+ session_interval=config.val.ui.history_session_interval
)
else:
# Get current date from query parameter, if not given choose today.
diff --git a/qutebrowser/browser/shared.py b/qutebrowser/browser/shared.py
index d400387a9..5d3ddc506 100644
--- a/qutebrowser/browser/shared.py
+++ b/qutebrowser/browser/shared.py
@@ -35,16 +35,16 @@ class CallSuper(Exception):
def custom_headers():
"""Get the combined custom headers."""
headers = {}
- dnt = b'1' if config.get('network', 'do-not-track') else b'0'
+ dnt = b'1' if config.val.network.do_not_track else b'0'
headers[b'DNT'] = dnt
headers[b'X-Do-Not-Track'] = dnt
- config_headers = config.get('network', 'custom-headers')
+ config_headers = config.val.network.custom_headers
if config_headers is not None:
for header, value in config_headers.items():
headers[header.encode('ascii')] = value.encode('ascii')
- accept_language = config.get('network', 'accept-language')
+ accept_language = config.val.network.accept_language
if accept_language is not None:
headers[b'Accept-Language'] = accept_language.encode('ascii')
@@ -72,7 +72,7 @@ def authentication_required(url, authenticator, abort_on):
def javascript_confirm(url, js_msg, abort_on):
"""Display a javascript confirm prompt."""
log.js.debug("confirm: {}".format(js_msg))
- if config.get('ui', 'modal-js-dialog'):
+ if config.val.ui.modal_js_dialog:
raise CallSuper
msg = 'From {}:
{}'.format(html.escape(url.toDisplayString()),
@@ -86,9 +86,9 @@ def javascript_confirm(url, js_msg, abort_on):
def javascript_prompt(url, js_msg, default, abort_on):
"""Display a javascript prompt."""
log.js.debug("prompt: {}".format(js_msg))
- if config.get('ui', 'modal-js-dialog'):
+ if config.val.ui.modal_js_dialog:
raise CallSuper
- if config.get('content', 'ignore-javascript-prompt'):
+ if config.val.content.ignore_javascript_prompt:
return (False, "")
msg = '{} asks:
{}'.format(html.escape(url.toDisplayString()),
@@ -107,10 +107,10 @@ def javascript_prompt(url, js_msg, default, abort_on):
def javascript_alert(url, js_msg, abort_on):
"""Display a javascript alert."""
log.js.debug("alert: {}".format(js_msg))
- if config.get('ui', 'modal-js-dialog'):
+ if config.val.ui.modal_js_dialog:
raise CallSuper
- if config.get('content', 'ignore-javascript-alert'):
+ if config.val.content.ignore_javascript_alert:
return
msg = 'From {}:
{}'.format(html.escape(url.toDisplayString()),
@@ -129,7 +129,7 @@ def ignore_certificate_errors(url, errors, abort_on):
Return:
True if the error should be ignored, False otherwise.
"""
- ssl_strict = config.get('network', 'ssl-strict')
+ ssl_strict = config.val.network.ssl_strict
log.webview.debug("Certificate errors {!r}, strict {}".format(
errors, ssl_strict))
@@ -233,7 +233,7 @@ def get_tab(win_id, target):
def get_user_stylesheet():
"""Get the combined user-stylesheet."""
- filename = config.get('ui', 'user-stylesheet')
+ filename = config.val.ui.user_stylesheet
if filename is None:
css = ''
@@ -241,7 +241,7 @@ def get_user_stylesheet():
with open(filename, 'r', encoding='utf-8') as f:
css = f.read()
- if config.get('ui', 'hide-scrollbar'):
+ if config.val.ui.hide_scrollbar:
css += '\nhtml > ::-webkit-scrollbar { width: 0px; height: 0px; }'
return css
diff --git a/qutebrowser/browser/webelem.py b/qutebrowser/browser/webelem.py
index 149300111..401a3bb93 100644
--- a/qutebrowser/browser/webelem.py
+++ b/qutebrowser/browser/webelem.py
@@ -182,7 +182,7 @@ class AbstractWebElement(collections.abc.MutableMapping):
# at least a classid attribute. Oh, and let's hope images/...
# DON'T have a classid attribute. HTML sucks.
log.webelem.debug("