Add value to config.changed signal

This commit is contained in:
Florian Bruhin 2014-04-16 09:21:27 +02:00
parent a410d56a78
commit 4ca8cc9537
6 changed files with 23 additions and 18 deletions

View File

@ -88,12 +88,12 @@ class Config(QObject):
Signals: Signals:
changed: Gets emitted when the config has changed. changed: Gets emitted when the config has changed.
Args: the changed section and option. Args: the changed section, option and new value.
style_changed: When style caches need to be invalidated. style_changed: When style caches need to be invalidated.
Args: the changed section and option. Args: the changed section and option.
""" """
changed = pyqtSignal(str, str) changed = pyqtSignal(str, str, object)
style_changed = pyqtSignal(str, str) style_changed = pyqtSignal(str, str)
def __init__(self, configdir, fname, parent=None): def __init__(self, configdir, fname, parent=None):
@ -326,7 +326,7 @@ class Config(QObject):
else: else:
if section in ['colors', 'fonts']: if section in ['colors', 'fonts']:
self.style_changed.emit(section, option) self.style_changed.emit(section, option)
self.changed.emit(section, option) self.changed.emit(section, option, self.get(section, option))
@cmdutils.register(instance='config') @cmdutils.register(instance='config')
def save(self): def save(self):
@ -459,12 +459,12 @@ class LineConfigParser:
with open(self._configfile, 'w') as f: with open(self._configfile, 'w') as f:
self.write(f, limit) self.write(f, limit)
@pyqtSlot(str, str) @pyqtSlot(str, str, object)
def on_config_changed(self, section, option): def on_config_changed(self, section, option, value):
"""Delete the file if the limit was changed to 0.""" """Delete the file if the limit was changed to 0."""
if self._limit is None: if self._limit is None:
return return
if (section, option) == self._limit and config.get(*self._limit) == 0: if (section, option) == self._limit and value == 0:
if os.path.exists(self._configfile): if os.path.exists(self._configfile):
os.remove(self._configfile) os.remove(self._configfile)

View File

@ -176,7 +176,9 @@ class BrowserTab(QWebView):
netman.deleteLater() netman.deleteLater()
logging.debug("Tab shutdown scheduled") logging.debug("Tab shutdown scheduled")
def on_config_changed(self, section, option): # pylint: disable=unused-argument
@pyqtSlot(str, str, object)
def on_config_changed(self, section, option, value):
"""Update tab config when config was changed.""" """Update tab config when config was changed."""
if section == 'general' and option in ['zoomlevels', 'defaultzoom']: if section == 'general' and option in ['zoomlevels', 'defaultzoom']:
self._init_neighborlist() self._init_neighborlist()

View File

@ -211,11 +211,11 @@ class CompletionView(QTreeView):
self.expandAll() self.expandAll()
self.resizeColumnToContents(0) self.resizeColumnToContents(0)
@pyqtSlot(str, str) @pyqtSlot(str, str, object)
def on_config_changed(self, section, option): def on_config_changed(self, section, option, value):
"""Update self._enabled when the config changed.""" """Update self._enabled when the config changed."""
if section == 'general' and option == 'show_completion': if section == 'general' and option == 'show_completion':
self._enabled = config.config.get('general', 'show_completion') self._enabled = value
@pyqtSlot(str) @pyqtSlot(str)
def on_cmd_text_changed(self, text): def on_cmd_text_changed(self, text):

View File

@ -20,7 +20,7 @@
import binascii import binascii
from base64 import b64decode from base64 import b64decode
from PyQt5.QtCore import QRect, QPoint from PyQt5.QtCore import pyqtSlot, QRect, QPoint
from PyQt5.QtWidgets import QWidget, QVBoxLayout from PyQt5.QtWidgets import QWidget, QVBoxLayout
from qutebrowser.widgets.statusbar import StatusBar from qutebrowser.widgets.statusbar import StatusBar
@ -99,7 +99,9 @@ class MainWindow(QWidget):
#self.tabWidget.setCurrentIndex(0) #self.tabWidget.setCurrentIndex(0)
#QtCore.QMetaObject.connectSlotsByName(MainWindow) #QtCore.QMetaObject.connectSlotsByName(MainWindow)
def on_config_changed(self, section, option): # pylint: disable=unused-argument
@pyqtSlot(str, str, object)
def on_config_changed(self, section, option, value):
"""Resize completion if config changed.""" """Resize completion if config changed."""
if section == 'general' and option == 'completion_height': if section == 'general' and option == 'completion_height':
self.resize_completion() self.resize_completion()

View File

@ -99,8 +99,9 @@ class TabWidget(QTabWidget):
except KeyError: except KeyError:
pass pass
@pyqtSlot(str, str) @pyqtSlot(str, str, object)
def on_config_changed(self, section, option): def on_config_changed(self, section, option, value):
"""Update attributes when config changed.""" """Update attributes when config changed."""
# pylint: disable=unused-argument
if section == 'tabbar': if section == 'tabbar':
self._init_config() self._init_config()

View File

@ -139,12 +139,12 @@ class TabbedBrowser(TabWidget):
else: else:
return None return None
@pyqtSlot(str, str) @pyqtSlot(str, str, object)
def on_config_changed(self, section, option): def on_config_changed(self, section, option, value):
"""Update tab config when config was changed.""" """Update tab config when config was changed."""
super().on_config_changed(section, option) super().on_config_changed(section, option, value)
for tab in self._tabs: for tab in self._tabs:
tab.on_config_changed(section, option) tab.on_config_changed(section, option, value)
def _titleChanged_handler(self, text): def _titleChanged_handler(self, text):
"""Set the title of a tab. """Set the title of a tab.