Refactor most stuff using config.val.ui
This commit is contained in:
parent
1ed8df8903
commit
1a6511c7a8
@ -464,7 +464,7 @@ def _init_modules(args, crash_handler):
|
|||||||
completionmodels.init()
|
completionmodels.init()
|
||||||
|
|
||||||
log.init.debug("Misc initialization...")
|
log.init.debug("Misc initialization...")
|
||||||
if config.val.ui.hide_wayland_decoration:
|
if config.val.window.hide_wayland_decoration:
|
||||||
os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
|
os.environ['QT_WAYLAND_DISABLE_WINDOWDECORATION'] = '1'
|
||||||
else:
|
else:
|
||||||
os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
|
os.environ.pop('QT_WAYLAND_DISABLE_WINDOWDECORATION', None)
|
||||||
|
@ -264,17 +264,17 @@ class AbstractZoom(QObject):
|
|||||||
def _on_config_changed(self, section, option):
|
def _on_config_changed(self, section, option):
|
||||||
if section == 'ui' and option in ['zoom-levels', 'default-zoom']:
|
if section == 'ui' and option in ['zoom-levels', 'default-zoom']:
|
||||||
if not self._default_zoom_changed:
|
if not self._default_zoom_changed:
|
||||||
factor = float(config.val.ui.default_zoom) / 100
|
factor = float(config.val.zoom.default) / 100
|
||||||
self._set_factor_internal(factor)
|
self._set_factor_internal(factor)
|
||||||
self._default_zoom_changed = False
|
self._default_zoom_changed = False
|
||||||
self._init_neighborlist()
|
self._init_neighborlist()
|
||||||
|
|
||||||
def _init_neighborlist(self):
|
def _init_neighborlist(self):
|
||||||
"""Initialize self._neighborlist."""
|
"""Initialize self._neighborlist."""
|
||||||
levels = config.val.ui.zoom_levels
|
levels = config.val.zoom.levels
|
||||||
self._neighborlist = usertypes.NeighborList(
|
self._neighborlist = usertypes.NeighborList(
|
||||||
levels, mode=usertypes.NeighborList.Modes.edge)
|
levels, mode=usertypes.NeighborList.Modes.edge)
|
||||||
self._neighborlist.fuzzyval = config.val.ui.default_zoom
|
self._neighborlist.fuzzyval = config.val.zoom.default
|
||||||
|
|
||||||
def offset(self, offset):
|
def offset(self, offset):
|
||||||
"""Increase/Decrease the zoom level by the given offset.
|
"""Increase/Decrease the zoom level by the given offset.
|
||||||
@ -310,8 +310,7 @@ class AbstractZoom(QObject):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def set_default(self):
|
def set_default(self):
|
||||||
default_zoom = config.val.ui.default_zoom
|
self._set_factor_internal(float(config.val.zoom.default) / 100)
|
||||||
self._set_factor_internal(float(default_zoom) / 100)
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractCaret(QObject):
|
class AbstractCaret(QObject):
|
||||||
|
@ -888,7 +888,7 @@ class CommandDispatcher:
|
|||||||
|
|
||||||
level = count if count is not None else zoom
|
level = count if count is not None else zoom
|
||||||
if level is None:
|
if level is None:
|
||||||
level = config.val.ui.default_zoom
|
level = config.val.zoom.default
|
||||||
tab = self._current_widget()
|
tab = self._current_widget()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -735,7 +735,7 @@ class AbstractDownloadManager(QObject):
|
|||||||
download.remove_requested.connect(functools.partial(
|
download.remove_requested.connect(functools.partial(
|
||||||
self._remove_item, download))
|
self._remove_item, download))
|
||||||
|
|
||||||
delay = config.val.ui.remove_finished_downloads
|
delay = config.val.downloads.remove_finished
|
||||||
if delay > -1:
|
if delay > -1:
|
||||||
download.finished.connect(
|
download.finished.connect(
|
||||||
lambda: QTimer.singleShot(delay, download.remove))
|
lambda: QTimer.singleShot(delay, download.remove))
|
||||||
|
@ -368,7 +368,7 @@ class DownloadManager(downloads.AbstractDownloadManager):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self._networkmanager = networkmanager.NetworkManager(
|
self._networkmanager = networkmanager.NetworkManager(
|
||||||
win_id=win_id, tab_id=None,
|
win_id=win_id, tab_id=None,
|
||||||
private=config.val.private_browsing, parent=self)
|
private=config.val.content.private_browsing, parent=self)
|
||||||
|
|
||||||
@pyqtSlot('QUrl')
|
@pyqtSlot('QUrl')
|
||||||
def get(self, url, *, user_agent=None, **kwargs):
|
def get(self, url, *, user_agent=None, **kwargs):
|
||||||
|
@ -285,7 +285,7 @@ def qute_history(url):
|
|||||||
return 'text/html', jinja.render(
|
return 'text/html', jinja.render(
|
||||||
'history.html',
|
'history.html',
|
||||||
title='History',
|
title='History',
|
||||||
session_interval=config.val.ui.history_session_interval
|
session_interval=config.val.history_session_interval
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Get current date from query parameter, if not given choose today.
|
# Get current date from query parameter, if not given choose today.
|
||||||
|
@ -72,7 +72,7 @@ def authentication_required(url, authenticator, abort_on):
|
|||||||
def javascript_confirm(url, js_msg, abort_on):
|
def javascript_confirm(url, js_msg, abort_on):
|
||||||
"""Display a javascript confirm prompt."""
|
"""Display a javascript confirm prompt."""
|
||||||
log.js.debug("confirm: {}".format(js_msg))
|
log.js.debug("confirm: {}".format(js_msg))
|
||||||
if config.val.ui.modal_js_dialog:
|
if config.val.content.javascript.modal_dialog:
|
||||||
raise CallSuper
|
raise CallSuper
|
||||||
|
|
||||||
msg = 'From <b>{}</b>:<br/>{}'.format(html.escape(url.toDisplayString()),
|
msg = 'From <b>{}</b>:<br/>{}'.format(html.escape(url.toDisplayString()),
|
||||||
@ -86,7 +86,7 @@ def javascript_confirm(url, js_msg, abort_on):
|
|||||||
def javascript_prompt(url, js_msg, default, abort_on):
|
def javascript_prompt(url, js_msg, default, abort_on):
|
||||||
"""Display a javascript prompt."""
|
"""Display a javascript prompt."""
|
||||||
log.js.debug("prompt: {}".format(js_msg))
|
log.js.debug("prompt: {}".format(js_msg))
|
||||||
if config.val.ui.modal_js_dialog:
|
if config.val.content.javascript.modal_dialog:
|
||||||
raise CallSuper
|
raise CallSuper
|
||||||
if config.val.content.ignore_javascript_prompt:
|
if config.val.content.ignore_javascript_prompt:
|
||||||
return (False, "")
|
return (False, "")
|
||||||
@ -107,7 +107,7 @@ def javascript_prompt(url, js_msg, default, abort_on):
|
|||||||
def javascript_alert(url, js_msg, abort_on):
|
def javascript_alert(url, js_msg, abort_on):
|
||||||
"""Display a javascript alert."""
|
"""Display a javascript alert."""
|
||||||
log.js.debug("alert: {}".format(js_msg))
|
log.js.debug("alert: {}".format(js_msg))
|
||||||
if config.val.ui.modal_js_dialog:
|
if config.val.content.javascript.modal_dialog:
|
||||||
raise CallSuper
|
raise CallSuper
|
||||||
|
|
||||||
if config.val.content.ignore_javascript_alert:
|
if config.val.content.ignore_javascript_alert:
|
||||||
@ -233,7 +233,7 @@ def get_tab(win_id, target):
|
|||||||
|
|
||||||
def get_user_stylesheet():
|
def get_user_stylesheet():
|
||||||
"""Get the combined user-stylesheet."""
|
"""Get the combined user-stylesheet."""
|
||||||
filename = config.val.ui.user_stylesheet
|
filename = config.val.content.user_stylesheet
|
||||||
|
|
||||||
if filename is None:
|
if filename is None:
|
||||||
css = ''
|
css = ''
|
||||||
@ -241,7 +241,7 @@ def get_user_stylesheet():
|
|||||||
with open(filename, 'r', encoding='utf-8') as f:
|
with open(filename, 'r', encoding='utf-8') as f:
|
||||||
css = f.read()
|
css = f.read()
|
||||||
|
|
||||||
if config.val.ui.hide_scrollbar:
|
if config.val.scrolling.bar:
|
||||||
css += '\nhtml > ::-webkit-scrollbar { width: 0px; height: 0px; }'
|
css += '\nhtml > ::-webkit-scrollbar { width: 0px; height: 0px; }'
|
||||||
|
|
||||||
return css
|
return css
|
||||||
|
@ -168,7 +168,7 @@ class WebKitElement(webelem.AbstractWebElement):
|
|||||||
if width > 1 and height > 1:
|
if width > 1 and height > 1:
|
||||||
# fix coordinates according to zoom level
|
# fix coordinates according to zoom level
|
||||||
zoom = self._elem.webFrame().zoomFactor()
|
zoom = self._elem.webFrame().zoomFactor()
|
||||||
if not config.val.ui.zoom_text_only:
|
if not config.val.zoom.text_only:
|
||||||
rect["left"] *= zoom
|
rect["left"] *= zoom
|
||||||
rect["top"] *= zoom
|
rect["top"] *= zoom
|
||||||
width *= zoom
|
width *= zoom
|
||||||
|
@ -132,7 +132,7 @@ def init(_args):
|
|||||||
QWebSettings.setOfflineStoragePath(
|
QWebSettings.setOfflineStoragePath(
|
||||||
os.path.join(data_path, 'offline-storage'))
|
os.path.join(data_path, 'offline-storage'))
|
||||||
|
|
||||||
if (config.val.private_browsing and
|
if (config.val.content.private_browsing and
|
||||||
not qtutils.version_check('5.4.2')):
|
not qtutils.version_check('5.4.2')):
|
||||||
# WORKAROUND for https://codereview.qt-project.org/#/c/108936/
|
# WORKAROUND for https://codereview.qt-project.org/#/c/108936/
|
||||||
# Won't work when private browsing is not enabled globally, but that's
|
# Won't work when private browsing is not enabled globally, but that's
|
||||||
|
@ -163,7 +163,7 @@ class MainWindow(QWidget):
|
|||||||
self._init_downloadmanager()
|
self._init_downloadmanager()
|
||||||
self._downloadview = downloadview.DownloadView(self.win_id)
|
self._downloadview = downloadview.DownloadView(self.win_id)
|
||||||
|
|
||||||
if config.val.private_browsing:
|
if config.val.content.private_browsing:
|
||||||
# This setting always trumps what's passed in.
|
# This setting always trumps what's passed in.
|
||||||
private = True
|
private = True
|
||||||
else:
|
else:
|
||||||
@ -250,7 +250,7 @@ class MainWindow(QWidget):
|
|||||||
left = (self.width() - width) / 2 if centered else 0
|
left = (self.width() - width) / 2 if centered else 0
|
||||||
|
|
||||||
height_padding = 20
|
height_padding = 20
|
||||||
status_position = config.val.ui.status_position
|
status_position = config.val.statusbar.position
|
||||||
if status_position == 'bottom':
|
if status_position == 'bottom':
|
||||||
if self.status.isVisible():
|
if self.status.isVisible():
|
||||||
status_height = self.status.height()
|
status_height = self.status.height()
|
||||||
@ -341,10 +341,9 @@ class MainWindow(QWidget):
|
|||||||
self._vbox.removeWidget(self.tabbed_browser)
|
self._vbox.removeWidget(self.tabbed_browser)
|
||||||
self._vbox.removeWidget(self._downloadview)
|
self._vbox.removeWidget(self._downloadview)
|
||||||
self._vbox.removeWidget(self.status)
|
self._vbox.removeWidget(self.status)
|
||||||
downloads_position = config.val.ui.downloads_position
|
|
||||||
status_position = config.val.ui.status_position
|
|
||||||
widgets = [self.tabbed_browser]
|
widgets = [self.tabbed_browser]
|
||||||
|
|
||||||
|
downloads_position = config.val.downloads.position
|
||||||
if downloads_position == 'top':
|
if downloads_position == 'top':
|
||||||
widgets.insert(0, self._downloadview)
|
widgets.insert(0, self._downloadview)
|
||||||
elif downloads_position == 'bottom':
|
elif downloads_position == 'bottom':
|
||||||
@ -352,6 +351,7 @@ class MainWindow(QWidget):
|
|||||||
else:
|
else:
|
||||||
raise ValueError("Invalid position {}!".format(downloads_position))
|
raise ValueError("Invalid position {}!".format(downloads_position))
|
||||||
|
|
||||||
|
status_position = config.val.statusbar.position
|
||||||
if status_position == 'top':
|
if status_position == 'top':
|
||||||
widgets.insert(0, self.status)
|
widgets.insert(0, self.status)
|
||||||
elif status_position == 'bottom':
|
elif status_position == 'bottom':
|
||||||
@ -536,23 +536,22 @@ class MainWindow(QWidget):
|
|||||||
if crashsignal.is_crashing:
|
if crashsignal.is_crashing:
|
||||||
e.accept()
|
e.accept()
|
||||||
return
|
return
|
||||||
confirm_quit = config.val.ui.confirm_quit
|
|
||||||
tab_count = self.tabbed_browser.count()
|
tab_count = self.tabbed_browser.count()
|
||||||
download_model = objreg.get('download-model', scope='window',
|
download_model = objreg.get('download-model', scope='window',
|
||||||
window=self.win_id)
|
window=self.win_id)
|
||||||
download_count = download_model.running_downloads()
|
download_count = download_model.running_downloads()
|
||||||
quit_texts = []
|
quit_texts = []
|
||||||
# Ask if multiple-tabs are open
|
# Ask if multiple-tabs are open
|
||||||
if 'multiple-tabs' in confirm_quit and tab_count > 1:
|
if 'multiple-tabs' in config.val.confirm_quit and tab_count > 1:
|
||||||
quit_texts.append("{} {} open.".format(
|
quit_texts.append("{} {} open.".format(
|
||||||
tab_count, "tab is" if tab_count == 1 else "tabs are"))
|
tab_count, "tab is" if tab_count == 1 else "tabs are"))
|
||||||
# Ask if multiple downloads running
|
# Ask if multiple downloads running
|
||||||
if 'downloads' in confirm_quit and download_count > 0:
|
if 'downloads' in config.val.confirm_quit and download_count > 0:
|
||||||
quit_texts.append("{} {} running.".format(
|
quit_texts.append("{} {} running.".format(
|
||||||
download_count,
|
download_count,
|
||||||
"download is" if download_count == 1 else "downloads are"))
|
"download is" if download_count == 1 else "downloads are"))
|
||||||
# Process all quit messages that user must confirm
|
# Process all quit messages that user must confirm
|
||||||
if quit_texts or 'always' in confirm_quit:
|
if quit_texts or 'always' in config.val.confirm_quit:
|
||||||
msg = jinja2.Template("""
|
msg = jinja2.Template("""
|
||||||
<ul>
|
<ul>
|
||||||
{% for text in quit_texts %}
|
{% for text in quit_texts %}
|
||||||
|
@ -126,7 +126,7 @@ class MessageView(QWidget):
|
|||||||
widget = Message(level, text, replace=replace, parent=self)
|
widget = Message(level, text, replace=replace, parent=self)
|
||||||
self._vbox.addWidget(widget)
|
self._vbox.addWidget(widget)
|
||||||
widget.show()
|
widget.show()
|
||||||
if config.val.ui.message_timeout != 0:
|
if config.val.messages.timeout != 0:
|
||||||
self._clear_timer.start()
|
self._clear_timer.start()
|
||||||
self._messages.append(widget)
|
self._messages.append(widget)
|
||||||
self._last_text = text
|
self._last_text = text
|
||||||
|
@ -233,14 +233,13 @@ class PromptContainer(QWidget):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
STYLESHEET = """
|
STYLESHEET = """
|
||||||
{% set prompt_radius = config.val.ui.prompt_radius %}
|
|
||||||
QWidget#PromptContainer {
|
QWidget#PromptContainer {
|
||||||
{% if config.val.ui.status_position == 'top' %}
|
{% if config.val.statusbar.position == 'top' %}
|
||||||
border-bottom-left-radius: {{ prompt_radius }}px;
|
border-bottom-left-radius: {{ config.val.prompt.radius }}px;
|
||||||
border-bottom-right-radius: {{ prompt_radius }}px;
|
border-bottom-right-radius: {{ config.val.prompt.radius }}px;
|
||||||
{% else %}
|
{% else %}
|
||||||
border-top-left-radius: {{ prompt_radius }}px;
|
border-top-left-radius: {{ config.val.prompt.radius }}px;
|
||||||
border-top-right-radius: {{ prompt_radius }}px;
|
border-top-right-radius: {{ config.val.prompt.radius }}px;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +565,7 @@ class FilenamePrompt(_BasePrompt):
|
|||||||
self.setFocusProxy(self._lineedit)
|
self.setFocusProxy(self._lineedit)
|
||||||
self._init_key_label()
|
self._init_key_label()
|
||||||
|
|
||||||
if config.val.ui.prompt_filebrowser:
|
if config.val.ui.prompt.filebrowser:
|
||||||
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
@ -628,7 +627,7 @@ class FilenamePrompt(_BasePrompt):
|
|||||||
self._file_view.setModel(self._file_model)
|
self._file_view.setModel(self._file_model)
|
||||||
self._file_view.clicked.connect(self._insert_path)
|
self._file_view.clicked.connect(self._insert_path)
|
||||||
|
|
||||||
if config.val.ui.prompt_filebrowser:
|
if config.val.ui.prompt.filebrowser:
|
||||||
self._vbox.addWidget(self._file_view)
|
self._vbox.addWidget(self._file_view)
|
||||||
else:
|
else:
|
||||||
self._file_view.hide()
|
self._file_view.hide()
|
||||||
|
@ -211,15 +211,15 @@ class StatusBar(QWidget):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def maybe_hide(self):
|
def maybe_hide(self):
|
||||||
"""Hide the statusbar if it's configured to do so."""
|
"""Hide the statusbar if it's configured to do so."""
|
||||||
hide = config.val.ui.hide_statusbar
|
|
||||||
tab = self._current_tab()
|
tab = self._current_tab()
|
||||||
|
hide = config.val.statusbar.hide
|
||||||
if hide or (tab is not None and tab.data.fullscreen):
|
if hide or (tab is not None and tab.data.fullscreen):
|
||||||
self.hide()
|
self.hide()
|
||||||
else:
|
else:
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def _set_hbox_padding(self):
|
def _set_hbox_padding(self):
|
||||||
padding = config.val.ui.statusbar_padding
|
padding = config.val.statusbar.padding
|
||||||
self._hbox.setContentsMargins(padding.left, 0, padding.right, 0)
|
self._hbox.setContentsMargins(padding.left, 0, padding.right, 0)
|
||||||
|
|
||||||
@pyqtProperty('QStringList')
|
@pyqtProperty('QStringList')
|
||||||
@ -344,7 +344,7 @@ class StatusBar(QWidget):
|
|||||||
|
|
||||||
def minimumSizeHint(self):
|
def minimumSizeHint(self):
|
||||||
"""Set the minimum height to the text height plus some padding."""
|
"""Set the minimum height to the text height plus some padding."""
|
||||||
padding = config.val.ui.statusbar_padding
|
padding = config.val.statusbar.padding
|
||||||
width = super().minimumSizeHint().width()
|
width = super().minimumSizeHint().width()
|
||||||
height = self.fontMetrics().height() + padding.top + padding.bottom
|
height = self.fontMetrics().height() + padding.top + padding.bottom
|
||||||
return QSize(width, height)
|
return QSize(width, height)
|
||||||
|
@ -432,7 +432,7 @@ class ExceptionCrashDialog(_CrashDialog):
|
|||||||
self._chk_log = QCheckBox("Include a debug log in the report",
|
self._chk_log = QCheckBox("Include a debug log in the report",
|
||||||
checked=True)
|
checked=True)
|
||||||
try:
|
try:
|
||||||
if config.val.private_browsing:
|
if config.val.content.private_browsing:
|
||||||
self._chk_log.setChecked(False)
|
self._chk_log.setChecked(False)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.misc.exception("Error while checking private browsing mode")
|
log.misc.exception("Error while checking private browsing mode")
|
||||||
@ -524,7 +524,7 @@ class FatalCrashDialog(_CrashDialog):
|
|||||||
"accessed pages in the report.",
|
"accessed pages in the report.",
|
||||||
checked=True)
|
checked=True)
|
||||||
try:
|
try:
|
||||||
if config.val.private_browsing:
|
if config.val.content.private_browsing:
|
||||||
self._chk_history.setChecked(False)
|
self._chk_history.setChecked(False)
|
||||||
except Exception:
|
except Exception:
|
||||||
log.misc.exception("Error while checking private browsing mode")
|
log.misc.exception("Error while checking private browsing mode")
|
||||||
|
@ -51,7 +51,7 @@ class KeyHintView(QLabel):
|
|||||||
color: {{ color['keyhint.fg'] }};
|
color: {{ color['keyhint.fg'] }};
|
||||||
background-color: {{ color['keyhint.bg'] }};
|
background-color: {{ color['keyhint.bg'] }};
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
{% if config.val.ui.status_position == 'top' %}
|
{% if config.val.statusbar.position == 'top' %}
|
||||||
border-bottom-right-radius: 6px;
|
border-bottom-right-radius: 6px;
|
||||||
{% else %}
|
{% else %}
|
||||||
border-top-right-radius: 6px;
|
border-top-right-radius: 6px;
|
||||||
@ -90,7 +90,7 @@ class KeyHintView(QLabel):
|
|||||||
self.hide()
|
self.hide()
|
||||||
return
|
return
|
||||||
|
|
||||||
blacklist = config.val.ui.keyhint_blacklist or []
|
blacklist = config.val.keyhint.blacklist or []
|
||||||
keyconf = objreg.get('key-config')
|
keyconf = objreg.get('key-config')
|
||||||
|
|
||||||
def blacklisted(keychain):
|
def blacklisted(keychain):
|
||||||
@ -107,7 +107,7 @@ class KeyHintView(QLabel):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# delay so a quickly typed keychain doesn't display hints
|
# delay so a quickly typed keychain doesn't display hints
|
||||||
self._show_timer.setInterval(config.val.ui.keyhint_delay)
|
self._show_timer.setInterval(config.val.keyhint.delay)
|
||||||
self._show_timer.start()
|
self._show_timer.start()
|
||||||
suffix_color = html.escape(config.val.colors.keyhint.fg.suffix)
|
suffix_color = html.escape(config.val.colors.keyhint.fg.suffix)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user