From 72340575af8c6fdb74020cbf6defb744e084826e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 17 Apr 2014 11:39:25 +0200 Subject: [PATCH] Remove value from on_config_changed signal again. Turns out this causes more trouble than it's worth, and it's unintuitive from which layer we get the value. --- qutebrowser/commands/keys.py | 5 +++-- qutebrowser/config/config.py | 4 ++-- qutebrowser/config/lineparser.py | 9 ++++++--- qutebrowser/config/websettings.py | 5 +++-- qutebrowser/widgets/browsertab.py | 5 ++--- qutebrowser/widgets/completion.py | 6 +++--- qutebrowser/widgets/mainwindow.py | 5 ++--- qutebrowser/widgets/tabbedbrowser.py | 8 ++++---- qutebrowser/widgets/tabwidget.py | 5 ++--- 9 files changed, 27 insertions(+), 25 deletions(-) diff --git a/qutebrowser/commands/keys.py b/qutebrowser/commands/keys.py index 71df504fa..cbaad54a0 100644 --- a/qutebrowser/commands/keys.py +++ b/qutebrowser/commands/keys.py @@ -230,8 +230,9 @@ class KeyParser(QObject): self.set_cmd_text.emit(':{} '.format(cmdstr)) return - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + # pylint: disable=unused-argument + @pyqtSlot(str, str) + def on_config_changed(self, section, option): if section == 'keybind': self.read_config() diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 714f5c4dc..0e4c5001e 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -94,7 +94,7 @@ class Config(QObject): Args: the changed section and option. """ - changed = pyqtSignal(str, str, object) + changed = pyqtSignal(str, str) style_changed = pyqtSignal(str, str) def __init__(self, configdir, fname, parent=None): @@ -327,7 +327,7 @@ class Config(QObject): else: if section in ['colors', 'fonts']: self.style_changed.emit(section, option) - self.changed.emit(section, option, self.get(section, option)) + self.changed.emit(section, option) @cmdutils.register(instance='config') def save(self): diff --git a/qutebrowser/config/lineparser.py b/qutebrowser/config/lineparser.py index b429327d1..e246a03ac 100644 --- a/qutebrowser/config/lineparser.py +++ b/qutebrowser/config/lineparser.py @@ -20,6 +20,7 @@ import os import os.path import logging + from PyQt5.QtCore import pyqtSlot @@ -73,7 +74,7 @@ class LineConfigParser: if not self.data: logging.debug("No data to save.") return - import qutebrowser.config.config as config + import qutebrowser.config.config as config # FIXME limit = -1 if self._limit is None else config.config.get(*self._limit) if limit == 0: return @@ -83,11 +84,13 @@ class LineConfigParser: with open(self._configfile, 'w') as f: self.write(f, limit) - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + @pyqtSlot(str, str) + def on_config_changed(self, section, option): """Delete the file if the limit was changed to 0.""" if self._limit is None: return + import qutebrowser.config.config as config # FIXME + value = config.config.get(section, option) if (section, option) == self._limit and value == 0: if os.path.exists(self._configfile): os.remove(self._configfile) diff --git a/qutebrowser/config/websettings.py b/qutebrowser/config/websettings.py index 6ac410f7d..2a4cdfe15 100644 --- a/qutebrowser/config/websettings.py +++ b/qutebrowser/config/websettings.py @@ -68,8 +68,9 @@ def init(): settings.setAttribute(item, config.config.get('webkit', name)) -@pyqtSlot(str, str, object) -def on_config_changed(section, option, value): +@pyqtSlot(str, str) +def on_config_changed(section, option): """Update global settings when qwebsettings changed.""" if section == 'webkit': + value = config.config.get(section, option) settings.setAttribute(MAPPING[option], value) diff --git a/qutebrowser/widgets/browsertab.py b/qutebrowser/widgets/browsertab.py index cfed01c12..01730d997 100644 --- a/qutebrowser/widgets/browsertab.py +++ b/qutebrowser/widgets/browsertab.py @@ -176,9 +176,8 @@ class BrowserTab(QWebView): netman.deleteLater() logging.debug("Tab shutdown scheduled") - # pylint: disable=unused-argument - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + @pyqtSlot(str, str) + def on_config_changed(self, section, option): """Update tab config when config was changed.""" if section == 'general' and option in ['zoomlevels', 'defaultzoom']: self._init_neighborlist() diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index 216366c66..1aa09eac5 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -211,11 +211,11 @@ class CompletionView(QTreeView): self.expandAll() self.resizeColumnToContents(0) - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + @pyqtSlot(str, str) + def on_config_changed(self, section, option): """Update self._enabled when the config changed.""" if section == 'general' and option == 'show_completion': - self._enabled = value + self._enabled = config.config.get('general', 'show_completion') @pyqtSlot(str) def on_cmd_text_changed(self, text): diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 4a10726f0..ac7575f85 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -106,9 +106,8 @@ class MainWindow(QWidget): #self.tabWidget.setCurrentIndex(0) #QtCore.QMetaObject.connectSlotsByName(MainWindow) - # pylint: disable=unused-argument - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + @pyqtSlot(str, str) + def on_config_changed(self, section, option): """Resize completion if config changed.""" if section == 'general' and option == 'completion_height': self.resize_completion() diff --git a/qutebrowser/widgets/tabbedbrowser.py b/qutebrowser/widgets/tabbedbrowser.py index 69839fd6c..3bca8b0b0 100644 --- a/qutebrowser/widgets/tabbedbrowser.py +++ b/qutebrowser/widgets/tabbedbrowser.py @@ -141,12 +141,12 @@ class TabbedBrowser(TabWidget): else: return None - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + @pyqtSlot(str, str) + def on_config_changed(self, section, option): """Update tab config when config was changed.""" - super().on_config_changed(section, option, value) + super().on_config_changed(section, option) for tab in self._tabs: - tab.on_config_changed(section, option, value) + tab.on_config_changed(section, option) def _titleChanged_handler(self, text): """Set the title of a tab. diff --git a/qutebrowser/widgets/tabwidget.py b/qutebrowser/widgets/tabwidget.py index 6a9d72804..47b3455fb 100644 --- a/qutebrowser/widgets/tabwidget.py +++ b/qutebrowser/widgets/tabwidget.py @@ -99,9 +99,8 @@ class TabWidget(QTabWidget): except KeyError: pass - # pylint: disable=unused-argument - @pyqtSlot(str, str, object) - def on_config_changed(self, section, option, value): + @pyqtSlot(str, str) + def on_config_changed(self, section, option): """Update attributes when config changed.""" if section == 'tabbar': self._init_config()