From 65aee9d9911b3a121be5bb5c5274f4e3fa5086b6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 17 May 2014 23:45:31 +0200 Subject: [PATCH] Add ui section to config --- qutebrowser/config/configdata.py | 23 +++++++++++++---------- qutebrowser/widgets/statusbar/bar.py | 8 ++++---- qutebrowser/widgets/webview.py | 14 +++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 78d2fd035..e984d2639 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -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'), diff --git a/qutebrowser/widgets/statusbar/bar.py b/qutebrowser/widgets/statusbar/bar.py index ff3bf1e2e..e4c88968f 100644 --- a/qutebrowser/widgets/statusbar/bar.py +++ b/qutebrowser/widgets/statusbar/bar.py @@ -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. diff --git a/qutebrowser/widgets/webview.py b/qutebrowser/widgets/webview.py index 6ffb8e9f3..45707db98 100644 --- a/qutebrowser/widgets/webview.py +++ b/qutebrowser/widgets/webview.py @@ -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):