From e828f5b81247481d95c87fe13ebe566a9478f0fc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 13 Jun 2017 16:15:41 +0200 Subject: [PATCH] Fix most config changed handlers --- qutebrowser/browser/browsertab.py | 6 +++--- qutebrowser/completion/completionwidget.py | 8 +++----- qutebrowser/mainwindow/mainwindow.py | 12 +++++------- qutebrowser/mainwindow/statusbar/bar.py | 10 ++++------ qutebrowser/mainwindow/tabwidget.py | 11 +++++------ 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index d33c7b046..81cf190a0 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -260,9 +260,9 @@ class AbstractZoom(QObject): # self.destroyed.connect(functools.partial( # cfg.changed.disconnect, self.init_neighborlist)) - @pyqtSlot(str, str) - def _on_config_changed(self, section, option): - if section == 'ui' and option in ['zoom-levels', 'default-zoom']: + @pyqtSlot(str) + def _on_config_changed(self, option): + if option in ['zoom.levels', 'zoom.default']: if not self._default_zoom_changed: factor = float(config.val.zoom.default) / 100 self._set_factor_internal(factor) diff --git a/qutebrowser/completion/completionwidget.py b/qutebrowser/completion/completionwidget.py index bd38e065a..62711aa5f 100644 --- a/qutebrowser/completion/completionwidget.py +++ b/qutebrowser/completion/completionwidget.py @@ -141,11 +141,9 @@ class CompletionView(QTreeView): def __repr__(self): return utils.get_repr(self) - @pyqtSlot(str, str) - def _on_config_changed(self, section, option): - if section != 'completion': - return - if option in ['height', 'shrink']: + @pyqtSlot(str) + def _on_config_changed(self, option): + if option in ['completion.height', 'completion.shrink']: self.update_geometry.emit() def _resize_columns(self): diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 2483a37b0..5df4aedef 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -323,16 +323,14 @@ class MainWindow(QWidget): def __repr__(self): return utils.get_repr(self) - @pyqtSlot(str, str) - def on_config_changed(self, section, option): + @pyqtSlot(str) + def on_config_changed(self, option): """Resize the completion if related config options changed.""" - if section != 'ui': - return - if option == 'statusbar-padding': + if option == 'statusbar.padding': self._update_overlay_geometries() - elif option == 'downloads-position': + elif option == 'downloads.position': self._add_widgets() - elif option == 'status-position': + elif option == 'statusbar.position': self._add_widgets() self._update_overlay_geometries() diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py index d89a1ded1..dcabdc6ab 100644 --- a/qutebrowser/mainwindow/statusbar/bar.py +++ b/qutebrowser/mainwindow/statusbar/bar.py @@ -199,13 +199,11 @@ class StatusBar(QWidget): def __repr__(self): return utils.get_repr(self) - @pyqtSlot(str, str) - def _on_config_changed(self, section, option): - if section != 'ui': - return - if option == 'hide-statusbar': + @pyqtSlot(str) + def _on_config_changed(self, option): + if option == 'statusbar.hide': self.maybe_hide() - elif option == 'statusbar-pdading': + elif option == 'statusbar.padding': self._set_hbox_padding() @pyqtSlot() diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py index f5301e18a..6034a3ce1 100644 --- a/qutebrowser/mainwindow/tabwidget.py +++ b/qutebrowser/mainwindow/tabwidget.py @@ -189,10 +189,9 @@ class TabWidget(QTabWidget): fields['scroll_pos'] = scroll_pos return fields - def update_tab_titles(self, section='tabs', option='title-format'): + def update_tab_titles(self, option='tabs.title.format'): """Update all texts.""" - if section == 'tabs' and option in ['title-format', - 'title-format-pinned']: + if option in ['tabs.title.format', 'tabs.title.format_pinned']: for idx in range(self.count()): self.update_tab_title(idx) @@ -426,10 +425,10 @@ class TabBar(QTabBar): p.setColor(QPalette.Window, config.val.colors.tabs.bar.bg) self.setPalette(p) - @pyqtSlot(str, str) - def on_tab_colors_changed(self, section, option): + @pyqtSlot(str) + def on_tab_colors_changed(self, option): """Set the tab colors.""" - if section == 'colors' and option.startswith('tabs.'): + if option.startswith('colors.tabs.'): self.update() def mousePressEvent(self, e):