Config update conversion

This commit is contained in:
Tim Bentley 2013-02-07 07:08:35 +00:00
parent 1430559205
commit 1576a2c1d4
5 changed files with 11 additions and 19 deletions

View File

@ -173,7 +173,7 @@ class Plugin(QtCore.QObject):
Settings.extend_default_settings(default_settings) Settings.extend_default_settings(default_settings)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name),
self.processAddServiceEvent) self.processAddServiceEvent)
Registry().register_function(u'%s_config_updated' % self.name, self.configUpdated) Registry().register_function(u'%s_config_updated' % self.name, self.config_update)
def checkPreConditions(self): def checkPreConditions(self):
""" """
@ -402,7 +402,7 @@ class Plugin(QtCore.QObject):
""" """
return u'' return u''
def configUpdated(self): def config_update(self):
""" """
The plugin's config has changed The plugin's config has changed
""" """

View File

@ -127,20 +127,12 @@ class Registry(object):
for function in self.functions_list[event]: for function in self.functions_list[event]:
try: try:
result = function(*args, **kwargs) result = function(*args, **kwargs)
# allow the result to be viewed in tests only.
if self.running_under_test is True:
self.inspect_result(result,*args, **kwargs)
if result: if result:
results.append(result) results.append(result)
except TypeError: except TypeError:
# Who has called me can help # Who has called me can help in debugging
import inspect import inspect
log.debug(inspect.currentframe().f_back.f_locals) log.debug(inspect.currentframe().f_back.f_locals)
log.exception(u'Exception for function %s', function) log.exception(u'Exception for function %s', function)
return results return results
def inspect_result(self, results,*args, **kwargs):
"""
Dummy method for tests to inspect the results of a call.
"""
pass

View File

@ -246,7 +246,7 @@ class BibleMediaItem(MediaManagerItem):
# Buttons # Buttons
QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton) QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton)
QtCore.QObject.connect(self.quickSearchButton, QtCore.SIGNAL(u'clicked()'), self.onQuickSearchButton) QtCore.QObject.connect(self.quickSearchButton, QtCore.SIGNAL(u'clicked()'), self.onQuickSearchButton)
Registry().register_function(u'config_updated', self.configUpdated) Registry().register_function(u'config_updated', self.config_update)
# Other stuff # Other stuff
QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton)
QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'), QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'),
@ -258,8 +258,8 @@ class BibleMediaItem(MediaManagerItem):
else: else:
self.advancedBookComboBox.setFocus() self.advancedBookComboBox.setFocus()
def configUpdated(self): def config_update(self):
log.debug(u'configUpdated') log.debug(u'config_update')
if Settings().value(self.settingsSection + u'/second bibles'): if Settings().value(self.settingsSection + u'/second bibles'):
self.advancedSecondLabel.setVisible(True) self.advancedSecondLabel.setVisible(True)
self.advancedSecondComboBox.setVisible(True) self.advancedSecondComboBox.setVisible(True)
@ -313,7 +313,7 @@ class BibleMediaItem(MediaManagerItem):
translate('BiblesPlugin.MediaItem', 'Search Text...')) translate('BiblesPlugin.MediaItem', 'Search Text...'))
]) ])
self.quickSearchEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection)) self.quickSearchEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection))
self.configUpdated() self.config_update()
log.debug(u'bible manager initialise complete') log.debug(u'bible manager initialise complete')
def loadBibles(self): def loadBibles(self):

View File

@ -95,7 +95,7 @@ class RemotesPlugin(Plugin):
u'title': translate('RemotePlugin', 'Remote', 'container title') u'title': translate('RemotePlugin', 'Remote', 'container title')
} }
def configUpdated(self): def config_update(self):
""" """
Called when Config is changed to restart the server on new address or Called when Config is changed to restart the server on new address or
port port

View File

@ -100,7 +100,7 @@ class SongMediaItem(MediaManagerItem):
self.addSearchToToolBar() self.addSearchToToolBar()
# Signals and slots # Signals and slots
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad)
Registry().register_function(u'config_updated', self.configUpdated) Registry().register_function(u'config_updated', self.config_update)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick)
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
@ -115,7 +115,7 @@ class SongMediaItem(MediaManagerItem):
def onFocus(self): def onFocus(self):
self.searchTextEdit.setFocus() self.searchTextEdit.setFocus()
def configUpdated(self): def config_update(self):
self.searchAsYouType = Settings().value(self.settingsSection + u'/search as type') self.searchAsYouType = Settings().value(self.settingsSection + u'/search as type')
self.updateServiceOnEdit = Settings().value(self.settingsSection + u'/update service on edit') self.updateServiceOnEdit = Settings().value(self.settingsSection + u'/update service on edit')
self.addSongFromService = Settings().value(self.settingsSection + u'/add song from service',) self.addSongFromService = Settings().value(self.settingsSection + u'/add song from service',)
@ -146,7 +146,7 @@ class SongMediaItem(MediaManagerItem):
UiStrings().Themes, UiStrings().SearchThemes) UiStrings().Themes, UiStrings().SearchThemes)
]) ])
self.searchTextEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection)) self.searchTextEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection))
self.configUpdated() self.config_update()
def onSearchTextButtonClicked(self): def onSearchTextButtonClicked(self):
# Save the current search type to the configuration. # Save the current search type to the configuration.