Add ui section to config

This commit is contained in:
Florian Bruhin 2014-05-17 23:45:31 +02:00
parent 49ad41949a
commit 65aee9d991
3 changed files with 24 additions and 21 deletions

View File

@ -61,6 +61,7 @@ FIRST_COMMENT = r"""
SECTION_DESC = {
'general': "General/misc. options.",
'ui': "General options related to the user interface.",
'input': "Options related to input modes.",
'network': "Settings related to the network.",
'completion': "Options related to completion and command history.",
@ -170,16 +171,6 @@ DATA = OrderedDict([
"Whether to start a search when something else than a URL is "
"entered."),
('zoom-levels',
SettingValue(types.PercList(minval=0),
'25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,200%,'
'250%,300%,400%,500%'),
"The available zoom levels, separated by commas."),
('default-zoom',
SettingValue(types.ZoomPerc(), '100%'),
"The default zoom level."),
('auto-save-config',
SettingValue(types.Bool(), 'true'),
"Whether to save the config automatically on quit."),
@ -197,6 +188,18 @@ DATA = OrderedDict([
SettingValue(types.ShellCommand(placeholder=True), 'gvim -f "{}"'),
"The editor (and arguments) to use for the open-editor binding. "
"Use {} for the filename. Gets split via shutils."),
)),
('ui', sect.KeyValue(
('zoom-levels',
SettingValue(types.PercList(minval=0),
'25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,200%,'
'250%,300%,400%,500%'),
"The available zoom levels, separated by commas."),
('default-zoom',
SettingValue(types.ZoomPerc(), '100%'),
"The default zoom level."),
('show-scroll-bar-horizontal',
SettingValue(types.ScrollBarPolicy(), 'never'),

View File

@ -117,7 +117,7 @@ class StatusBar(QWidget):
self._text_queue = deque()
self._text_pop_timer = QTimer()
self._text_pop_timer.setInterval(
config.get('general', 'message-timeout'))
config.get('ui', 'message-timeout'))
self._text_pop_timer.timeout.connect(self._pop_text)
self.cmd.show_cmd.connect(self._show_cmd_widget)
@ -192,7 +192,7 @@ class StatusBar(QWidget):
"""
logging.debug("Displaying text: {} (error={})".format(text, error))
now = datetime.now()
mindelta = config.get('general', 'message-timeout')
mindelta = config.get('ui', 'message-timeout')
delta = (None if self._last_text_time is None
else now - self._last_text_time)
self._last_text_time = now
@ -271,9 +271,9 @@ class StatusBar(QWidget):
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update message timeout when config changed."""
if section == 'general' and option == 'message-timeout':
if section == 'ui' and option == 'message-timeout':
self._text_pop_timer.setInterval(
config.get('general', 'message-timeout'))
config.get('ui', 'message-timeout'))
def resizeEvent(self, e):
"""Extend resizeEvent of QWidget to emit a resized signal afterwards.

View File

@ -112,9 +112,9 @@ class WebView(QWebView):
self.page_.networkAccessManager().sslErrors.connect(
lambda *args: setattr(self, '_has_ssl_errors', True))
self.page_.mainFrame().setScrollBarPolicy(
Qt.Horizontal, config.get('general', 'show-scroll-bar-horizontal'))
Qt.Horizontal, config.get('ui', 'show-scroll-bar-horizontal'))
self.page_.mainFrame().setScrollBarPolicy(
Qt.Vertical, config.get('general', 'show-scroll-bar-vertical'))
Qt.Vertical, config.get('ui', 'show-scroll-bar-vertical'))
def __repr__(self):
return "WebView(url='{}')".format(
@ -155,8 +155,8 @@ class WebView(QWebView):
def _init_neighborlist(self):
"""Initialize the _zoom neighborlist."""
self._zoom = NeighborList(
config.get('general', 'zoom-levels'),
default=config.get('general', 'default-zoom'),
config.get('ui', 'zoom-levels'),
default=config.get('ui', 'default-zoom'),
mode=NeighborList.Modes.block)
def _on_destroyed(self, sender):
@ -399,17 +399,17 @@ class WebView(QWebView):
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update tab config when config was changed."""
if section == 'general':
if section == 'ui':
if option in ['zoom-levels', 'default-zoom']:
self._init_neighborlist()
elif option == 'show-scroll-bar-horizontal':
self.page_.mainFrame().setScrollBarPolicy(
Qt.Horizontal,
config.get('general', 'show-scroll-bar-horizontal'))
config.get('ui', 'show-scroll-bar-horizontal'))
elif option == 'show-scroll-bar-vertical':
self.page_.mainFrame().setScrollBarPolicy(
Qt.Vertical,
config.get('general', 'show-scroll-bar-vertical'))
config.get('ui', 'show-scroll-bar-vertical'))
@pyqtSlot('QMouseEvent')
def on_mouse_event(self, evt):