From ca5e46a2b1e5360d2bc6fb3e7da60e498e7696a3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 3 Feb 2013 21:46:56 +0000 Subject: [PATCH 01/16] Add test idea for the registry --- openlp/core/__init__.py | 6 ---- openlp/core/lib/eventreceiver.py | 3 -- openlp/core/lib/registry.py | 31 +++++++++++++++++++ openlp/core/ui/mainwindow.py | 10 +++--- openlp/core/ui/thememanager.py | 2 ++ openlp/plugins/alerts/lib/alertsmanager.py | 16 ++++++++-- openlp/plugins/custom/forms/editcustomform.py | 6 ++-- .../presentations/presentationplugin.py | 3 +- openlp/plugins/songs/forms/editsongform.py | 3 +- 9 files changed, 56 insertions(+), 24 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 33eb916be..9abc40493 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -154,12 +154,6 @@ class OpenLP(QtGui.QApplication): self.main_window.app_startup() return self.exec_() - def close_splash_screen(self): - """ - Close the splash screen when requested. - """ - self.splash.close() - def is_already_running(self): """ Look to see if OpenLP is already running and ask if a 2nd copy diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index df24694b0..eaf8ddc32 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -44,9 +44,6 @@ class EventReceiver(QtCore.QObject): **Mainwindow related and generic signals** - ``mainwindow_status_text`` - Changes the bottom status bar text on the mainwindow. - ``openlp_error_message`` Displays a standalone Error Message. diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 511067a80..27c037a27 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -59,6 +59,7 @@ class Registry(object): log.info(u'Registry Initialising') registry = cls() registry.service_list = {} + registry.functions_list = {} registry.running_under_test = False # Allow the tests to remove Registry entries but not the live system if u'nosetest' in sys.argv[0]: @@ -96,3 +97,33 @@ class Registry(object): return if key in self.service_list: del self.service_list[key] + + def register_function(self, occasion, function): + """ + Register a function and a handler to be called later + """ + if self.functions_list.has_key(occasion) == 0: + self.functions_list[occasion] = [function] + else: + self.functions_list[occasion].append(function) + + def remove_function(self, occasion, function): + """ + Register a function and a handler to be called later + """ + if self.running_under_test is False: + log.error(u'Invalid Method call for key %s' % occasion) + raise KeyError(u'Invalid Method call for key %s' % occasion) + return + if self.functions_list.has_key(occasion): + self.functions_list[occasion].remove(function) + + def execute(self, occasion, data): + """ + Execute all the handlers registered passing the data to the handler + """ + print self.functions_list, self.functions_list.has_key(occasion) + + if self.functions_list.has_key(occasion): + for function in self.functions_list[occasion]: + function(data) \ No newline at end of file diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e1cba9762..8e1be9602 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -532,8 +532,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mainwindow_status_text'), - self.showStatusMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) # Media Manager QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) @@ -722,21 +720,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Display an error message """ - self.application.close_splash_screen() + self.application.splash.close() QtGui.QMessageBox.critical(self, data[u'title'], data[u'message']) def warning_message(self, message): """ Display a warning message """ - self.application.close_splash_screen() + self.application.splash.close() QtGui.QMessageBox.warning(self, message[u'title'], message[u'message']) def onInformationMessage(self, data): """ Display an informational message """ - self.application.close_splash_screen() + self.application.splash.close() QtGui.QMessageBox.information(self, data[u'title'], data[u'message']) def onHelpWebSiteClicked(self): @@ -1122,7 +1120,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): title = u'%s - %s' % (self.mainTitle, fileName) self.setWindowTitle(title) - def showStatusMessage(self, message): + def show_status_message(self, message): """ Show a message in the status bar """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a482a3c44..25b4d5c5e 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -238,6 +238,7 @@ class ThemeManager(QtGui.QWidget): self.theme_list_widget.item(count).setText(name) Settings().setValue(self.settingsSection + u'/global theme', self.global_theme) Receiver.send_message(u'theme_update_global', self.global_theme) + Registry().execute(u'theme_update_global', self.global_theme) self._push_themes() def onAddTheme(self): @@ -465,6 +466,7 @@ class ThemeManager(QtGui.QWidget): Notify listeners that the theme list has been updated """ Receiver.send_message(u'theme_update_list', self.get_themes()) + Registry().execute(u'theme_update_list', self.get_themes()) def get_themes(self): """ diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index ab0f7c1d9..7ca324f88 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -35,7 +35,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Registry, Receiver, translate log = logging.getLogger(__name__) @@ -72,10 +72,10 @@ class AlertsManager(QtCore.QObject): if text: self.alertList.append(text) if self.timer_id != 0: - Receiver.send_message(u'mainwindow_status_text', + self.main_window.show_status_message( translate('AlertsPlugin.AlertsManager', 'Alert message created and displayed.')) return - Receiver.send_message(u'mainwindow_status_text', u'') + self.main_window.show_status_message(u'') self.generateAlert() def generateAlert(self): @@ -107,3 +107,13 @@ class AlertsManager(QtCore.QObject): self.killTimer(self.timer_id) self.timer_id = 0 self.generateAlert() + + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) \ No newline at end of file diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 18f3ab736..a27696171 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -31,9 +31,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, translate -from openlp.core.lib.ui import critical_error_message_box, \ - find_and_set_in_combo_box +from openlp.core.lib import Receiver, Registry, translate +from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.lib.db import CustomSlide from editcustomdialog import Ui_CustomEditDialog @@ -66,6 +65,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.slideListView.currentRowChanged.connect(self.on_current_row_changed) self.slideListView.doubleClicked.connect(self.on_edit_button_clicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) + Registry().register_function(u'theme_update_list', self.loadThemes) def loadThemes(self, theme_list): """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 883bb4bb8..2e6041084 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -37,8 +37,7 @@ from PyQt4 import QtCore from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.utils import AppLocation -from openlp.plugins.presentations.lib import PresentationController, \ - PresentationMediaItem, PresentationTab +from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0c0e5c196..6e55c072d 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -39,7 +39,7 @@ import shutil from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, \ - check_directory_exists, Registry, UiStrings + check_directory_exists, Registry, UiStrings, Registry from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, critical_error_message_box, \ find_and_set_in_combo_box from openlp.core.utils import AppLocation @@ -98,6 +98,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.audioRemoveAllButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveAllButtonClicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) + Registry().register_function(u'theme_update_list', self.loadThemes) self.previewButton = QtGui.QPushButton() self.previewButton.setObjectName(u'previewButton') self.previewButton.setText(UiStrings().SaveAndPreview) From b7b19a41802cc03d6fbe7c28a572a58532dc926a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 4 Feb 2013 19:25:12 +0000 Subject: [PATCH 02/16] Fix up Registry function processing --- openlp/core/lib/registry.py | 34 ++++++++++-------- openlp/core/lib/renderer.py | 2 +- openlp/core/ui/mainwindow.py | 5 +-- openlp/core/ui/servicemanager.py | 4 +-- openlp/core/ui/thememanager.py | 4 +-- openlp/core/ui/themestab.py | 11 +++--- openlp/plugins/custom/forms/editcustomform.py | 1 - openlp/plugins/songs/forms/editsongform.py | 5 ++- .../openlp_core_lib/test_registry.py | 36 ++++++++++++++++++- 9 files changed, 70 insertions(+), 32 deletions(-) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 27c037a27..04bb72f32 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -98,32 +98,36 @@ class Registry(object): if key in self.service_list: del self.service_list[key] - def register_function(self, occasion, function): + def register_function(self, event, function): """ Register a function and a handler to be called later """ - if self.functions_list.has_key(occasion) == 0: - self.functions_list[occasion] = [function] + if not self.functions_list.has_key(event): + self.functions_list[event] = [function] else: - self.functions_list[occasion].append(function) + self.functions_list[event].append(function) - def remove_function(self, occasion, function): + def remove_function(self, event, function): """ Register a function and a handler to be called later """ if self.running_under_test is False: - log.error(u'Invalid Method call for key %s' % occasion) - raise KeyError(u'Invalid Method call for key %s' % occasion) + log.error(u'Invalid Method call for key %s' % event) + raise KeyError(u'Invalid Method call for key %s' % event) return - if self.functions_list.has_key(occasion): - self.functions_list[occasion].remove(function) + if event in self.functions_list: + self.functions_list[event].remove(function) - def execute(self, occasion, data): + def execute(self, event, *args, **kwargs): """ - Execute all the handlers registered passing the data to the handler + Execute all the handlers registered passing the data to the handler and returning results """ - print self.functions_list, self.functions_list.has_key(occasion) + results = [] + if event in self.functions_list: + for function in self.functions_list[event]: + print event, function, + result = function(*args, **kwargs) + if result: + results.append(result) + return results - if self.functions_list.has_key(occasion): - for function in self.functions_list[occasion]: - function(data) \ No newline at end of file diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 7b7027efd..d54232773 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -80,7 +80,7 @@ class Renderer(object): self.display.setup() self._theme_dimensions = {} self._calculate_default() - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.set_global_theme) + Registry().register_function(u'theme_update_global', self.set_global_theme) self.web = QtWebKit.QWebView() self.web.setVisible(False) self.web_frame = self.web.page().mainFrame() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 8e1be9602..0e858bb25 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -528,7 +528,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.modeDefaultItem, QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked) QtCore.QObject.connect(self.modeSetupItem, QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked) QtCore.QObject.connect(self.modeLiveItem, QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.defaultThemeChanged) + Registry().register_function(u'theme_update_global', self.defaultThemeChanged) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) @@ -699,7 +699,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.activePlugin.toggleStatus(PluginStatus.Inactive) self.themeManagerContents.configUpdated() self.themeManagerContents.load_themes(True) - Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme) + #Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme) + Registry().execute(u'theme_update_global', self.themeManagerContents.global_theme) # Check if any Bibles downloaded. If there are, they will be # processed. Receiver.send_message(u'bibles_load_list', True) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b45794556..27d4a2caf 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -214,7 +214,7 @@ class ServiceManagerDialog(object): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.regenerate_service_Items) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_global'), self.theme_change) + Registry().register_function(u'theme_update_global', self.theme_change) # Last little bits of setting up self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') self.servicePath = AppLocation.get_section_data_path(u'servicemanager') @@ -1243,7 +1243,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme) self.regenerate_service_Items(True) - def theme_change(self): + def theme_change(self, args, **Kwargs): """ The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state. diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 25b4d5c5e..0c7a0fc60 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -134,8 +134,7 @@ class ThemeManager(QtGui.QWidget): QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen) QtCore.QObject.connect(self.theme_list_widget, QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.check_list_state) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'theme_update_global'), self.change_global_from_tab) + Registry().register_function(u'theme_update_global', self.change_global_from_tab) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) # Variables self.theme_list = [] @@ -237,7 +236,6 @@ class ThemeManager(QtGui.QWidget): name = translate('OpenLP.ThemeManager', '%s (default)') % self.global_theme self.theme_list_widget.item(count).setText(name) Settings().setValue(self.settingsSection + u'/global theme', self.global_theme) - Receiver.send_message(u'theme_update_global', self.global_theme) Registry().execute(u'theme_update_global', self.global_theme) self._push_themes() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index b502d11e0..fddfeb366 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -31,7 +31,7 @@ The Themes configuration tab """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, translate, UiStrings +from openlp.core.lib import Receiver, Registry, Settings, SettingsTab, translate, UiStrings from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import find_and_set_in_combo_box @@ -104,7 +104,7 @@ class ThemesTab(SettingsTab): QtCore.QObject.connect(self.GlobalLevelRadioButton, QtCore.SIGNAL(u'clicked()'), self.onGlobalLevelButtonClicked) QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) + Registry().register_function(u'theme_update_list', self.updateThemeList) def retranslateUi(self): """ @@ -153,13 +153,15 @@ class ThemesTab(SettingsTab): settings.endGroup() self.renderer.set_global_theme(self.global_theme) self.renderer.set_theme_level(self.theme_level) - Receiver.send_message(u'theme_update_global', self.global_theme) + #Receiver.send_message(u'theme_update_global', self.global_theme) + Registry().execute(u'theme_update_global', self.global_theme) def postSetUp(self): """ After setting things up... """ - Receiver.send_message(u'theme_update_global', self.global_theme) + #Receiver.send_message(u'theme_update_global', self.global_theme) + Registry().execute(u'theme_update_global', self.global_theme) def onSongLevelButtonClicked(self): """ @@ -197,6 +199,7 @@ class ThemesTab(SettingsTab): [u'Bible Theme', u'Song Theme'] """ # Reload as may have been triggered by the ThemeManager. + print theme_list self.global_theme = Settings().value(self.settingsSection + u'/global theme') self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a27696171..a308737a2 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -64,7 +64,6 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.editAllButton.clicked.connect(self.on_edit_all_button_clicked) self.slideListView.currentRowChanged.connect(self.on_current_row_changed) self.slideListView.doubleClicked.connect(self.on_edit_button_clicked) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) Registry().register_function(u'theme_update_list', self.loadThemes) def loadThemes(self, theme_list): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 6e55c072d..d3fb859f4 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -39,8 +39,8 @@ import shutil from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, \ - check_directory_exists, Registry, UiStrings, Registry -from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, critical_error_message_box, \ + check_directory_exists, Registry, UiStrings +from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ find_and_set_in_combo_box from openlp.core.utils import AppLocation from openlp.plugins.songs.forms import EditVerseForm, MediaFilesForm @@ -97,7 +97,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.audioRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked) QtCore.QObject.connect(self.audioRemoveAllButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveAllButtonClicked) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) Registry().register_function(u'theme_update_list', self.loadThemes) self.previewButton = QtGui.QPushButton() self.previewButton.setObjectName(u'previewButton') diff --git a/tests/functional/openlp_core_lib/test_registry.py b/tests/functional/openlp_core_lib/test_registry.py index f27eef3d8..32ad1b8e4 100644 --- a/tests/functional/openlp_core_lib/test_registry.py +++ b/tests/functional/openlp_core_lib/test_registry.py @@ -11,7 +11,7 @@ TESTPATH = os.path.abspath(os.path.join(os.path.dirname(__file__), u'..', u'..', class TestRegistry(TestCase): - def registry_basic_test(self): + def registry_service_test(self): """ Test the registry creation and its usage """ @@ -46,3 +46,37 @@ class TestRegistry(TestCase): temp = Registry().get(u'test1') self.assertEqual(context.exception[0], u'Service test1 not found in list', u'KeyError exception should have been thrown for deleted service') + + def registry_function_test(self): + """ + Test the registry creation and its usage + """ + # GIVEN: An existing registry register a function + Registry.create() + Registry().register_function(u'test1', self.dummy_function_1) + + # WHEN: I execute the function + return_value = Registry().execute(u'test1') + + # THEN: I expect then function to have been called and a return given + self.assertEqual(return_value[0], u'function_1', u'A return value is provided and matches') + + # WHEN: I execute the a function with the same reference and execute the function + Registry().register_function(u'test1', self.dummy_function_1) + return_value = Registry().execute(u'test1') + + # THEN: I expect then function to have been called and a return given + self.assertEqual(return_value, [u'function_1', u'function_1'], u'A return value list is provided and matches') + + # WHEN: I execute the a 2nd function with the different reference and execute the function + Registry().register_function(u'test2', self.dummy_function_2) + return_value = Registry().execute(u'test2') + + # THEN: I expect then function to have been called and a return given + self.assertEqual(return_value[0], u'function_2', u'A return value is provided and matches') + + def dummy_function_1(self): + return "function_1" + + def dummy_function_2(self): + return "function_2" \ No newline at end of file From eac2ce39b33e0a5e66cffadbeda0bdd0e729f010 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 5 Feb 2013 21:42:15 +0000 Subject: [PATCH 03/16] More Receiver removals --- openlp/core/__init__.py | 1 + openlp/core/lib/eventreceiver.py | 14 ---- openlp/core/lib/registry.py | 11 +-- openlp/core/lib/ui.py | 5 +- openlp/core/ui/firsttimeform.py | 4 +- openlp/core/ui/mainwindow.py | 40 ++++++---- openlp/core/ui/servicemanager.py | 18 ++--- openlp/core/ui/shortcutlistform.py | 11 ++- openlp/core/ui/thememanager.py | 17 +++-- openlp/core/ui/themestab.py | 3 - openlp/plugins/bibles/lib/http.py | 22 +++++- openlp/plugins/bibles/lib/manager.py | 73 ++++++++++--------- .../songusage/forms/songusagedeleteform.py | 19 +++-- .../songusage/forms/songusagedetailform.py | 31 +++++--- 14 files changed, 151 insertions(+), 118 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 9abc40493..172b47dea 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -197,6 +197,7 @@ class OpenLP(QtGui.QApplication): """ Wrapper to make ProcessEvents visible and named correctly """ + log.debug(u'processing event flush') self.processEvents() def set_busy_cursor(self): diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index eaf8ddc32..23115ab65 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -44,12 +44,6 @@ class EventReceiver(QtCore.QObject): **Mainwindow related and generic signals** - ``openlp_error_message`` - Displays a standalone Error Message. - - ``openlp_information_message`` - Displays a standalone Information Message. - ``openlp_version_check`` Version has changed so pop up window. @@ -125,14 +119,6 @@ class EventReceiver(QtCore.QObject): ``live_display_blank_check`` Check to see if the blank display message is required. - **Theme related singlas** - - ``theme_update_list`` - send out message with new themes. - - ``theme_update_global`` - Tell the components we have a new global theme. - **Plugin specific signals** ``{plugin}_start`` diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 04bb72f32..a206e950a 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -125,9 +125,10 @@ class Registry(object): results = [] if event in self.functions_list: for function in self.functions_list[event]: - print event, function, - result = function(*args, **kwargs) - if result: - results.append(result) + try: + result = function(*args, **kwargs) + if result: + results.append(result) + except TypeError: + log.exception(u'Exception for function %s', function) return results - diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 0d869d724..7d1c6cec2 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import build_icon, translate, Receiver, UiStrings +from openlp.core.lib import Registry, build_icon, translate, Receiver, UiStrings from openlp.core.utils.actions import ActionList @@ -133,8 +133,7 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) data = {u'message': message} - data[u'title'] = title if title else UiStrings().Error - return Receiver.send_message(u'openlp_error_message', data) + return Registry().get(u'main_window').error_message(title if title else UiStrings().Error, message) def create_horizontal_adjusting_combo_box(parent, name): diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 29e2cd97a..1c4b7eaf2 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -296,8 +296,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): item = self.themesListWidget.item(index) if item.data(QtCore.Qt.UserRole) == filename: break - item.setIcon(build_icon(os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp', - screenshot))) + item.setIcon(build_icon(os.path.join(unicode(gettempdir(), + get_filesystem_encoding()), u'openlp', screenshot))) def _getFileSize(self, url): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 0e858bb25..cface47da 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -537,9 +537,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) self.application.set_busy_cursor() # Simple message boxes - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_error_message'), self.onErrorMessage) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_information_message'), - self.onInformationMessage) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_copy_data'), self.setCopyData) # warning cyclic dependency @@ -580,8 +577,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Once all components are initialised load the Themes log.info(u'Load Themes') self.themeManagerContents.load_themes(True) - # Hide/show the theme combobox on the service manager - self.serviceManagerContents.theme_change() # Reset the cursor self.application.set_normal_cursor() @@ -697,9 +692,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.activePlugin.app_startup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) - self.themeManagerContents.configUpdated() + self.themeManagerContents.config_updated() self.themeManagerContents.load_themes(True) - #Receiver.send_message(u'theme_update_global', self.themeManagerContents.global_theme) Registry().execute(u'theme_update_global', self.themeManagerContents.global_theme) # Check if any Bibles downloaded. If there are, they will be # processed. @@ -717,26 +711,44 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), translate('OpenLP.MainWindow', 'The Main Display has been blanked out')) - def onErrorMessage(self, data): + def error_message(self, title, message): """ Display an error message + + ``title`` + The title of the warning box. + + ``message`` + The message to be displayed. """ self.application.splash.close() - QtGui.QMessageBox.critical(self, data[u'title'], data[u'message']) + QtGui.QMessageBox.critical(self, title, message) - def warning_message(self, message): + def warning_message(self, title, message): """ Display a warning message + + ``title`` + The title of the warning box. + + ``message`` + The message to be displayed. """ self.application.splash.close() - QtGui.QMessageBox.warning(self, message[u'title'], message[u'message']) + QtGui.QMessageBox.warning(self, title, message) - def onInformationMessage(self, data): + def information_message(self, title, message): """ Display an informational message + + ``title`` + The title of the warning box. + + ``message`` + The message to be displayed. """ self.application.splash.close() - QtGui.QMessageBox.information(self, data[u'title'], data[u'message']) + QtGui.QMessageBox.information(self, title, message) def onHelpWebSiteClicked(self): """ @@ -1079,8 +1091,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.liveController.display: self.liveController.display.close() self.liveController.display = None - # Allow the main process to exit - self.application = None def serviceChanged(self, reset=False, serviceName=None): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 27d4a2caf..5a2c96782 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -555,10 +555,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): zip_file.write(audio_from, audio_to.encode(u'utf-8')) except IOError: log.exception(u'Failed to save service to disk: %s', temp_file_name) - Receiver.send_message(u'openlp_error_message', { - u'title': translate(u'OpenLP.ServiceManager', u'Error Saving File'), - u'message': translate(u'OpenLP.ServiceManager', u'There was an error saving your file.') - }) + self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'), + translate(u'OpenLP.ServiceManager', u'There was an error saving your file.') + ) success = False finally: if zip_file: @@ -613,10 +612,9 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): zip_file.writestr(service_file_name.encode(u'utf-8'), service_content) except IOError: log.exception(u'Failed to save service to disk: %s', temp_file_name) - Receiver.send_message(u'openlp_error_message', { - u'title': translate(u'OpenLP.ServiceManager', u'Error Saving File'), - u'message': translate(u'OpenLP.ServiceManager', u'There was an error saving your file.') - }) + self.main_window.error_message(translate(u'OpenLP.ServiceManager', u'Error Saving File'), + translate(u'OpenLP.ServiceManager', u'There was an error saving your file.') + ) success = False finally: if zip_file: @@ -1237,13 +1235,13 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): """ Set the theme for the current service. """ - log.debug(u'ontheme_combo_box_selected') + log.debug(u'on_theme_combo_box_selected') self.service_theme = self.theme_combo_box.currentText() self.renderer.set_service_theme(self.service_theme) Settings().setValue(self.main_window.serviceManagerSettingsSection + u'/service theme', self.service_theme) self.regenerate_service_Items(True) - def theme_change(self, args, **Kwargs): + def theme_change(self, global_theme): """ The theme may have changed in the settings dialog so make sure the theme combo box is in the correct state. diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index b628156b8..75e7403d5 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -438,12 +438,11 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if changing_action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]: is_valid = False if not is_valid: - self.main_window.warning_message( { - u'title': translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), - u'message': translate('OpenLP.ShortcutListDialog', - 'The shortcut "%s" is already assigned to another action, ' - 'please use a different shortcut.') % key_sequence.toString() - }) + self.main_window.warning_message( translate('OpenLP.ShortcutListDialog', 'Duplicate Shortcut'), + translate('OpenLP.ShortcutListDialog', + 'The shortcut "%s" is already assigned to another action, please use a different shortcut.') % + key_sequence.toString() + ) return is_valid def _actionShortcuts(self, action): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 0c7a0fc60..f0e16b78b 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -125,13 +125,13 @@ class ThemeManager(QtGui.QWidget): self.global_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', 'Set As &Global Default'), icon=u':/general/general_export.png', - triggers=self.changeGlobalFromScreen) + triggers=self.change_global_from_screen) self.exportAction = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Export Theme'), icon=u':/general/general_export.png', triggers=self.on_export_theme) # Signals QtCore.QObject.connect(self.theme_list_widget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen) + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.change_global_from_screen) QtCore.QObject.connect(self.theme_list_widget, QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.check_list_state) Registry().register_function(u'theme_update_global', self.change_global_from_tab) @@ -165,6 +165,7 @@ class ThemeManager(QtGui.QWidget): """ Triggered when Config dialog is updated. """ + log.debug(u'config_updated') self.global_theme = Settings().value(self.settingsSection + u'/global theme') def check_list_state(self, item): @@ -214,15 +215,14 @@ class ThemeManager(QtGui.QWidget): if theme_name == new_name: name = translate('OpenLP.ThemeManager', '%s (default)') % new_name self.theme_list_widget.item(count).setText(name) - self.deleteToolbarAction.setVisible( - item not in self.theme_list_widget.selectedItems()) + self.deleteToolbarAction.setVisible(item not in self.theme_list_widget.selectedItems()) - def changeGlobalFromScreen(self, index=-1): + def change_global_from_screen(self, index=-1): """ Change the global theme when a theme is double clicked upon in the Theme Manager list """ - log.debug(u'changeGlobalFromScreen %s', index) + log.debug(u'change_global_from_screen %s', index) selected_row = self.theme_list_widget.currentRow() for count in range(0, self.theme_list_widget.count()): item = self.theme_list_widget.item(count) @@ -463,13 +463,13 @@ class ThemeManager(QtGui.QWidget): """ Notify listeners that the theme list has been updated """ - Receiver.send_message(u'theme_update_list', self.get_themes()) Registry().execute(u'theme_update_list', self.get_themes()) def get_themes(self): """ Return the list of loaded themes """ + log.debug(u'get themes') return self.theme_list def get_theme_data(self, theme_name): @@ -479,7 +479,7 @@ class ThemeManager(QtGui.QWidget): ``theme_name`` Name of the theme to load from file """ - log.debug(u'getthemedata for theme %s', theme_name) + log.debug(u'get theme data for theme %s', theme_name) xml_file = os.path.join(self.path, unicode(theme_name), unicode(theme_name) + u'.xml') xml = get_text_file_string(xml_file) if not xml: @@ -687,6 +687,7 @@ class ThemeManager(QtGui.QWidget): """ Called to update the themes' preview images. """ + log.debug('update_preview_images') self.main_window.displayProgressBar(len(self.theme_list)) for theme in self.theme_list: self.main_window.incrementProgressBar() diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index fddfeb366..b4e300766 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -153,14 +153,12 @@ class ThemesTab(SettingsTab): settings.endGroup() self.renderer.set_global_theme(self.global_theme) self.renderer.set_theme_level(self.theme_level) - #Receiver.send_message(u'theme_update_global', self.global_theme) Registry().execute(u'theme_update_global', self.global_theme) def postSetUp(self): """ After setting things up... """ - #Receiver.send_message(u'theme_update_global', self.global_theme) Registry().execute(u'theme_update_global', self.global_theme) def onSongLevelButtonClicked(self): @@ -199,7 +197,6 @@ class ThemesTab(SettingsTab): [u'Bible Theme', u'Song Theme'] """ # Reload as may have been triggered by the ThemeManager. - print theme_list self.global_theme = Settings().value(self.settingsSection + u'/global theme') self.DefaultComboBox.clear() self.DefaultComboBox.addItems(theme_list) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 799c11129..d0486dfaa 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -235,10 +235,8 @@ class BGExtract(object): soup = get_soup_for_bible_ref( u'http://www.biblegateway.com/passage/?%s' % url_params, pre_parse_regex=r'', pre_parse_substitute='', cleaner=cleaner) - self.application.process_events() if not soup: return None - self.application.process_events() div = soup.find('div', 'result-text-style-normal') self._clean_soup(div) span_list = div.findAll('span', 'text') @@ -297,6 +295,16 @@ class BGExtract(object): books.append(book.contents[0]) return books + def _get_application(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application + + application = property(_get_application) + class BSExtract(object): """ @@ -466,6 +474,16 @@ class CWExtract(object): books.append(book.contents[0]) return books + def _get_application(self): + """ + Adds the openlp to the class dynamically + """ + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application + + application = property(_get_application) + class HTTPBible(BibleDB): log.info(u'%s HTTPBible loaded', __name__) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index aaf91d2c0..46ba0731f 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -30,7 +30,7 @@ import logging import os -from openlp.core.lib import Receiver, SettingsManager, translate, Settings +from openlp.core.lib import Registry, Receiver, SettingsManager, translate, Settings from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta @@ -304,12 +304,12 @@ class BibleManager(object): log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext) if not bible: if show_error: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', 'No Bibles Available'), - u'message': translate('BiblesPlugin.BibleManager', + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'No Bibles Available'), + translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the ' 'Import Wizard to install one or more Bibles.') - }) + ) return None language_selection = self.get_language_selection(bible) reflist = parse_reference(versetext, self.db_cache[bible], @@ -322,14 +322,11 @@ class BibleManager(object): u'verse': get_reference_separator(u'sep_v_display'), u'range': get_reference_separator(u'sep_r_display'), u'list': get_reference_separator(u'sep_l_display')} - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', - 'Scripture Reference Error'), - u'message': translate('BiblesPlugin.BibleManager', - 'Your scripture reference is either not supported by ' + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'Your scripture reference is either not supported by ' 'OpenLP or is invalid. Please make sure your reference ' - 'conforms to one of the following patterns or consult the ' - 'manual:\n\n' + 'conforms to one of the following patterns or consult the manual:\n\n' 'Book Chapter\n' 'Book Chapter%(range)sChapter\n' 'Book Chapter%(verse)sVerse%(range)sVerse\n' @@ -339,9 +336,8 @@ class BibleManager(object): '%(verse)sVerse%(range)sVerse\n' 'Book Chapter%(verse)sVerse%(range)sChapter%(verse)sVerse', 'Please pay attention to the appended "s" of the wildcards ' - 'and refrain from translating the words inside the ' - 'names in the brackets.') % reference_seperators - }) + 'and refrain from translating the words inside the names in the brackets.') % reference_seperators + ) return None def get_language_selection(self, bible): @@ -380,36 +376,33 @@ class BibleManager(object): """ log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) if not bible: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', 'No Bibles Available'), - u'message': translate('BiblesPlugin.BibleManager', - 'There are no Bibles currently installed. Please use the ' - 'Import Wizard to install one or more Bibles.') - }) + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'No Bibles Available'), + translate('BiblesPlugin.BibleManager', + 'There are no Bibles currently installed. Please use the Import Wizard to install one or more' + ' Bibles.') + ) return None # Check if the bible or second_bible is a web bible. - webbible = self.db_cache[bible].get_object(BibleMeta, - u'download_source') + webbible = self.db_cache[bible].get_object(BibleMeta, u'download_source') second_webbible = u'' if second_bible: - second_webbible = self.db_cache[second_bible].get_object(BibleMeta, - u'download_source') + second_webbible = self.db_cache[second_bible].get_object(BibleMeta, u'download_source') if webbible or second_webbible: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), - u'message': translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.') - }) + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Web Bible cannot be used'), + translate('BiblesPlugin.BibleManager', 'Text Search is not available with Web Bibles.') + ) return None if text: return self.db_cache[bible].verse_search(text) else: - Receiver.send_message(u'openlp_information_message', { - u'title': translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), - u'message': translate('BiblesPlugin.BibleManager', 'You did not enter a search keyword.\n' - 'You can separate different keywords by a space to ' - 'search for all of your keywords and you can separate ' + self.main_window.information_message( + translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'You did not enter a search keyword.\nYou can separate ' + 'different keywords by a space to search for all of your keywords and you can separate ' 'them by a comma to search for one of them.') - }) + ) return None def save_meta_data(self, bible, version, copyright, permissions, @@ -460,6 +453,16 @@ class BibleManager(object): for bible in self.db_cache: self.db_cache[bible].finalise() + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) + BibleFormat.set_availability(BibleFormat.OpenLP1, HAS_OPENLP1) __all__ = [u'BibleFormat'] diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 8174060bd..cb26f4dbb 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, Receiver +from openlp.core.lib import Registry, translate from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedeletedialog import Ui_SongUsageDeleteDialog @@ -57,11 +57,20 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): if ret == QtGui.QMessageBox.Yes: deleteDate = self.deleteCalendar.selectedDate().toPyDate() self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= deleteDate) - Receiver.send_message(u'openlp_information_message', { - u'title': translate('SongUsagePlugin.SongUsageDeleteForm', 'Deletion Successful'), - u'message': translate( - 'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully. ')} + self.main_window.information_message( + translate('SongUsagePlugin.SongUsageDeleteForm', 'Deletion Successful'), + translate( + 'SongUsagePlugin.SongUsageDeleteForm', 'All requested data has been deleted successfully. ') ) self.accept() else: self.reject() + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) \ No newline at end of file diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index c455e079c..1f68e1a97 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -33,7 +33,7 @@ import os from PyQt4 import QtGui from sqlalchemy.sql import and_ -from openlp.core.lib import Receiver, Settings, translate, check_directory_exists +from openlp.core.lib import Registry, Settings, translate, check_directory_exists from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedetaildialog import Ui_SongUsageDetailDialog @@ -81,11 +81,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): log.debug(u'accept') path = self.fileLineEdit.text() if not path: - Receiver.send_message(u'openlp_error_message', { - u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'), - u'message': translate( - 'SongUsagePlugin.SongUsageDetailForm', 'You have not set a valid output location for your song usage ' - 'report. Please select an existing path on your computer.')}) + self.main_window.error_message( + translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'), + translate('SongUsagePlugin.SongUsageDetailForm', 'You have not set a valid output location for your' + ' song usage report. Please select an existing path on your computer.') + ) return check_directory_exists(path) filename = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % ( @@ -108,13 +108,24 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): instance.usagetime, instance.title, instance.copyright, instance.ccl_number, instance.authors, instance.plugin_name, instance.source) fileHandle.write(record.encode(u'utf-8')) - Receiver.send_message(u'openlp_information_message', { - u'title': translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'), - u'message': translate('SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' - 'has been successfully created. ') % outname}) + self.main_window.information_message( + translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'), + translate('SongUsagePlugin.SongUsageDetailForm', 'Report \n%s \n' + 'has been successfully created. ') % outname + ) except IOError: log.exception(u'Failed to write out song usage records') finally: if fileHandle: fileHandle.close() self.close() + + def _get_main_window(self): + """ + Adds the main window to the class dynamically + """ + if not hasattr(self, u'_main_window'): + self._main_window = Registry().get(u'main_window') + return self._main_window + + main_window = property(_get_main_window) \ No newline at end of file From d491997ca788c414fafde264bec9581373e37a54 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Feb 2013 19:25:16 +0000 Subject: [PATCH 04/16] old test code --- openlp/core/lib/registry.py | 18 +++++- tests/conftest.py | 46 -------------- .../openlp_core_lib/test_registry.py | 2 +- tests/run.py | 60 ------------------- tests/test_app.py | 37 ------------ 5 files changed, 16 insertions(+), 147 deletions(-) delete mode 100644 tests/conftest.py delete mode 100755 tests/run.py delete mode 100644 tests/test_app.py diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index a206e950a..f9773a6d1 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -60,10 +60,10 @@ class Registry(object): registry = cls() registry.service_list = {} registry.functions_list = {} - registry.running_under_test = False + registry.running_under_test = True # Allow the tests to remove Registry entries but not the live system - if u'nosetest' in sys.argv[0]: - registry.running_under_test = True + if u'openlp.py' in sys.argv[0]: + registry.running_under_test = False return registry def get(self, key): @@ -127,8 +127,20 @@ class Registry(object): for function in self.functions_list[event]: try: 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: results.append(result) except TypeError: + # Who has called me can help + import inspect + log.debug(inspect.currentframe().f_back.f_locals) log.exception(u'Exception for function %s', function) return results + + def inspect_result(self, results,*args, **kwargs): + """ + Dummy method for tests to inspect the results of a call. + """ + pass diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 5722c6235..000000000 --- a/tests/conftest.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Edwin Lunando, Joshua Miller, Stevan Pettit, # -# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # -# Simon Scudder, Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon # -# Tibble, Dave Warnock, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -""" -Configuration file for pytest framework. -""" - -from openlp.core import main as openlp_main - - -# Test function argument to make openlp gui instance persistent for all tests. -# All test cases have to access the same instance. To allow create multiple -# instances it would be necessary use diffrent configuraion and data files. -# Created instance will use your OpenLP settings. -def pytest_funcarg__openlpapp(request): - def setup(): - return openlp_main(['--testing']) - def teardown(app): - pass - return request.cached_setup(setup=setup, teardown=teardown, scope='session') diff --git a/tests/functional/openlp_core_lib/test_registry.py b/tests/functional/openlp_core_lib/test_registry.py index 32ad1b8e4..826aafc9b 100644 --- a/tests/functional/openlp_core_lib/test_registry.py +++ b/tests/functional/openlp_core_lib/test_registry.py @@ -49,7 +49,7 @@ class TestRegistry(TestCase): def registry_function_test(self): """ - Test the registry creation and its usage + Test the registry function creation and their usages """ # GIVEN: An existing registry register a function Registry.create() diff --git a/tests/run.py b/tests/run.py deleted file mode 100755 index 53a6a6cb6..000000000 --- a/tests/run.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Edwin Lunando, Joshua Miller, Stevan Pettit, # -# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # -# Simon Scudder, Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon # -# Tibble, Dave Warnock, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -""" -This script is used to run set of automated tests of OpenLP. To start tests, -simply run this script:: - - @:~$ ./run.py - -""" - -import os -import sys - -TESTS_PATH = os.path.dirname(os.path.abspath(__file__)) -SRC_PATH = os.path.join(TESTS_PATH, '..') - -PYTEST_OPTIONS = [TESTS_PATH] - -# Extend python PATH with openlp source -sys.path.insert(0, SRC_PATH) - -# Python testing framework -# http://pytest.org -import pytest - - -def main(): - print 'pytest options:', PYTEST_OPTIONS - pytest.main(PYTEST_OPTIONS) - - -if __name__ == u'__main__': - main() diff --git a/tests/test_app.py b/tests/test_app.py deleted file mode 100644 index c0b1e651a..000000000 --- a/tests/test_app.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2011 Raoul Snyman # -# Portions copyright (c) 2008-2011 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Edwin Lunando, Joshua Miller, Stevan Pettit, # -# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # -# Simon Scudder, Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon # -# Tibble, Dave Warnock, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from openlp.core import OpenLP -from openlp.core.ui.mainwindow import MainWindow - - -def test_start_app(openlpapp): - assert type(openlpapp) == OpenLP - assert type(openlpapp.mainWindow) == MainWindow - assert unicode(openlpapp.mainWindow.windowTitle()) == u'OpenLP 2.1' From 1430559205911aa177eb0effb36b6abbaa27ecb2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 6 Feb 2013 21:52:15 +0000 Subject: [PATCH 05/16] More Receiver to Registry migrations --- openlp/core/lib/eventreceiver.py | 9 --------- openlp/core/lib/imagemanager.py | 4 ++-- openlp/core/lib/plugin.py | 3 +-- openlp/core/lib/screen.py | 6 +++--- openlp/core/ui/advancedtab.py | 4 ++-- openlp/core/ui/firsttimeform.py | 3 +-- openlp/core/ui/generaltab.py | 6 +++--- openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/mainwindow.py | 11 ++++++----- openlp/core/ui/media/playertab.py | 4 ++-- openlp/core/ui/servicemanager.py | 5 ++--- openlp/core/ui/settingsform.py | 2 +- openlp/core/ui/thememanager.py | 2 +- openlp/core/utils/__init__.py | 4 ++-- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- openlp/plugins/custom/lib/mediaitem.py | 4 ++-- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/remotes/lib/remotetab.py | 4 ++-- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 19 files changed, 36 insertions(+), 47 deletions(-) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 23115ab65..ca6fe7b17 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -44,20 +44,11 @@ class EventReceiver(QtCore.QObject): **Mainwindow related and generic signals** - ``openlp_version_check`` - Version has changed so pop up window. - ``openlp_stop_wizard`` Stops a wizard before completion. **Setting related signals** - ``config_updated`` - Informs components that the config has changed. - - ``config_screen_changed`` - The display monitor has been changed. - **Slidecontroller signals** ``slidecontroller_{live|preview}_next`` diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 9726079f7..a5e32dbf8 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -39,7 +39,7 @@ import Queue from PyQt4 import QtCore -from openlp.core.lib import resize_image, image_to_byte, Receiver, Registry, ScreenList +from openlp.core.lib import resize_image, image_to_byte, Registry, ScreenList log = logging.getLogger(__name__) @@ -200,7 +200,7 @@ class ImageManager(QtCore.QObject): self.image_thread = ImageThread(self) self._conversion_queue = PriorityQueue() self.stop_manager = False - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.process_updates) + Registry().register_function(u'config_updated', self.process_updates) def update_display(self): """ diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index bad7defb8..586e35ad8 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -173,8 +173,7 @@ class Plugin(QtCore.QObject): Settings.extend_default_settings(default_settings) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), self.processAddServiceEvent) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_config_updated' % self.name), - self.configUpdated) + Registry().register_function(u'%s_config_updated' % self.name, self.configUpdated) def checkPreConditions(self): """ diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 9c118de99..e0779eda3 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -35,7 +35,7 @@ import copy from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Registry, translate log = logging.getLogger(__name__) @@ -100,7 +100,7 @@ class ScreenList(object): if screen == self.override: self.override = copy.deepcopy(newScreen) self.set_override_display() - Receiver.send_message(u'config_screen_changed') + Registry().execute(u'config_screen_changed') break def screen_count_changed(self, changed_screen=-1): @@ -128,7 +128,7 @@ class ScreenList(object): # We do not want to send this message at start up. if changed_screen != -1: # Reload setting tabs to apply possible changes. - Receiver.send_message(u'config_screen_changed') + Registry().execute(u'config_screen_changed') def get_screen_list(self): """ diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 08a98d918..4c2dc6c60 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -36,7 +36,7 @@ import sys from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate, build_icon +from openlp.core.lib import Registry, SettingsTab, Receiver, Settings, UiStrings, translate, build_icon from openlp.core.utils import get_images_filter, AppLocation, format_time from openlp.core.lib import SlideLimits @@ -455,7 +455,7 @@ class AdvancedTab(SettingsTab): settings.setValue(u'slide limits', self.slide_limits) settings.endGroup() if self.display_changed: - Receiver.send_message(u'config_screen_changed') + Registry().execute(u'config_screen_changed') self.display_changed = False Receiver.send_message(u'slidecontroller_update_slide_limits') diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 1c4b7eaf2..033a0b52d 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -103,8 +103,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): QtCore.QObject.connect(self.noInternetFinishButton, QtCore.SIGNAL('clicked()'), self.onNoInternetFinishButtonClicked) QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), - self.updateScreenListCombo) + Registry().register_function(u'config_screen_changed', self.updateScreenListCombo) def exec_(self): """ diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 4626d36d2..0529e20d7 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, translate, ScreenList, UiStrings +from openlp.core.lib import Registry, Receiver, Settings, SettingsTab, translate, ScreenList, UiStrings log = logging.getLogger(__name__) @@ -199,7 +199,7 @@ class GeneralTab(SettingsTab): QtCore.QObject.connect(self.customXValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) QtCore.QObject.connect(self.monitorComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged) # Reload the tab, as the screen resolution/count may have changed. - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.load) + Registry().register_function(u'config_screen_changed', self.load) # Remove for now self.usernameLabel.setVisible(False) self.usernameEdit.setVisible(False) @@ -331,7 +331,7 @@ class GeneralTab(SettingsTab): else: self.screens.reset_current_display() if self.display_changed: - Receiver.send_message(u'config_screen_changed') + Registry().execute(u'config_screen_changed') self.display_changed = False def onOverrideRadioButtonPressed(self, checked): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 9cae5dfac..3a09cc22c 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -161,7 +161,7 @@ class MainDisplay(Display): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_show'), self.showDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_display_css'), self.cssChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configChanged) + Registry().register_function(u'config_updated', self.configChanged) def setTransparency(self, enabled): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index cface47da..efb178f2d 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -529,9 +529,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.modeSetupItem, QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked) QtCore.QObject.connect(self.modeLiveItem, QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked) Registry().register_function(u'theme_update_global', self.defaultThemeChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_version_check'), self.versionNotice) + Registry().register_function(u'openlp_version_check', self.versionNotice) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) + Registry().register_function(u'config_screen_changed', self.screenChanged) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) # Media Manager QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) @@ -539,9 +539,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Simple message boxes QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_copy_data'), self.setCopyData) - # warning cyclic dependency - # renderer needs to call ThemeManager and - # ThemeManager needs to call Renderer + Registry().register_function(u'theme_update_global', self.defaultThemeChanged) + Registry().register_function(u'openlp_version_check', self.versionNotice) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) + QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) self.renderer = Renderer() # Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.mediaToolBox) diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index cfa274d0c..cdf302351 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -31,7 +31,7 @@ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab fo """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver, Settings, UiStrings +from openlp.core.lib import Registry, SettingsTab, translate, Receiver, Settings, UiStrings from openlp.core.lib.ui import create_button from openlp.core.ui.media import get_media_players, set_media_players @@ -230,7 +230,7 @@ class PlayerTab(SettingsTab): if player_string_changed: self.service_manager.reset_supported_suffixes() Receiver.send_message(u'mediaitem_media_rebuild') - Receiver.send_message(u'config_screen_changed') + Registry().execute(u'config_screen_changed') def postSetUp(self, postUpdate=False): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5a2c96782..fbd8a8d80 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -211,9 +211,8 @@ class ServiceManagerDialog(object): QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), - self.regenerate_service_Items) + Registry().register_function(u'config_updated', self.config_updated) + Registry().register_function(u'config_screen_changed', self.regenerate_service_Items) Registry().register_function(u'theme_update_global', self.theme_change) # Last little bits of setting up self.service_theme = Settings().value(self.main_window.serviceManagerSettingsSection + u'/service theme') diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 0543f1087..520e5b8bd 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -107,7 +107,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): for tabIndex in range(self.stackedLayout.count()): self.stackedLayout.widget(tabIndex).save() # Must go after all settings are save - Receiver.send_message(u'config_updated') + Registry().execute(u'config_updated') return QtGui.QDialog.accept(self) def reject(self): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index f0e16b78b..c2dab4011 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -135,7 +135,7 @@ class ThemeManager(QtGui.QWidget): QtCore.QObject.connect(self.theme_list_widget, QtCore.SIGNAL(u'currentItemChanged(QListWidgetItem *, QListWidgetItem *)'), self.check_list_state) Registry().register_function(u'theme_update_global', self.change_global_from_tab) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) + Registry().register_function(u'config_updated', self.config_updated) # Variables self.theme_list = [] self.path = AppLocation.get_section_data_path(self.settingsSection) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index f1c05e668..9d5c09e65 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -51,7 +51,7 @@ if sys.platform != u'win32' and sys.platform != u'darwin': XDG_BASE_AVAILABLE = False import openlp -from openlp.core.lib import Receiver, translate, check_directory_exists +from openlp.core.lib import translate, check_directory_exists log = logging.getLogger(__name__) APPLICATION_VERSION = {} @@ -75,7 +75,7 @@ class VersionThread(QtCore.QThread): app_version = get_application_version() version = check_latest_version(app_version) if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])): - Receiver.send_message(u'openlp_version_check', u'%s' % version) + Registry().execute(u'openlp_version_check', u'%s' % version) class AppLocation(object): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 13d770909..7ab3444dc 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, translate, create_separated_list, \ +from openlp.core.lib import Registry, MediaManagerItem, Receiver, ItemCapabilities, translate, create_separated_list, \ ServiceItemContext, Settings, UiStrings from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \ @@ -246,7 +246,7 @@ class BibleMediaItem(MediaManagerItem): # Buttons 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(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) + Registry().register_function(u'config_updated', self.configUpdated) # Other stuff QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'), diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 7b87dbef5..7b24da8db 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -32,7 +32,7 @@ import logging from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func, and_ -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, check_item_selected, translate, \ +from openlp.core.lib import Registry, MediaManagerItem, Receiver, ItemCapabilities, check_item_selected, translate, \ ServiceItemContext, Settings, PluginStatus, UiStrings from openlp.plugins.custom.forms import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder @@ -75,7 +75,7 @@ class CustomMediaItem(MediaManagerItem): self.onSearchTextButtonClicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.loadList) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) + Registry().register_function(u'config_updated', self.config_updated) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_create_from_service'), self.create_from_service_item) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index deca81f77..916ee45ad 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -75,7 +75,7 @@ class MediaMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), self.videobackgroundReplaced) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), self.rebuild_players) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.displaySetup) + Registry().register_function(u'config_screen_changed', self.displaySetup) # Allow DnD from the desktop self.listView.activateDnD() diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 1d28355c4..22024680e 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui, QtNetwork -from openlp.core.lib import Settings, SettingsTab, translate, Receiver +from openlp.core.lib import Registry, Settings, SettingsTab, translate ZERO_URL = u'0.0.0.0' @@ -152,7 +152,7 @@ class RemoteTab(SettingsTab): Settings().setValue(self.settingsSection + u'/ip address', self.addressEdit.text()) Settings().setValue(self.settingsSection + u'/twelve hour', self.twelveHour) if changed: - Receiver.send_message(u'remotes_config_updated') + Registry().register_function(u'remotes_config_updated') def onTwelveHourCheckBoxChanged(self, check_state): self.twelveHour = False diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 883865bb8..eca29f1e0 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -35,7 +35,7 @@ import shutil from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, translate, check_item_selected, \ +from openlp.core.lib import Registry, MediaManagerItem, Receiver, ItemCapabilities, translate, check_item_selected, \ PluginStatus, create_separated_list, check_directory_exists, ServiceItemContext, Settings, UiStrings from openlp.core.lib.ui import create_widget_action from openlp.core.utils import AppLocation @@ -100,7 +100,7 @@ class SongMediaItem(MediaManagerItem): self.addSearchToToolBar() # 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'config_updated'), self.configUpdated) + Registry().register_function(u'config_updated', self.configUpdated) 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'searchTypeChanged(int)'), From 1576a2c1d400c450ba97f61c6163bc102878151d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 7 Feb 2013 07:08:35 +0000 Subject: [PATCH 06/16] Config update conversion --- openlp/core/lib/plugin.py | 4 ++-- openlp/core/lib/registry.py | 10 +--------- openlp/plugins/bibles/lib/mediaitem.py | 8 ++++---- openlp/plugins/remotes/remoteplugin.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 6 +++--- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 586e35ad8..8b1951726 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -173,7 +173,7 @@ class Plugin(QtCore.QObject): Settings.extend_default_settings(default_settings) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), 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): """ @@ -402,7 +402,7 @@ class Plugin(QtCore.QObject): """ return u'' - def configUpdated(self): + def config_update(self): """ The plugin's config has changed """ diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index f9773a6d1..082592172 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -127,20 +127,12 @@ class Registry(object): for function in self.functions_list[event]: try: 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: results.append(result) except TypeError: - # Who has called me can help + # Who has called me can help in debugging import inspect log.debug(inspect.currentframe().f_back.f_locals) log.exception(u'Exception for function %s', function) return results - def inspect_result(self, results,*args, **kwargs): - """ - Dummy method for tests to inspect the results of a call. - """ - pass diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 7ab3444dc..65148143a 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -246,7 +246,7 @@ class BibleMediaItem(MediaManagerItem): # Buttons QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton) 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 QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'), @@ -258,8 +258,8 @@ class BibleMediaItem(MediaManagerItem): else: self.advancedBookComboBox.setFocus() - def configUpdated(self): - log.debug(u'configUpdated') + def config_update(self): + log.debug(u'config_update') if Settings().value(self.settingsSection + u'/second bibles'): self.advancedSecondLabel.setVisible(True) self.advancedSecondComboBox.setVisible(True) @@ -313,7 +313,7 @@ class BibleMediaItem(MediaManagerItem): translate('BiblesPlugin.MediaItem', 'Search Text...')) ]) self.quickSearchEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection)) - self.configUpdated() + self.config_update() log.debug(u'bible manager initialise complete') def loadBibles(self): diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 160b7d542..e028dfcbb 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -95,7 +95,7 @@ class RemotesPlugin(Plugin): 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 port diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index eca29f1e0..62b5d70ac 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -100,7 +100,7 @@ class SongMediaItem(MediaManagerItem): self.addSearchToToolBar() # Signals and slots 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(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), @@ -115,7 +115,7 @@ class SongMediaItem(MediaManagerItem): def onFocus(self): self.searchTextEdit.setFocus() - def configUpdated(self): + def config_update(self): self.searchAsYouType = Settings().value(self.settingsSection + u'/search as type') self.updateServiceOnEdit = Settings().value(self.settingsSection + u'/update service on edit') self.addSongFromService = Settings().value(self.settingsSection + u'/add song from service',) @@ -146,7 +146,7 @@ class SongMediaItem(MediaManagerItem): UiStrings().Themes, UiStrings().SearchThemes) ]) self.searchTextEdit.setCurrentSearchType(Settings().value(u'%s/last search type' % self.settingsSection)) - self.configUpdated() + self.config_update() def onSearchTextButtonClicked(self): # Save the current search type to the configuration. From c90d45ca73c12f9ceee86a188afdbbcee05bcacc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 7 Feb 2013 08:42:17 +0000 Subject: [PATCH 07/16] Bye Bye Event Receiver --- openlp/core/__init__.py | 4 +- openlp/core/lib/__init__.py | 1 - openlp/core/lib/eventreceiver.py | 227 ------------------ openlp/core/lib/listwidgetwithdnd.py | 7 +- openlp/core/lib/mediamanageritem.py | 5 +- openlp/core/lib/plugin.py | 5 +- openlp/core/lib/renderer.py | 6 +- openlp/core/ui/advancedtab.py | 26 +- openlp/core/ui/firsttimeform.py | 2 +- openlp/core/ui/generaltab.py | 4 +- openlp/core/ui/maindisplay.py | 16 +- openlp/core/ui/mainwindow.py | 54 ++--- openlp/core/ui/media/mediacontroller.py | 32 ++- openlp/core/ui/media/playertab.py | 4 +- openlp/core/ui/printserviceform.py | 4 +- openlp/core/ui/servicemanager.py | 10 +- openlp/core/ui/settingsform.py | 2 +- openlp/core/ui/slidecontroller.py | 83 +++---- openlp/core/ui/themeform.py | 4 +- openlp/core/ui/thememanager.py | 2 +- openlp/core/ui/wizard.py | 4 +- openlp/plugins/alerts/lib/alertsmanager.py | 26 +- openlp/plugins/alerts/lib/alertstab.py | 4 +- .../plugins/bibles/forms/bibleupgradeform.py | 4 +- openlp/plugins/bibles/lib/biblestab.py | 8 +- openlp/plugins/bibles/lib/db.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 8 +- openlp/plugins/custom/forms/editcustomform.py | 4 +- openlp/plugins/custom/lib/mediaitem.py | 13 +- openlp/plugins/images/imageplugin.py | 4 +- openlp/plugins/images/lib/imagetab.py | 4 +- openlp/plugins/images/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 7 +- openlp/plugins/media/lib/mediatab.py | 6 +- openlp/plugins/presentations/lib/mediaitem.py | 7 +- .../presentations/lib/messagelistener.py | 30 +-- .../lib/presentationcontroller.py | 4 +- .../presentations/lib/presentationtab.py | 6 +- openlp/plugins/remotes/lib/httpserver.py | 20 +- openlp/plugins/remotes/lib/remotetab.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 4 +- openlp/plugins/songs/forms/songexportform.py | 4 +- .../songs/forms/songmaintenanceform.py | 6 +- openlp/plugins/songs/lib/mediaitem.py | 9 +- openlp/plugins/songs/lib/songimport.py | 4 +- openlp/plugins/songusage/songusageplugin.py | 8 +- 46 files changed, 219 insertions(+), 483 deletions(-) delete mode 100644 openlp/core/lib/eventreceiver.py diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 083628656..d25e7a284 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -43,7 +43,7 @@ from traceback import format_exception from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, ScreenList, UiStrings, Registry, check_directory_exists +from openlp.core.lib import Settings, ScreenList, UiStrings, Registry, check_directory_exists from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm @@ -150,7 +150,7 @@ class OpenLP(QtGui.QApplication): update_check = Settings().value(u'general/update check') if update_check: VersionThread(self.main_window).start() - Receiver.send_message(u'live_display_blank_check') + self.main_window.blank_check() self.main_window.app_startup() return self.exec_() diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index c34c824db..023bd76fe 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -387,7 +387,6 @@ def create_separated_list(stringlist): from registry import Registry from uistrings import UiStrings -from eventreceiver import Receiver from screen import ScreenList from settings import Settings from listwidgetwithdnd import ListWidgetWithDnD diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py deleted file mode 100644 index ca6fe7b17..000000000 --- a/openlp/core/lib/eventreceiver.py +++ /dev/null @@ -1,227 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -Provide event handling code for OpenLP -""" -import logging - -from PyQt4 import QtCore - -log = logging.getLogger(__name__) - - -class EventReceiver(QtCore.QObject): - """ - Class to allow events to be passed from different parts of the system. This - is a private class and should not be used directly but rather via the - Receiver class. - - **Mainwindow related and generic signals** - - ``openlp_stop_wizard`` - Stops a wizard before completion. - - **Setting related signals** - - **Slidecontroller signals** - - ``slidecontroller_{live|preview}_next`` - Moves to the next slide. - - ``slidecontroller_{live|preview}_next_noloop`` - Moves to the next slide without auto advance. - - ``slidecontroller_{live|preview}_previous`` - Moves to the previous slide. - - ``slidecontroller_{live|preview}_previous_noloop`` - Moves to the previous slide, without auto advance. - - ``slidecontroller_{live|preview}_set`` - Moves to a specific slide, by index. - - ``slidecontroller_{live|preview}_started`` - Broadcasts that an item has been made live/previewed. - - ``slidecontroller_{live|preview}_change`` - Informs the slidecontroller that a slide change has occurred and to - update itself. - - ``slidecontroller_{live|preview}_changed`` - Broadcasts that the slidecontroller has changed the current slide. - - ``slidecontroller_{live|preview}_blank`` - Request that the output screen is blanked. - - ``slidecontroller_{live|preview}_unblank`` - Request that the output screen is unblanked. - - ``slidecontroller_live_spin_delay`` - Pushes out the loop delay. - - ``slidecontroller_update_slide_limits`` - Updates the slide_limits variable from the saved settings. - - ``slidecontroller_live_stop_loop`` - Stop the loop on the main display. - - **Display signals** - - ``update_display_css`` - CSS has been updated which needs to be changed on the main display. - - **Live Display signals** - - ``live_display_hide`` - Hide the live display. - - ``live_display_show`` - Return the live display. - - ``live_display_active`` - The live display has been made active. - - ``live_display_blank_check`` - Check to see if the blank display message is required. - - **Plugin specific signals** - - ``{plugin}_start`` - Requests a plugin to start a external program. Path and file have to - be provided in the message. - - ``{plugin}_first`` - Requests a plugin to handle a first event. - - ``{plugin}_previous`` - Requests a plugin to handle a previous event. - - ``{plugin}_next`` - Requests a plugin to handle a next event. - - ``{plugin}_last`` - Requests a plugin to handle a last event. - - ``{plugin}_slide`` - Requests a plugin to handle a go to specific slide event. - - ``{plugin}_stop`` - Requests a plugin to handle a stop event. - - ``{plugin}_blank`` - Requests a plugin to handle a blank screen event. - - ``{plugin}_unblank`` - Requests a plugin to handle an unblank screen event. - - ``{plugin}_load_list`` - Tells the the plugin to reload the media manager list. - - ``{plugin}_preview`` - Tells the plugin it's item can be previewed. - - ``{plugin}_add_service_item`` - Ask the plugin to push the selected items to the service item. - - ``{plugin}_service_load`` - Ask the plugin to process an individual service item after it has been - loaded. - - ``{plugin}_config_updated`` - The config has changed so tell the plugin about it. - - ``alerts_text`` - Displays an alert message. - - ``bibles_nobook`` - Attempt to find book resulted in no match. - - ``remotes_poll_request`` - Waits for openlp to do something "interesting" and sends a - ``remotes_poll_response`` signal when it does. - - """ - def __init__(self): - """ - Initialise the event receiver, calling the parent constructor. - """ - QtCore.QObject.__init__(self) - - def send_message(self, event, msg=None): - """ - Emit a Qt signal. - - ``event`` - The event to that was sent. - - ``msg`` - Defaults to *None*. The message to send with the event. - """ - log.debug(u'Event %s passed with payload %s' % (event, msg)) - self.emit(QtCore.SIGNAL(event), msg) - - -class Receiver(object): - """ - Class to allow events to be passed from different parts of the system. This - is a static wrapper around the ``EventReceiver`` class. As there is only - one instance of it in the system the Qt4 signal/slot architecture can send - messages across the system. - - To send a message: - ``Receiver.send_message(u'<>', data)`` - - To receive a Message - ``QtCore.QObject.connect( - Receiver.get_receiver(), - QtCore.SIGNAL(u'<>'), - <> - )`` - """ - __eventreceiver__ = EventReceiver() - - @staticmethod - def send_message(event, msg=None): - """ - Sends a message to the messaging system. - - ``event`` - The event to send. - - ``msg`` - Defaults to *None*. The message to send with the event. - """ - Receiver.__eventreceiver__.send_message(event, msg) - - @staticmethod - def get_receiver(): - """ - Get the global ``__eventreceiver__`` instance. - """ - return Receiver.__eventreceiver__ diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index daff870ee..987dcb240 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -33,7 +33,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver +from openlp.core.lib import Registry class ListWidgetWithDnD(QtGui.QListWidget): @@ -54,8 +54,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): """ self.setAcceptDrops(True) self.setDragDropMode(QtGui.QAbstractItemView.DragDrop) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_dnd' % self.mimeDataText), - self.parent().loadFile) + Registry().register_function((u'%s_dnd' % self.mimeDataText), self.parent().loadFile) def mouseMoveEvent(self, event): """ @@ -112,6 +111,6 @@ class ListWidgetWithDnD(QtGui.QListWidget): listing = os.listdir(localFile) for file in listing: files.append(os.path.join(localFile, file)) - Receiver.send_message(u'%s_dnd' % self.mimeDataText, files) + Registry().execute(u'%s_dnd' % self.mimeDataText, files) else: event.ignore() diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index bb8ee2f70..e132668f6 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -35,7 +35,7 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, Receiver, ListWidgetWithDnD, \ +from openlp.core.lib import OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \ ServiceItemContext, Settings, Registry, UiStrings, build_icon, translate from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import create_widget_action, critical_error_message_box @@ -116,8 +116,7 @@ class MediaManagerItem(QtGui.QWidget): self.setupUi() self.retranslateUi() self.autoSelectId = -1 - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_service_load' % self.plugin.name), - self.serviceLoad) + Registry().register_function(u'%s_service_load' % self.plugin.name, self.serviceLoad) def requiredIcons(self): """ diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 8b1951726..203f30e6e 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Receiver, Settings, Registry, UiStrings +from openlp.core.lib import Settings, Registry, UiStrings from openlp.core.utils import get_application_version log = logging.getLogger(__name__) @@ -171,8 +171,7 @@ class Plugin(QtCore.QObject): default_settings[u'%s/%s files' % (name, name)] = [] # Add settings to the dict of all settings. Settings.extend_default_settings(default_settings) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), - self.processAddServiceEvent) + Registry().register_function(u'%s_add_service_item' % self.name, self.processAddServiceEvent) Registry().register_function(u'%s_config_updated' % self.name, self.config_update) def checkPreConditions(self): diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index a54840cbb..d3c0b66d5 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -31,8 +31,8 @@ import logging from PyQt4 import QtGui, QtCore, QtWebKit -from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Receiver, Registry, ScreenList, \ - ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css +from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Registry, ScreenList, ServiceItem, \ + expand_tags, build_lyrics_format_css, build_lyrics_outline_css from openlp.core.lib.theme import ThemeLevel from openlp.core.ui import MainDisplay @@ -602,7 +602,7 @@ class Renderer(object): previous_raw = u'' # Stop here as the theme line count was requested. if self.force_page: - Receiver.send_message(u'theme_line_count', index + 1) + Registry().execute(u'theme_line_count', index + 1) break else: continue diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index ae678f2ce..76931a8bb 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -36,7 +36,7 @@ import sys from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, SettingsTab, Receiver, Settings, UiStrings, translate, build_icon +from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate, build_icon from openlp.core.utils import AppLocation, format_time, get_images_filter from openlp.core.lib import SlideLimits @@ -397,22 +397,19 @@ class AdvancedTab(SettingsTab): if not os.path.exists(self.current_data_path): log.error(u'Data path not found %s' % self.current_data_path) answer = QtGui.QMessageBox.critical(self, - translate('OpenLP.AdvancedTab', - 'Data Directory Error'), - translate('OpenLP.AdvancedTab', - 'OpenLP data directory was not found\n\n%s\n\n' + translate('OpenLP.AdvancedTab', 'Data Directory Error'), + translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n' 'This data directory was previously changed from the OpenLP ' 'default location. If the new location was on removable ' 'media, that media needs to be made available.\n\n' - 'Click "No" to stop loading OpenLP. allowing you to fix ' - 'the the problem.\n\n' + 'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n' 'Click "Yes" to reset the data directory to the default ' 'location.').replace('%s', self.current_data_path), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) if answer == QtGui.QMessageBox.No: log.info(u'User requested termination') - Receiver.send_message(u'cleanup') + self.main_window.clean_up() sys.exit() # Set data location to default. settings.remove(u'advanced/data path') @@ -457,7 +454,7 @@ class AdvancedTab(SettingsTab): if self.display_changed: Registry().execute(u'config_screen_changed') self.display_changed = False - Receiver.send_message(u'slidecontroller_update_slide_limits') + Registry().execute(u'slidecontroller_update_slide_limits') def cancel(self): """ @@ -573,7 +570,7 @@ class AdvancedTab(SettingsTab): # Check if data already exists here. self.check_data_overwrite(new_data_path) # Save the new location. - Receiver.send_message(u'set_new_data_path', new_data_path) + self.main_window.set_new_data_path(new_data_path) self.new_data_directory_edit.setText(new_data_path) self.data_directory_cancel_button.show() @@ -594,7 +591,7 @@ class AdvancedTab(SettingsTab): return self.check_data_overwrite(new_data_path) # Save the new location. - Receiver.send_message(u'set_new_data_path', new_data_path) + self.main_window.set_new_data_path(new_data_path) self.new_data_directory_edit.setText(os.path.abspath(new_data_path)) self.data_directory_cancel_button.show() else: @@ -605,8 +602,7 @@ class AdvancedTab(SettingsTab): """ Copy existing data when you change your data directory. """ - Receiver.send_message(u'set_copy_data', - self.data_directory_copy_check_box.isChecked()) + self.main_window.set_copy_data(self.data_directory_copy_check_box.isChecked()) if self.data_exists: if self.data_directory_copy_check_box.isChecked(): self.new_data_directory_has_files_label.show() @@ -645,8 +641,8 @@ class AdvancedTab(SettingsTab): """ self.new_data_directory_edit.clear() self.data_directory_copy_check_box.setChecked(False) - Receiver.send_message(u'set_new_data_path', u'') - Receiver.send_message(u'set_copy_data', False) + self.main_window.set_new_data_path(None) + self.main_window.set_copy_data(False) self.data_directory_copy_check_box.hide() self.data_directory_cancel_button.hide() self.new_data_directory_has_files_label.hide() diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 07e0a8dfe..faa2278e3 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -41,7 +41,7 @@ from ConfigParser import SafeConfigParser from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginStatus, Receiver, Settings, Registry, build_icon, check_directory_exists, translate +from openlp.core.lib import PluginStatus, Settings, Registry, build_icon, check_directory_exists, translate from openlp.core.utils import AppLocation, get_web_page, get_filesystem_encoding from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 0529e20d7..83c2ee255 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, Receiver, Settings, SettingsTab, translate, ScreenList, UiStrings +from openlp.core.lib import Registry, Settings, SettingsTab, translate, ScreenList, UiStrings log = logging.getLogger(__name__) @@ -315,7 +315,7 @@ class GeneralTab(SettingsTab): Apply settings after settings tab has loaded and most of the system so must be delayed """ - Receiver.send_message(u'slidecontroller_live_spin_delay', self.timeoutSpinBox.value()) + Registry().execute(u'slidecontroller_live_spin_delay', self.timeoutSpinBox.value()) # Do not continue on start up. if not postUpdate: return diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 89d2a316e..e376efe9a 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -42,7 +42,7 @@ import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver, ServiceItem, Settings, ImageSource, Registry, build_html, expand_tags, \ +from openlp.core.lib import ServiceItem, Settings, ImageSource, Registry, build_html, expand_tags, \ image_to_byte, translate from openlp.core.lib.theme import BackgroundType @@ -158,9 +158,9 @@ class MainDisplay(Display): self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setTransparency(False) if self.isLive: - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_show'), self.showDisplay) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_display_css'), self.cssChanged) + Registry().register_function(u'live_display_hide', self.hideDisplay) + Registry().register_function(u'live_display_show', self.showDisplay) + Registry().register_function(u'update_display_css', self.cssChanged) Registry().register_function(u'config_updated', self.configChanged) def setTransparency(self, enabled): @@ -387,11 +387,11 @@ class MainDisplay(Display): if self.override: # We have an video override so allow it to be stopped. if u'video' in self.override: - Receiver.send_message(u'video_background_replaced') + Registry().execute(u'video_background_replaced') self.override = {} # We have a different theme. elif self.override[u'theme'] != serviceItem.themedata.background_filename: - Receiver.send_message(u'live_theme_changed') + Registry().execute(u'live_theme_changed') self.override = {} else: # replace the background @@ -417,7 +417,7 @@ class MainDisplay(Display): # if was hidden keep it hidden if self.hideMode and self.isLive and not serviceItem.is_media(): if Settings().value(u'general/auto unblank'): - Receiver.send_message(u'slidecontroller_live_unblank') + Registry().execute(u'slidecontroller_live_unblank') else: self.hideDisplay(self.hideMode) self.__hideMouse() @@ -470,7 +470,7 @@ class MainDisplay(Display): self.hideMode = None # Trigger actions when display is active again. if self.isLive: - Receiver.send_message(u'live_display_active') + Registry().execute(u'live_display_active') def __hideMouse(self): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 356b7fede..976c177ef 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -41,7 +41,7 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, Receiver, ImageManager, PluginStatus, Registry, \ +from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, Registry, \ Settings, ScreenList, build_icon, check_directory_exists, translate from openlp.core.lib.ui import UiStrings, create_action from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \ @@ -497,8 +497,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Once settings are loaded update the menu with the recent files. self.updateRecentFilesMenu() self.pluginForm = PluginForm(self) - self.newDataPath = u'' - self.copyData = False + self.new_data_path = None + self.copy_data = False # Set up signals and slots QtCore.QObject.connect(self.importThemeItem, QtCore.SIGNAL(u'triggered()'), self.themeManagerContents.on_import_theme) @@ -528,21 +528,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.QObject.connect(self.modeDefaultItem, QtCore.SIGNAL(u'triggered()'), self.onModeDefaultItemClicked) QtCore.QObject.connect(self.modeSetupItem, QtCore.SIGNAL(u'triggered()'), self.onModeSetupItemClicked) QtCore.QObject.connect(self.modeLiveItem, QtCore.SIGNAL(u'triggered()'), self.onModeLiveItemClicked) - Registry().register_function(u'theme_update_global', self.defaultThemeChanged) - Registry().register_function(u'openlp_version_check', self.versionNotice) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) - Registry().register_function(u'config_screen_changed', self.screenChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) # Media Manager QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged) self.application.set_busy_cursor() # Simple message boxes - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_new_data_path'), self.setNewDataPath) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'set_copy_data'), self.setCopyData) - Registry().register_function(u'theme_update_global', self.defaultThemeChanged) - Registry().register_function(u'openlp_version_check', self.versionNotice) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_blank_check'), self.blankCheck) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'cleanup'), self.clean_up) + Registry().register_function(u'theme_update_global', self.default_theme_changed) + Registry().register_function(u'openlp_version_check', self.version_notice) + Registry().register_function(u'config_screen_changed', self.screen_changed) self.renderer = Renderer() # Define the media Dock Manager self.mediaDockManager = MediaDockManager(self.mediaToolBox) @@ -597,7 +589,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if widget: widget.onFocus() - def versionNotice(self, version): + def version_notice(self, version): """ Notifies the user that a newer version of OpenLP is available. Triggered by delay thread. @@ -698,10 +690,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Registry().execute(u'theme_update_global', self.themeManagerContents.global_theme) # Check if any Bibles downloaded. If there are, they will be # processed. - Receiver.send_message(u'bibles_load_list', True) + Registry().execute(u'bibles_load_list', True) self.application.set_normal_cursor() - def blankCheck(self): + def blank_check(self): """ Check and display message if screen blank on setup. """ @@ -1015,12 +1007,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.setPreviewPanelVisibility(preview) self.setLivePanelVisibility(live) - def screenChanged(self): + def screen_changed(self): """ The screen has changed so we have to update components such as the renderer. """ - log.debug(u'screenChanged') + log.debug(u'screen_changed') self.application.set_busy_cursor() self.imageManager.update_display() self.renderer.update_display() @@ -1093,7 +1085,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Save settings self.saveSettings() # Check if we need to change the data directory - if self.newDataPath: + if self.new_data_path: self.changeDataDirectory() # Close down the display if self.liveController.display: @@ -1145,7 +1137,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ self.statusBar.showMessage(message) - def defaultThemeChanged(self, theme): + def default_theme_changed(self, theme): """ Update the default theme indicator in the status bar """ @@ -1349,33 +1341,33 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.loadProgressBar.hide() self.application.process_events() - def setNewDataPath(self, new_data_path): + def set_new_data_path(self, new_data_path): """ Set the new data path """ - self.newDataPath = new_data_path + self.new_data_path = new_data_path - def setCopyData(self, copy_data): + def set_copy_data(self, copy_data): """ Set the flag to copy the data """ - self.copyData = copy_data + self.copy_data = copy_data def changeDataDirectory(self): """ Change the data directory. """ - log.info(u'Changing data path to %s' % self.newDataPath) + log.info(u'Changing data path to %s' % self.new_data_path) old_data_path = unicode(AppLocation.get_data_path()) # Copy OpenLP data to new location if requested. self.application.set_busy_cursor() - if self.copyData: + if self.copy_data: log.info(u'Copying data to new path') try: self.showStatusMessage( translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s ' - '- Please wait for copy to finish').replace('%s', self.newDataPath)) - dir_util.copy_tree(old_data_path, self.newDataPath) + '- Please wait for copy to finish').replace('%s', self.new_data_path)) + dir_util.copy_tree(old_data_path, self.new_data_path) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: self.application.set_normal_cursor() @@ -1389,9 +1381,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): log.info(u'No data copy requested') # Change the location of data directory in config file. settings = QtCore.QSettings() - settings.setValue(u'advanced/data path', self.newDataPath) + settings.setValue(u'advanced/data path', self.new_data_path) # Check if the new data path is our default. - if self.newDataPath == AppLocation.get_directory(AppLocation.DataDir): + if self.new_data_path == AppLocation.get_directory(AppLocation.DataDir): settings.remove(u'advanced/data path') self.application.set_normal_cursor() diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 73cd5b263..048fb5f4d 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -35,7 +35,7 @@ import os import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, Receiver, Settings, Registry, UiStrings, translate +from openlp.core.lib import OpenLPToolbar, Settings, Registry, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players from openlp.core.ui.media.mediaplayer import MediaPlayer @@ -107,21 +107,19 @@ class MediaController(object): self.timer.setInterval(200) # Signals self.timer.timeout.connect(self.media_state) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPlay'), self.media_play_msg) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackPause'), self.media_pause_msg) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'playbackStop'), self.media_stop_msg) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'seekSlider'), self.media_seek_msg) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'volumeSlider'), self.media_volume_msg) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_hide'), self.media_hide) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_blank'), self.media_blank) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_unblank'), self.media_unblank) + Registry().register_function(u'playbackPlay', self.media_play_msg) + Registry().register_function(u'playbackPause', self.media_pause_msg) + Registry().register_function(u'playbackStop', self.media_stop_msg) + Registry().register_function(u'seekSlider', self.media_seek_msg) + Registry().register_function(u'volumeSlider', self.media_volume_msg) + Registry().register_function(u'media_hide', self.media_hide) + Registry().register_function(u'media_blank', self.media_blank) + Registry().register_function(u'media_unblank', self.media_unblank) # Signals for background video - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_hide'), self.media_hide) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_unblank'), self.media_unblank) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), - self._set_active_players) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'), - self._generate_extensions_lists) + Registry().register_function(u'songs_hide', self.media_hide) + Registry().register_function(u'songs_unblank', self.media_unblank) + Registry().register_function(u'mediaitem_media_rebuild', self._set_active_players) + Registry().register_function(u'mediaitem_suffixes', self._generate_extensions_lists) def _set_active_players(self): """ @@ -694,7 +692,7 @@ class MediaController(object): hide_mode = msg[2] if not isLive: return - Receiver.send_message(u'live_display_hide', hide_mode) + Registry().execute(u'live_display_hide', hide_mode) controller = self.mainWindow.liveController display = self._define_display(controller) if self.currentMediaPlayer[controller.controllerType].state == MediaState.Playing: @@ -709,7 +707,7 @@ class MediaController(object): First element is not relevant in this context Second element is the boolean for Live indication """ - Receiver.send_message(u'live_display_show') + Registry().execute(u'live_display_show') isLive = msg[1] if not isLive: return diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index a8ff0a2d3..d8b896864 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -31,7 +31,7 @@ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab fo """ from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, SettingsTab, Receiver, Settings, UiStrings, translate +from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate from openlp.core.lib.ui import create_button from openlp.core.ui.media import get_media_players, set_media_players @@ -229,7 +229,7 @@ class PlayerTab(SettingsTab): player_string_changed = True if player_string_changed: self.service_manager.reset_supported_suffixes() - Receiver.send_message(u'mediaitem_media_rebuild') + Registry().execute(u'mediaitem_media_rebuild') Registry().execute(u'config_screen_changed') def postSetUp(self, postUpdate=False): diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index d9fa54f36..074b4d96a 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -36,7 +36,7 @@ import os from PyQt4 import QtCore, QtGui from lxml import html -from openlp.core.lib import Receiver, Settings, UiStrings, Registry, translate, get_text_file_string +from openlp.core.lib import Settings, UiStrings, Registry, translate, get_text_file_string from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.utils import AppLocation @@ -408,7 +408,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): return for item in self.service_manager.serviceItems: # Trigger Audit requests - Receiver.send_message(u'print_service_started', [item[u'service_item']]) + Registry().register_function(u'print_service_started', [item[u'service_item']]) def _get_service_manager(self): """ diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 86cbd7024..ac39cc2d4 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -42,7 +42,7 @@ log = logging.getLogger(__name__) from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, ItemCapabilities, Settings, PluginStatus, Registry, \ +from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, Settings, PluginStatus, Registry, \ UiStrings, build_icon, translate, str_to_bool, check_directory_exists from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box @@ -210,7 +210,7 @@ class ServiceManagerDialog(object): self.collapsed) QtCore.QObject.connect(self.service_manager_list, QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.update_theme_list) + Registry().register_function(u'theme_update_list', self.update_theme_list) Registry().register_function(u'config_updated', self.config_updated) Registry().register_function(u'config_screen_changed', self.regenerate_service_Items) Registry().register_function(u'theme_update_global', self.theme_change) @@ -733,7 +733,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): service_item.validate_item(self.suffixes) self.load_item_unique_identifier = 0 if service_item.is_capable(ItemCapabilities.OnLoadUpdate): - Receiver.send_message(u'%s_service_load' % service_item.name.lower(), service_item) + Registry().execute(u'%s_service_load' % service_item.name.lower(), service_item) # if the item has been processed if service_item.unique_identifier == self.load_item_unique_identifier: service_item.edit_id = int(self.load_item_edit_id) @@ -1436,7 +1436,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Saves the current text item as a custom slide """ item = self.find_service_item()[0] - Receiver.send_message(u'custom_create_from_service', self.service_items[item][u'service_item']) + Registry().execute(u'custom_create_from_service', self.service_items[item][u'service_item']) def find_service_item(self): """ @@ -1523,7 +1523,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): replace = True else: self.drop_position = self._get_parent_item_data(item) - Receiver.send_message(u'%s_add_service_item' % plugin, replace) + Registry().execute(u'%s_add_service_item' % plugin, replace) def update_theme_list(self, theme_list): """ diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 221955ce0..1b000f16b 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtGui -from openlp.core.lib import Receiver, PluginStatus, Registry, build_icon +from openlp.core.lib import PluginStatus, Registry, build_icon from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from openlp.core.ui.media import PlayerTab from settingsdialog import Ui_SettingsDialog diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 607ae1dd5..c5ae4cdce 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`slidecontroller` module contains argubly the most important part of OpenLP - the slide controller +The :mod:`slidecontroller` module contains the most important part of OpenLP - the slide controller """ import os import logging @@ -36,7 +36,7 @@ from collections import deque from PyQt4 import QtCore, QtGui -from openlp.core.lib import OpenLPToolbar, Receiver, ItemCapabilities, ServiceItem, ImageSource, SlideLimits, \ +from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, SlideLimits, \ ServiceItemAction, Settings, Registry, UiStrings, ScreenList, build_icon, build_html, translate from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType from openlp.core.lib.ui import create_action @@ -66,7 +66,7 @@ class DisplayController(QtGui.QWidget): """ sender = self.sender().objectName() if self.sender().objectName() else self.sender().text() controller = self - Receiver.send_message('%s' % sender, [controller, args]) + Registry().execute('%s' % sender, [controller, args]) class SlideController(DisplayController): @@ -362,10 +362,8 @@ class SlideController(DisplayController): # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) if self.isLive: - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_live_spin_delay'), self.receiveSpinDelay) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_toggle_display'), self.toggleDisplay) + Registry().register_function(u'slidecontroller_live_spin_delay', self.receiveSpinDelay) + Registry().register_function(u'slidecontroller_toggle_display', self.toggleDisplay) self.toolbar.setWidgetVisible(self.loopList, False) self.toolbar.setWidgetVisible(self.wideMenu, False) else: @@ -377,22 +375,14 @@ class SlideController(DisplayController): self.__addActionsToWidget(self.previewListWidget) else: self.previewListWidget.addActions([self.nextItem, self.previousItem]) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_next' % self.typePrefix), self.onSlideSelectedNext) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.typePrefix), self.onSlideSelectedPrevious) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_change' % self.typePrefix), self.onSlideChange) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_set' % self.typePrefix), self.onSlideSelectedIndex) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_blank' % self.typePrefix), self.onSlideBlank) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix), self.onSlideUnblank) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'slidecontroller_update_slide_limits'), self.updateSlideLimits) + Registry().register_function(u'slidecontroller_%s_stop_loop' % self.typePrefix, self.onStopLoop) + Registry().register_function(u'slidecontroller_%s_next' % self.typePrefix, self.onSlideSelectedNext) + Registry().register_function(u'slidecontroller_%s_previous' % self.typePrefix, self.onSlideSelectedPrevious) + Registry().register_function(u'slidecontroller_%s_change' % self.typePrefix, self.onSlideChange) + Registry().register_function(u'slidecontroller_%s_set' % self.typePrefix, self.onSlideSelectedIndex) + Registry().register_function(u'slidecontroller_%s_blank' % self.typePrefix, self.onSlideBlank) + Registry().register_function(u'slidecontroller_%s_unblank' % self.typePrefix, self.onSlideUnblank) + Registry().register_function(u'slidecontroller_update_slide_limits', self.updateSlideLimits) def _slideShortcutActivated(self): """ @@ -756,8 +746,7 @@ class SlideController(DisplayController): self.serviceItem = copy.copy(serviceItem) if old_item and self.isLive and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay): self._resetBlank() - Receiver.send_message(u'%s_start' % serviceItem.name.lower(), - [serviceItem, self.isLive, self.hideMode(), slideno]) + Registry().execute(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, self.hideMode(), slideno]) self.slideList = {} width = self.parent().controlSplitter.sizes()[self.split] self.previewListWidget.clear() @@ -853,10 +842,10 @@ class SlideController(DisplayController): # However opening a new item of the same type will automatically # close the previous, so make sure we don't close the new one. if old_item.is_command() and not serviceItem.is_command(): - Receiver.send_message(u'%s_stop' % old_item.name.lower(), [old_item, self.isLive]) + Registry().execute(u'%s_stop' % old_item.name.lower(), [old_item, self.isLive]) if old_item.is_media() and not serviceItem.is_media(): self.onMediaClose() - Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem]) + Registry().execute(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem]) def __updatePreviewSelection(self, slideno): """ @@ -877,7 +866,7 @@ class SlideController(DisplayController): if not self.serviceItem: return if self.serviceItem.is_command(): - Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, index]) + Registry().execute(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, index]) self.updatePreview() else: self.__checkUpdateSelectedSlide(index) @@ -898,7 +887,7 @@ class SlideController(DisplayController): elif display_type == u'blanked': self.onBlankDisplay(True) else: - Receiver.send_message(u'live_display_show') + Registry().execute(u'live_display_show') else: self.liveEscape() @@ -980,18 +969,18 @@ class SlideController(DisplayController): if self.serviceItem is not None: if hide_mode: if not self.serviceItem.is_command(): - Receiver.send_message(u'live_display_hide', hide_mode) - Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(), + Registry().execute(u'live_display_hide', hide_mode) + Registry().execute(u'%s_blank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, hide_mode]) else: if not self.serviceItem.is_command(): - Receiver.send_message(u'live_display_show') - Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'live_display_show') + Registry().execute(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: if hide_mode: - Receiver.send_message(u'live_display_hide', hide_mode) + Registry().execute(u'live_display_hide', hide_mode) else: - Receiver.send_message(u'live_display_show') + Registry().execute(u'live_display_show') def hidePlugin(self, hide): """ @@ -1000,17 +989,17 @@ class SlideController(DisplayController): log.debug(u'hidePlugin %s ', hide) if self.serviceItem is not None: if hide: - Receiver.send_message(u'live_display_hide', HideMode.Screen) - Receiver.send_message(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'live_display_hide', HideMode.Screen) + Registry().execute(u'%s_hide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: if not self.serviceItem.is_command(): - Receiver.send_message(u'live_display_show') - Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'live_display_show') + Registry().execute(u'%s_unblank' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) else: if hide: - Receiver.send_message(u'live_display_hide', HideMode.Screen) + Registry().execute(u'live_display_hide', HideMode.Screen) else: - Receiver.send_message(u'live_display_show') + Registry().execute(u'live_display_show') def onSlideSelected(self): """ @@ -1028,7 +1017,7 @@ class SlideController(DisplayController): if -1 < row < self.previewListWidget.rowCount(): if self.serviceItem.is_command(): if self.isLive and not start: - Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), + Registry().execute(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, row]) else: to_display = self.serviceItem.get_rendered_frame(row) @@ -1044,7 +1033,7 @@ class SlideController(DisplayController): self.updatePreview() self.selectedRow = row self.__checkUpdateSelectedSlide(row) - Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row) + Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row) self.display.setFocus() def onSlideChange(self, row): @@ -1053,7 +1042,7 @@ class SlideController(DisplayController): """ self.__checkUpdateSelectedSlide(row) self.updatePreview() - Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row) + Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row) def updatePreview(self): """ @@ -1092,7 +1081,7 @@ class SlideController(DisplayController): """ if not self.serviceItem: return - Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command() and self.isLive: self.updatePreview() else: @@ -1119,7 +1108,7 @@ class SlideController(DisplayController): """ if not self.serviceItem: return - Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_command() and self.isLive: self.updatePreview() else: @@ -1259,7 +1248,7 @@ class SlideController(DisplayController): # Live and Preview have issues if we have video or presentations # playing in both at the same time. if self.serviceItem.is_command(): - Receiver.send_message(u'%s_stop' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) + Registry().execute(u'%s_stop' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive]) if self.serviceItem.is_media(): self.onMediaClose() self.onGoLive() diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index a23e08207..0f96631ae 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, UiStrings, Registry, translate +from openlp.core.lib import UiStrings, Registry, translate from openlp.core.lib.theme import BackgroundType, BackgroundGradientType from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import ThemeLayoutForm @@ -88,7 +88,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QObject.connect(self.footerPositionCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onFooterPositionCheckBoxStateChanged) QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_line_count'), self.updateLinesText) + Registry().register_function(u'theme_line_count', self.updateLinesText) QtCore.QObject.connect(self.mainSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) QtCore.QObject.connect(self.lineSpacingSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) QtCore.QObject.connect(self.outlineSizeSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.calculateLines) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index db1eb9b9f..83604766d 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -38,7 +38,7 @@ import re from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.lib import ImageSource, OpenLPToolbar, Receiver, Registry, SettingsManager, Settings, UiStrings, \ +from openlp.core.lib import ImageSource, OpenLPToolbar, Registry, SettingsManager, Settings, UiStrings, \ get_text_file_string, build_icon, translate, check_item_selected, check_directory_exists, create_thumb, \ validate_thumb from openlp.core.lib.theme import ThemeXML, BackgroundType, VerticalType, BackgroundGradientType diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 744dd8087..0947abcd1 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Registry, Settings, UiStrings, build_icon, translate +from openlp.core.lib import Registry, Settings, UiStrings, build_icon, translate from openlp.core.lib.ui import add_welcome_page log = logging.getLogger(__name__) @@ -173,7 +173,7 @@ class OpenLPWizard(QtGui.QWizard): """ log.debug(u'Wizard cancelled by user.') if self.currentPage() == self.progressPage: - Receiver.send_message(u'openlp_stop_wizard') + Registry().execute(u'openlp_stop_wizard') self.done(QtGui.QDialog.Rejected) def onCurrentIdChanged(self, pageId): diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 7ca324f88..03f36f09e 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -35,7 +35,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Registry, Receiver, translate +from openlp.core.lib import Registry, translate log = logging.getLogger(__name__) @@ -49,19 +49,19 @@ class AlertsManager(QtCore.QObject): QtCore.QObject.__init__(self, parent) self.screen = None self.timer_id = 0 - self.alertList = [] - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_display_active'), self.generateAlert) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alerts_text'), self.onAlertText) + self.alert_list = [] + Registry().register_function(u'live_display_active', self.generate_alert) + Registry().register_function(u'alerts_text', self.alert_text) - def onAlertText(self, message): + def alert_text(self, message): """ Called via a alerts_text event. Message is single element array containing text """ if message: - self.displayAlert(message[0]) + self.display_alert(message[0]) - def displayAlert(self, text=u''): + def display_alert(self, text=u''): """ Called from the Alert Tab to display an alert @@ -70,22 +70,22 @@ class AlertsManager(QtCore.QObject): """ log.debug(u'display alert called %s' % text) if text: - self.alertList.append(text) + self.alert_list.append(text) if self.timer_id != 0: self.main_window.show_status_message( translate('AlertsPlugin.AlertsManager', 'Alert message created and displayed.')) return self.main_window.show_status_message(u'') - self.generateAlert() + self.generate_alert() - def generateAlert(self): + def generate_alert(self): """ Format and request the Alert and start the timer """ log.debug(u'Generate Alert called') - if not self.alertList: + if not self.alert_list: return - text = self.alertList.pop(0) + text = self.alert_list.pop(0) alertTab = self.parent().settingsTab self.parent().liveController.display.alert(text, alertTab.location) # Check to see if we have a timer running. @@ -106,7 +106,7 @@ class AlertsManager(QtCore.QObject): self.parent().liveController.display.alert(u'', alertTab.location) self.killTimer(self.timer_id) self.timer_id = 0 - self.generateAlert() + self.generate_alert() def _get_main_window(self): """ diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 05aff7fd6..61311684d 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate +from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate from openlp.core.lib.ui import create_valign_selection_widgets class AlertsTab(SettingsTab): @@ -174,7 +174,7 @@ class AlertsTab(SettingsTab): settings.setValue(u'location', self.location) settings.endGroup() if self.changed: - Receiver.send_message(u'update_display_css') + Registry().execute(u'update_display_css') self.changed = False def updateDisplay(self): diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index f7f16aace..189901a6e 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -36,7 +36,7 @@ from tempfile import gettempdir from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Settings, UiStrings, translate, check_directory_exists +from openlp.core.lib import Registry, Settings, UiStrings, translate, check_directory_exists from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, delete_file, get_filesystem_encoding @@ -82,7 +82,7 @@ class BibleUpgradeForm(OpenLPWizard): Set up the UI for the bible wizard. """ OpenLPWizard.setupUi(self, image) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + Registry().execute(u'openlp_stop_wizard', self.stop_import) def stop_import(self): """ diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 0ac667697..815fc7178 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, SettingsTab, Settings, UiStrings, translate +from openlp.core.lib import Registry, SettingsTab, Settings, UiStrings, translate from openlp.core.lib.ui import find_and_set_in_combo_box from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, update_reference_separators, \ get_reference_separator, LanguageSelection @@ -168,7 +168,7 @@ class BiblesTab(SettingsTab): self.onEndSeparatorLineEditEdited) QtCore.QObject.connect(self.endSeparatorLineEdit, QtCore.SIGNAL(u'editingFinished()'), self.onEndSeparatorLineEditFinished) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) + Registry().register_function(u'theme_update_list', self.update_theme_list) QtCore.QObject.connect(self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'), self.onLanguageSelectionComboBoxChanged) @@ -406,10 +406,10 @@ class BiblesTab(SettingsTab): else: settings.remove(u'end separator') update_reference_separators() - Receiver.send_message(u'bibles_load_list') + Registry().execute(u'bibles_load_list') settings.endGroup() - def updateThemeList(self, theme_list): + def update_theme_list(self, theme_list): """ Called from ThemeManager when the Themes have changed. diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 7b6c94353..93f3a6bc5 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -38,7 +38,7 @@ from sqlalchemy import Column, ForeignKey, Table, or_, types, func from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm.exc import UnmappedClassError -from openlp.core.lib import Receiver, Registry, translate +from openlp.core.lib import Registry, translate from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, clean_filename @@ -160,7 +160,7 @@ class BibleDB(QtCore.QObject, Manager): if u'path' in kwargs: self.path = kwargs[u'path'] self.wizard = None - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + Registry().execute(u'openlp_stop_wizard', self.stop_import) def stop_import(self): """ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 2f0836672..8375e3fc3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -31,8 +31,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, \ - UiStrings, create_separated_list, translate +from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \ + create_separated_list, translate from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \ critical_error_message_box, find_and_set_in_combo_box, build_icon @@ -70,7 +70,8 @@ class BibleMediaItem(MediaManagerItem): self.search_results = {} self.second_search_results = {} self.checkSearchResult() - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'bibles_load_list'), self.reloadBibles) + Registry().register_function(u'bibles_load_list', self.reloadBibles) + Registry().register_function(u'config_updated', self.config_update) def __checkSecondBible(self, bible, second_bible): """ @@ -246,7 +247,6 @@ class BibleMediaItem(MediaManagerItem): # Buttons QtCore.QObject.connect(self.advancedSearchButton, QtCore.SIGNAL(u'clicked()'), self.onAdvancedSearchButton) QtCore.QObject.connect(self.quickSearchButton, QtCore.SIGNAL(u'clicked()'), self.onQuickSearchButton) - Registry().register_function(u'config_updated', self.config_update) # Other stuff QtCore.QObject.connect(self.quickSearchEdit, QtCore.SIGNAL(u'returnPressed()'), self.onQuickSearchButton) QtCore.QObject.connect(self.searchTabBar, QtCore.SIGNAL(u'currentChanged(int)'), diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a308737a2..a306ed174 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, Registry, translate +from openlp.core.lib import Registry, translate from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser from openlp.plugins.custom.lib.db import CustomSlide @@ -190,7 +190,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ log.debug(u'onPreview') if self.saveCustom(): - Receiver.send_message(u'custom_preview') + Registry().execute(u'custom_preview') def updateSlideList(self, slides, edit_all=False): """ diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 3d290a601..b3226cdc4 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -32,8 +32,8 @@ import logging from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func, and_ -from openlp.core.lib import Registry, MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, \ - PluginStatus, UiStrings, check_item_selected, translate +from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, Settings, PluginStatus,\ + UiStrings, check_item_selected, translate from openlp.plugins.custom.forms import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder from openlp.plugins.custom.lib.db import CustomSlide @@ -73,11 +73,10 @@ class CustomMediaItem(MediaManagerItem): QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), self.onSearchTextButtonClicked) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_load_list'), self.loadList) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) + Registry().register_function(u'custom_load_list', self.loadList) + Registry().register_function(u'custom_preview', self.onPreviewClick) Registry().register_function(u'config_updated', self.config_updated) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_create_from_service'), - self.create_from_service_item) + Registry().register_function(u'custom_create_from_service', self.create_from_service_item) def config_updated(self): self.add_custom_from_service = Settings().value(self.settingsSection + u'/add custom from service') @@ -280,7 +279,7 @@ class CustomMediaItem(MediaManagerItem): self.plugin.manager.save_object(custom) self.onSearchTextButtonClicked() if item.name.lower() == u'custom': - Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False)) + Registry().execute(u'service_item_update', u'%s:%s:%s' % (custom.id, item.unique_identifier, False)) def onClearTextButtonClick(self): """ diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 0f2829dbc..7f7a56dc0 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui import logging -from openlp.core.lib import Plugin, StringContent, Receiver, ImageSource, Settings, build_icon, translate +from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, Settings, build_icon, translate from openlp.plugins.images.lib import ImageMediaItem, ImageTab log = logging.getLogger(__name__) @@ -50,7 +50,7 @@ class ImagePlugin(Plugin): self.weight = -7 self.iconPath = u':/plugins/plugin_images.png' self.icon = build_icon(self.iconPath) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'image_updated'), self.image_updated) + Registry().execute(u'image_updated', self.image_updated) def about(self): about_text = translate('ImagePlugin', 'Image Plugin' diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index ce3e9b957..d5ff96666 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, Receiver, Settings, UiStrings, translate +from openlp.core.lib import SettingsTab, Registry, Settings, UiStrings, translate class ImageTab(SettingsTab): """ @@ -91,5 +91,5 @@ class ImageTab(SettingsTab): settings.setValue(u'background color', self.bg_color) settings.endGroup() if self.initial_color != self.bg_color: - Receiver.send_message(u'image_updated') + Registry().execute(u'image_updated') diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 0ab73aa46..1a23ff9e4 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, ItemCapabilities, Receiver, SettingsManager, ServiceItemContext, \ +from openlp.core.lib import MediaManagerItem, ItemCapabilities, Registry, SettingsManager, ServiceItemContext, \ Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, create_thumb, translate, \ validate_thumb from openlp.core.lib.ui import critical_error_message_box @@ -51,7 +51,7 @@ class ImageMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, plugin, icon) self.quickPreviewAllowed = True self.hasSearch = True - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged) + Registry().register_function(u'live_theme_changed', self.liveThemeChanged) # Allow DnD from the desktop self.listView.activateDnD() diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index f02b254d5..3f0821f53 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Receiver, ServiceItem, ServiceItemContext, \ +from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Registry, ServiceItem, ServiceItemContext, \ Settings, UiStrings, build_icon, check_item_selected, check_directory_exists, translate from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.ui import DisplayController, Display, DisplayControllerType @@ -71,9 +71,8 @@ class MediaMediaItem(MediaManagerItem): self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()} self.displayController.previewDisplay.setup() self.media_controller.setup_display(self.displayController.previewDisplay, False) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'video_background_replaced'), - self.videobackgroundReplaced) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_media_rebuild'), self.rebuild_players) + Registry().register_function(u'video_background_replaced', self.videobackgroundReplaced) + Registry().register_function(u'mediaitem_media_rebuild', self.rebuild_players) Registry().register_function(u'config_screen_changed', self.displaySetup) # Allow DnD from the desktop self.listView.activateDnD() diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 69a21d0a4..b7ec1aa39 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate +from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate class MediaQCheckBox(QtGui.QCheckBox): """ @@ -84,5 +84,5 @@ class MediaTab(SettingsTab): Settings().setValue(setting_key, self.autoStartCheckBox.checkState()) if override_changed: self.parent.reset_supported_suffixes() - Receiver.send_message(u'mediaitem_media_rebuild') - Receiver.send_message(u'mediaitem_suffixes') + Registry().execute(u'mediaitem_media_rebuild') + Registry().execute(u'mediaitem_suffixes') diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 1875ca66c..67d040aae 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \ +from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext, Settings, UiStrings, \ build_icon, check_item_selected, create_thumb, translate, validate_thumb from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.utils import locale_compare @@ -60,9 +60,8 @@ class PresentationMediaItem(MediaManagerItem): self.message_listener = MessageListener(self) self.hasSearch = True self.singleServiceItem = False - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), - self.populateDisplayTypes) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'mediaitem_suffixes'), self.buildFileMaskString) + Registry().register_function(u'mediaitem_presentation_rebuild', self.populateDisplayTypes) + Registry().register_function(u'mediaitem_suffixes', self.buildFileMaskString) # Allow DnD from the desktop self.listView.activateDnD() diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index cde59209a..95713196e 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore -from openlp.core.lib import Receiver +from openlp.core.lib import Registry from openlp.core.ui import HideMode log = logging.getLogger(__name__) @@ -71,7 +71,7 @@ class Controller(object): self.hide_mode = hide_mode if self.is_live: if hide_mode == HideMode.Screen: - Receiver.send_message(u'live_display_hide', HideMode.Screen) + Registry().execute(u'live_display_hide', HideMode.Screen) self.stop() elif hide_mode == HideMode.Theme: self.blank(hide_mode) @@ -79,7 +79,7 @@ class Controller(object): self.blank(hide_mode) else: self.doc.start_presentation() - Receiver.send_message(u'live_display_hide', HideMode.Screen) + Registry().execute(u'live_display_hide', HideMode.Screen) self.doc.slidenumber = 1 if slide_no > 1: self.slide(slide_no) @@ -236,7 +236,7 @@ class Controller(object): return if not self.doc.is_active(): return - Receiver.send_message(u'live_display_hide', HideMode.Theme) + Registry().execute(u'live_display_hide', HideMode.Theme) elif hide_mode == HideMode.Blank: if not self.activate(): return @@ -273,7 +273,7 @@ class Controller(object): if self.doc.slidenumber and self.doc.slidenumber != self.doc.get_slide_number(): self.doc.goto_slide(self.doc.slidenumber) self.doc.unblank_screen() - Receiver.send_message(u'live_display_hide', HideMode.Screen) + Registry().execute(u'live_display_hide', HideMode.Screen) def poll(self): if not self.doc: @@ -294,16 +294,16 @@ class MessageListener(object): self.preview_handler = Controller(False) self.live_handler = Controller(True) # messages are sent from core.ui.slidecontroller - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_start'), self.startup) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_stop'), self.shutdown) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_hide'), self.hide) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_first'), self.first) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_previous'), self.previous) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_next'), self.next) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_last'), self.last) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_slide'), self.slide) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_blank'), self.blank) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_unblank'), self.unblank) + Registry().register_function(u'presentations_start', self.startup) + Registry().register_function(u'presentations_stop', self.shutdown) + Registry().register_function(u'presentations_hide', self.hide) + Registry().register_function(u'presentations_first', self.first) + Registry().register_function(u'presentations_previous', self.previous) + Registry().register_function(u'presentations_next', self.next) + Registry().register_function(u'presentations_last', self.last) + Registry().register_function(u'presentations_slide', self.slide) + Registry().register_function(u'presentations_blank', self.blank) + Registry().register_function(u'presentations_unblank', self.unblank) self.timer = QtCore.QTimer() self.timer.setInterval(500) QtCore.QObject.connect(self.timer, QtCore.SIGNAL(u'timeout()'), self.timeout) diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index fad88d7cd..4348e23dc 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -33,7 +33,7 @@ import shutil from PyQt4 import QtCore -from openlp.core.lib import Receiver, Registry, Settings, check_directory_exists, create_thumb, validate_thumb +from openlp.core.lib import Registry, Settings, check_directory_exists, create_thumb, validate_thumb from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -274,7 +274,7 @@ class PresentationDocument(object): prefix = u'live' else: prefix = u'preview' - Receiver.send_message(u'slidecontroller_%s_change' % prefix, self.slidenumber - 1) + Registry().execute(u'slidecontroller_%s_change' % prefix, self.slidenumber - 1) def get_slide_text(self, slide_no): """ diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index 15b3b2590..d436e23af 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -29,7 +29,7 @@ from PyQt4 import QtGui -from openlp.core.lib import Receiver, Settings, SettingsTab, UiStrings, translate +from openlp.core.lib import Registry, Settings, SettingsTab, UiStrings, translate class PresentationTab(SettingsTab): """ @@ -130,8 +130,8 @@ class PresentationTab(SettingsTab): changed = True if changed: self.parent.reset_supported_suffixes() - Receiver.send_message(u'mediaitem_presentation_rebuild') - Receiver.send_message(u'mediaitem_suffixes') + Registry().execute(u'mediaitem_presentation_rebuild') + Registry().execute(u'mediaitem_suffixes') def tabVisible(self): """ diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index d444fc1c4..70df2bcd9 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -123,7 +123,7 @@ import urlparse from PyQt4 import QtCore, QtNetwork from mako.template import Template -from openlp.core.lib import Receiver, Settings, PluginStatus, StringContent +from openlp.core.lib import Registry, Settings, PluginStatus, StringContent from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) @@ -175,10 +175,8 @@ class HttpServer(object): address = Settings().value(self.plugin.settingsSection + u'/ip address') self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_changed'), - self.slide_change) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'), - self.item_change) + Registry().register_function(u'slidecontroller_live_changed', self.slide_change) + Registry().register_function(u'slidecontroller_live_started', self.item_change) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'newConnection()'), self.new_connection) log.debug(u'TCP listening on port %d' % port) @@ -406,7 +404,7 @@ class HttpConnection(object): ``action`` This is the action, either ``hide`` or ``show``. """ - Receiver.send_message(u'slidecontroller_toggle_display', action) + Registry().execute(u'slidecontroller_toggle_display', action) return HttpResponse(json.dumps({u'results': {u'success': True}}), {u'Content-Type': u'application/json'}) @@ -421,7 +419,7 @@ class HttpConnection(object): except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') text = urllib.unquote(text) - Receiver.send_message(u'alerts_text', [text]) + Registry().execute(u'alerts_text', [text]) success = True else: success = False @@ -471,9 +469,9 @@ class HttpConnection(object): log.info(data) # This slot expects an int within a list. id = data[u'request'][u'id'] - Receiver.send_message(event, [id]) + Registry().execute(event, [id]) else: - Receiver.send_message(event) + Registry().execute(event) json_data = {u'results': {u'success': True}} return HttpResponse(json.dumps(json_data), {u'Content-Type': u'application/json'}) @@ -490,9 +488,9 @@ class HttpConnection(object): data = json.loads(self.url_params[u'data'][0]) except KeyError, ValueError: return HttpResponse(code=u'400 Bad Request') - Receiver.send_message(event, data[u'request'][u'id']) + Registry().execute(event, data[u'request'][u'id']) else: - Receiver.send_message(event) + Registry().execute(event) return HttpResponse(json.dumps({u'results': {u'success': True}}), {u'Content-Type': u'application/json'}) diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 91b9e64c9..38b8753ab 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore, QtGui, QtNetwork -from openlp.core.lib import Registry, Settings, SettingsTab, Receiver, translate +from openlp.core.lib import Registry, Settings, SettingsTab, translate ZERO_URL = u'0.0.0.0' diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 7898ae953..4b8d46ccd 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -38,7 +38,7 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, PluginStatus, Receiver, MediaType, translate, create_separated_list, \ +from openlp.core.lib import Registry, PluginStatus, MediaType, translate, create_separated_list, \ check_directory_exists, UiStrings from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, \ find_and_set_in_combo_box @@ -699,7 +699,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): log.debug(u'onPreview') if button.objectName() == u'previewButton': self.saveSong(True) - Receiver.send_message(u'songs_preview') + Registry().execute(u'songs_preview') def onAudioAddFromFileButtonClicked(self): """ diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index f4773b3da..f21e8672a 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -34,7 +34,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, UiStrings, create_separated_list, build_icon, translate +from openlp.core.lib import Registry, UiStrings, create_separated_list, build_icon, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib import natcmp @@ -62,7 +62,7 @@ class SongExportForm(OpenLPWizard): """ OpenLPWizard.__init__(self, parent, plugin, u'songExportWizard', u':/wizards/wizard_exportsong.bmp') self.stop_export_flag = False - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_export) + Registry().register_function(u'openlp_stop_wizard', self.stop_export) def stop_export(self): """ diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 546791778..262789ddf 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ -from openlp.core.lib import Receiver, UiStrings, translate +from openlp.core.lib import Registry, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms import AuthorsForm, TopicsForm, SongBookForm from openlp.plugins.songs.lib.db import Author, Book, Topic, Song @@ -283,7 +283,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.manager.save_object(author): self.resetAuthors() if not self.fromSongEdit: - Receiver.send_message(u'songs_load_list') + Registry().execute(u'songs_load_list') else: critical_error_message_box( message=translate('SongsPlugin.SongMaintenanceForm', 'Could not save your changes.')) @@ -378,7 +378,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): merge(dbObject) reset() if not self.fromSongEdit: - Receiver.send_message(u'songs_load_list') + Registry().execute(u'songs_load_list') self.application.set_normal_cursor() def mergeAuthors(self, oldAuthor): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 2571e21d2..b273cf3b8 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -36,8 +36,7 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ -from openlp.core.lib import Registry, MediaManagerItem, Receiver, ItemCapabilities, PluginStatus, ServiceItemContext, \ - Settings, \ +from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \ UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists from openlp.core.lib.ui import create_widget_action from openlp.core.utils import AppLocation @@ -101,9 +100,9 @@ class SongMediaItem(MediaManagerItem): triggers=self.onSongMaintenanceClick) self.addSearchToToolBar() # Signals and slots - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_load_list'), self.onSongListLoad) + Registry().register_function(u'songs_load_list', self.onSongListLoad) Registry().register_function(u'config_updated', self.config_update) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'songs_preview'), self.onPreviewClick) + Registry().register_function(u'songs_preview', self.onPreviewClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'searchTypeChanged(int)'), self.onSearchTextButtonClicked) @@ -295,7 +294,7 @@ class SongMediaItem(MediaManagerItem): self.importWizard = SongImportForm(self, self.plugin) self.importWizard.exec_() # Run song load as list may have been cancelled but some songs loaded - Receiver.send_message(u'songs_load_list') + Registry().execute(u'songs_load_list') def onExportClick(self): if not hasattr(self, u'exportWizard'): diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 10f58b232..735c7c477 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore -from openlp.core.lib import Receiver, translate, check_directory_exists +from openlp.core.lib import Registry, translate, check_directory_exists from openlp.core.ui.wizard import WizardStrings from openlp.core.utils import AppLocation from openlp.plugins.songs.lib import clean_song, VerseType @@ -83,7 +83,7 @@ class SongImport(QtCore.QObject): self.song = None self.stopImportFlag = False self.setDefaults() - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stopImport) + Registry().register_function(u'openlp_stop_wizard', self.stopImport) def setDefaults(self): """ diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 3b3611f0e..a9b05b1f4 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -32,7 +32,7 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, Receiver, Settings, StringContent, build_icon, translate +from openlp.core.lib import Plugin, Registry, Settings, StringContent, build_icon, translate from openlp.core.lib.db import Manager from openlp.core.lib.ui import create_action from openlp.core.utils.actions import ActionList @@ -123,10 +123,8 @@ class SongUsagePlugin(Plugin): def initialise(self): log.info(u'SongUsage Initialising') Plugin.initialise(self) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'slidecontroller_live_started'), - self.displaySongUsage) - QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'print_service_started'), - self.printSongUsage) + Registry().register_function(u'slidecontroller_live_started', self.displaySongUsage) + Registry().register_function(u'print_service_started', self.printSongUsage) self.songUsageActive = Settings().value(self.settingsSection + u'/active') # Set the button and checkbox state self.setButtonState() From 306352643042c055beaefaf137e742c18d7efa26 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 7 Feb 2013 10:16:08 +0000 Subject: [PATCH 08/16] Fix problems with start up thread --- openlp/core/lib/settings.py | 3 ++- openlp/core/ui/mainwindow.py | 21 +++++++++++++++++---- openlp/core/utils/__init__.py | 4 +++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 78e8004c4..fc20be4c0 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -228,7 +228,8 @@ class Settings(QtCore.QSettings): u'user interface/main window splitter geometry': QtCore.QByteArray(), u'user interface/main window state': QtCore.QByteArray(), u'user interface/preview panel': True, - u'user interface/preview splitter geometry': QtCore.QByteArray() + u'user interface/preview splitter geometry': QtCore.QByteArray(), + u'servicemanager/last directory': u'' } __file_path__ = u'' __obsolete_settings__ = [ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 976c177ef..902078ecc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -484,6 +484,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.formattingTagForm = FormattingTagForm(self) self.shortcutForm = ShortcutListForm(self) self.recentFiles = [] + self.timer_id = 0 + self.timer_version_id = 0 # Set up the path with plugins plugin_path = AppLocation.get_directory(AppLocation.PluginsDir) self.plugin_manager = PluginManager(plugin_path) @@ -592,13 +594,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def version_notice(self, version): """ Notifies the user that a newer version of OpenLP is available. - Triggered by delay thread. + Triggered by delay thread and cannot display popup. """ + log.debug(u'version_notice') version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are ' 'currently running version %s). \n\nYou can download the latest version from http://openlp.org/.') - QtGui.QMessageBox.question(self, - translate('OpenLP.MainWindow', 'OpenLP Version Updated'), - version_text % (version, get_application_version()[u'full'])) + self.version_text = version_text % (version, get_application_version()[u'full']) def show(self): """ @@ -618,6 +619,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.serviceManagerContents.load_file(filename) elif Settings().value(self.generalSettingsSection + u'/auto open'): self.serviceManagerContents.load_Last_file() + self.timer_version_id = self.startTimer(1000) view_mode = Settings().value(u'%s/view mode' % self.generalSettingsSection) if view_mode == u'default': self.modeDefaultItem.setChecked(True) @@ -1340,6 +1342,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.timer_id = 0 self.loadProgressBar.hide() self.application.process_events() + if event.timerId() == self.timer_version_id: + self.timer_version_id = 0 + # Has the thread passed some data to be displayed so display it and stop all waiting + if hasattr(self, u'version_text'): + QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'), + self.version_text) + else: + # the thread has not confirmed it is running or it has not yet sent any data so lets keep waiting + if not hasattr(self,u'version_update_running') or self.version_update_running: + self.timer_version_id = self.startTimer(1000) + self.application.process_events() def set_new_data_path(self, new_data_path): """ diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9d5c09e65..104567039 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -72,12 +72,12 @@ class VersionThread(QtCore.QThread): Run the thread. """ self.sleep(1) + log.debug(u'Version thread - run') app_version = get_application_version() version = check_latest_version(app_version) if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])): Registry().execute(u'openlp_version_check', u'%s' % version) - class AppLocation(object): """ The :class:`AppLocation` class is a static class which retrieves a @@ -288,6 +288,8 @@ def check_latest_version(current_version): this_test = datetime.now().date() settings.setValue(u'last version test', this_test) settings.endGroup() + # Tell the main window whether there will ever be data to display + Registry().get(u'main_window').version_update_running = last_test != this_test if last_test != this_test: if current_version[u'build']: req = urllib2.Request(u'http://www.openlp.org/files/nightly_version.txt') From cae39247d9b721ff36b9611375927883ed5c2f77 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 7 Feb 2013 11:33:47 +0000 Subject: [PATCH 09/16] Final cleanup of variables --- openlp/core/ui/firsttimeform.py | 6 +- openlp/core/ui/maindisplay.py | 24 ++++---- openlp/core/ui/slidecontroller.py | 56 +++++++++---------- openlp/core/ui/themestab.py | 4 +- openlp/plugins/bibles/lib/mediaitem.py | 10 ++-- openlp/plugins/custom/forms/editcustomform.py | 4 +- openlp/plugins/images/lib/mediaitem.py | 4 +- openlp/plugins/media/lib/mediaitem.py | 8 +-- openlp/plugins/presentations/lib/mediaitem.py | 10 ++-- .../presentations/presentationplugin.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 4 +- openlp/plugins/songs/lib/cclifileimport.py | 2 +- openlp/plugins/songs/lib/dreambeamimport.py | 2 +- openlp/plugins/songs/lib/easyslidesimport.py | 2 +- openlp/plugins/songs/lib/ewimport.py | 4 +- .../plugins/songs/lib/foilpresenterimport.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 14 ++--- openlp/plugins/songs/lib/mediashoutimport.py | 2 +- openlp/plugins/songs/lib/olp1import.py | 10 ++-- openlp/plugins/songs/lib/olpimport.py | 2 +- openlp/plugins/songs/lib/oooimport.py | 4 +- openlp/plugins/songs/lib/openlyricsimport.py | 2 +- openlp/plugins/songs/lib/opensongimport.py | 2 +- openlp/plugins/songs/lib/powersongimport.py | 2 +- openlp/plugins/songs/lib/sofimport.py | 2 +- openlp/plugins/songs/lib/songbeamerimport.py | 2 +- openlp/plugins/songs/lib/songimport.py | 8 +-- openlp/plugins/songs/lib/songproimport.py | 2 +- .../plugins/songs/lib/songshowplusimport.py | 2 +- openlp/plugins/songs/lib/sundayplusimport.py | 2 +- openlp/plugins/songs/lib/wowimport.py | 2 +- openlp/plugins/songs/lib/zionworximport.py | 2 +- openlp/plugins/songusage/songusageplugin.py | 8 +-- 33 files changed, 106 insertions(+), 106 deletions(-) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index faa2278e3..8d7eee496 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -95,7 +95,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): if self.webAccess: files = self.webAccess.read() self.config.readfp(io.BytesIO(files)) - self.updateScreenListCombo() + self.update_screen_list_combo() self.was_download_cancelled = False self.downloading = translate('OpenLP.FirstTimeWizard', 'Downloading %s...') QtCore.QObject.connect(self.cancelButton, QtCore.SIGNAL('clicked()'), @@ -103,7 +103,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): QtCore.QObject.connect(self.noInternetFinishButton, QtCore.SIGNAL('clicked()'), self.onNoInternetFinishButtonClicked) QtCore.QObject.connect(self, QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) - Registry().register_function(u'config_screen_changed', self.updateScreenListCombo) + Registry().register_function(u'config_screen_changed', self.update_screen_list_combo) def exec_(self): """ @@ -227,7 +227,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): self._postWizard() self.application.set_normal_cursor() - def updateScreenListCombo(self): + def update_screen_list_combo(self): """ The user changed screen resolution or enabled/disabled more screens, so we need to update the combo box. diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e376efe9a..661516e7d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -158,10 +158,10 @@ class MainDisplay(Display): self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setTransparency(False) if self.isLive: - Registry().register_function(u'live_display_hide', self.hideDisplay) - Registry().register_function(u'live_display_show', self.showDisplay) - Registry().register_function(u'update_display_css', self.cssChanged) - Registry().register_function(u'config_updated', self.configChanged) + Registry().register_function(u'live_display_hide', self.hide_display) + Registry().register_function(u'live_display_show', self.show_display) + Registry().register_function(u'update_display_css', self.css_changed) + Registry().register_function(u'config_updated', self.config_changed) def setTransparency(self, enabled): """ @@ -174,13 +174,13 @@ class MainDisplay(Display): self.setAttribute(QtCore.Qt.WA_TranslucentBackground, enabled) self.repaint() - def cssChanged(self): + def css_changed(self): """ We may need to rebuild the CSS on the live display. """ self.rebuildCSS = True - def configChanged(self): + def config_changed(self): """ Call the plugins to rebuild the Live display CSS as the screen has not been rebuild on exit of config. @@ -362,7 +362,7 @@ class MainDisplay(Display): # if was hidden keep it hidden if self.isLive: if self.hideMode: - self.hideDisplay(self.hideMode) + self.hide_display(self.hideMode) else: # Single screen active if self.screens.display_count == 1: @@ -419,7 +419,7 @@ class MainDisplay(Display): if Settings().value(u'general/auto unblank'): Registry().execute(u'slidecontroller_live_unblank') else: - self.hideDisplay(self.hideMode) + self.hide_display(self.hideMode) self.__hideMouse() def footer(self, text): @@ -430,12 +430,12 @@ class MainDisplay(Display): js = u'show_footer(\'' + text.replace(u'\\', u'\\\\').replace(u'\'', u'\\\'') + u'\')' self.frame.evaluateJavaScript(js) - def hideDisplay(self, mode=HideMode.Screen): + def hide_display(self, mode=HideMode.Screen): """ Hide the display by making all layers transparent Store the images so they can be replaced when required """ - log.debug(u'hideDisplay mode = %d', mode) + log.debug(u'hide_display mode = %d', mode) if self.screens.display_count == 1: # Only make visible if setting enabled. if not Settings().value(u'general/display on monitor'): @@ -453,13 +453,13 @@ class MainDisplay(Display): self.webView.setVisible(True) self.hideMode = mode - def showDisplay(self): + def show_display(self): """ Show the stored layers so the screen reappears as it was originally. Make the stored images None to release memory. """ - log.debug(u'showDisplay') + log.debug(u'show_display') if self.screens.display_count == 1: # Only make visible if setting enabled. if not Settings().value(u'general/display on monitor'): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index c5ae4cdce..e3c42a2f9 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -107,7 +107,7 @@ class SlideController(DisplayController): self.selectedRow = 0 self.serviceItem = None self.slide_limits = None - self.updateSlideLimits() + self.update_slide_limits() self.panel = QtGui.QWidget(parent.controlSplitter) self.slideList = {} # Layout for holding panel @@ -169,13 +169,13 @@ class SlideController(DisplayController): text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=self.category, triggers=self.onSlideSelectedPrevious) + category=self.category, triggers=self.on_slide_selected_previous) self.toolbar.addAction(self.previousItem) self.nextItem = create_action(self, u'nextItem_' + self.typePrefix, text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut, - category=self.category, triggers=self.onSlideSelectedNextAction) + category=self.category, triggers=self.on_slide_selected_next_action) self.toolbar.addAction(self.nextItem) self.toolbar.addSeparator() self.controllerType = DisplayControllerType.Preview @@ -362,8 +362,8 @@ class SlideController(DisplayController): # Signals QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected) if self.isLive: - Registry().register_function(u'slidecontroller_live_spin_delay', self.receiveSpinDelay) - Registry().register_function(u'slidecontroller_toggle_display', self.toggleDisplay) + Registry().register_function(u'slidecontroller_live_spin_delay', self.receive_spin_delay) + Registry().register_function(u'slidecontroller_toggle_display', self.toggle_display) self.toolbar.setWidgetVisible(self.loopList, False) self.toolbar.setWidgetVisible(self.wideMenu, False) else: @@ -375,14 +375,14 @@ class SlideController(DisplayController): self.__addActionsToWidget(self.previewListWidget) else: self.previewListWidget.addActions([self.nextItem, self.previousItem]) - Registry().register_function(u'slidecontroller_%s_stop_loop' % self.typePrefix, self.onStopLoop) - Registry().register_function(u'slidecontroller_%s_next' % self.typePrefix, self.onSlideSelectedNext) - Registry().register_function(u'slidecontroller_%s_previous' % self.typePrefix, self.onSlideSelectedPrevious) - Registry().register_function(u'slidecontroller_%s_change' % self.typePrefix, self.onSlideChange) - Registry().register_function(u'slidecontroller_%s_set' % self.typePrefix, self.onSlideSelectedIndex) - Registry().register_function(u'slidecontroller_%s_blank' % self.typePrefix, self.onSlideBlank) - Registry().register_function(u'slidecontroller_%s_unblank' % self.typePrefix, self.onSlideUnblank) - Registry().register_function(u'slidecontroller_update_slide_limits', self.updateSlideLimits) + Registry().register_function(u'slidecontroller_%s_stop_loop' % self.typePrefix, self.on_stop_loop) + Registry().register_function(u'slidecontroller_%s_next' % self.typePrefix, self.on_slide_selected_next) + Registry().register_function(u'slidecontroller_%s_previous' % self.typePrefix, self.on_slide_selected_previous) + Registry().register_function(u'slidecontroller_%s_change' % self.typePrefix, self.on_slide_change) + Registry().register_function(u'slidecontroller_%s_set' % self.typePrefix, self.on_slide_selected_index) + Registry().register_function(u'slidecontroller_%s_blank' % self.typePrefix, self.on_slide_blank) + Registry().register_function(u'slidecontroller_%s_unblank' % self.typePrefix, self.on_slide_unblank) + Registry().register_function(u'slidecontroller_update_slide_limits', self.update_slide_limits) def _slideShortcutActivated(self): """ @@ -469,7 +469,7 @@ class SlideController(DisplayController): self.display.setVisible(False) self.media_controller.media_stop(self) - def toggleDisplay(self, action): + def toggle_display(self, action): """ Toggle the display settings triggered from remote messages. """ @@ -608,13 +608,13 @@ class SlideController(DisplayController): self.__updatePreviewSelection(slide_no) self.slideSelected() - def receiveSpinDelay(self, value): + def receive_spin_delay(self, value): """ Adjusts the value of the ``delaySpinBox`` to the given one. """ self.delaySpinBox.setValue(int(value)) - def updateSlideLimits(self): + def update_slide_limits(self): """ Updates the Slide Limits variable from the settings. """ @@ -740,7 +740,7 @@ class SlideController(DisplayController): Display the slide number passed """ log.debug(u'processManagerItem live = %s' % self.isLive) - self.onStopLoop() + self.on_stop_loop() old_item = self.serviceItem # take a copy not a link to the servicemanager copy. self.serviceItem = copy.copy(serviceItem) @@ -858,7 +858,7 @@ class SlideController(DisplayController): self.__checkUpdateSelectedSlide(slideno) # Screen event methods - def onSlideSelectedIndex(self, message): + def on_slide_selected_index(self, message): """ Go to the requested slide """ @@ -891,13 +891,13 @@ class SlideController(DisplayController): else: self.liveEscape() - def onSlideBlank(self): + def on_slide_blank(self): """ Handle the slidecontroller blank event """ self.onBlankDisplay(True) - def onSlideUnblank(self): + def on_slide_unblank(self): """ Handle the slidecontroller unblank event """ @@ -1036,7 +1036,7 @@ class SlideController(DisplayController): Registry().execute(u'slidecontroller_%s_changed' % self.typePrefix, row) self.display.setFocus() - def onSlideChange(self, row): + def on_slide_change(self, row): """ The slide has been changed. Update the slidecontroller accordingly """ @@ -1068,14 +1068,14 @@ class SlideController(DisplayController): winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height()) self.slidePreview.setPixmap(winimg) - def onSlideSelectedNextAction(self, checked): + def on_slide_selected_next_action(self, checked): """ Wrapper function from create_action so we can throw away the incorrect parameter """ - self.onSlideSelectedNext() + self.on_slide_selected_next() - def onSlideSelectedNext(self, wrap=None): + def on_slide_selected_next(self, wrap=None): """ Go to the next slide. """ @@ -1102,7 +1102,7 @@ class SlideController(DisplayController): self.__checkUpdateSelectedSlide(row) self.slideSelected() - def onSlideSelectedPrevious(self): + def on_slide_selected_previous(self): """ Go to the previous slide. """ @@ -1141,7 +1141,7 @@ class SlideController(DisplayController): if hide_mode is None and (self.playSlidesLoop.isChecked() or self.playSlidesOnce.isChecked()): self.onStartLoop() else: - self.onStopLoop() + self.on_stop_loop() def onStartLoop(self): """ @@ -1150,7 +1150,7 @@ class SlideController(DisplayController): if self.previewListWidget.rowCount() > 1: self.timer_id = self.startTimer(int(self.delaySpinBox.value()) * 1000) - def onStopLoop(self): + def on_stop_loop(self): """ Stop the timer loop running """ @@ -1222,7 +1222,7 @@ class SlideController(DisplayController): If the timer event is for this window select next slide """ if event.timerId() == self.timer_id: - self.onSlideSelectedNext(self.playSlidesLoop.isChecked()) + self.on_slide_selected_next(self.playSlidesLoop.isChecked()) def onEditSong(self): """ diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index f78aefd29..1442ff4e9 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -104,7 +104,7 @@ class ThemesTab(SettingsTab): QtCore.QObject.connect(self.GlobalLevelRadioButton, QtCore.SIGNAL(u'clicked()'), self.onGlobalLevelButtonClicked) QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) - Registry().register_function(u'theme_update_list', self.updateThemeList) + Registry().register_function(u'theme_update_list', self.update_theme_list) def retranslateUi(self): """ @@ -187,7 +187,7 @@ class ThemesTab(SettingsTab): self.renderer.set_global_theme(self.global_theme) self.__previewGlobalTheme() - def updateThemeList(self, theme_list): + def update_theme_list(self, theme_list): """ Called from ThemeManager when the Themes have changed. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 8375e3fc3..52e786617 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -70,7 +70,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results = {} self.second_search_results = {} self.checkSearchResult() - Registry().register_function(u'bibles_load_list', self.reloadBibles) + Registry().register_function(u'bibles_load_list', self.reload_bibles) Registry().register_function(u'config_updated', self.config_update) def __checkSecondBible(self, bible, second_bible): @@ -343,7 +343,7 @@ class BibleMediaItem(MediaManagerItem): bible = Settings().value(self.settingsSection + u'/quick bible') find_and_set_in_combo_box(self.quickVersionComboBox, bible) - def reloadBibles(self, process=False): + def reload_bibles(self, process=False): log.debug(u'Reloading Bibles') self.plugin.manager.reload_bibles() self.loadBibles() @@ -471,7 +471,7 @@ class BibleMediaItem(MediaManagerItem): self.import_wizard = BibleImportForm(self, self.plugin.manager, self.plugin) # If the import was not cancelled then reload. if self.import_wizard.exec_(): - self.reloadBibles() + self.reload_bibles() def onEditClick(self): if self.quickTab.isVisible(): @@ -482,7 +482,7 @@ class BibleMediaItem(MediaManagerItem): self.editBibleForm = EditBibleForm(self, self.main_window, self.plugin.manager) self.editBibleForm.loadBible(bible) if self.editBibleForm.exec_(): - self.reloadBibles() + self.reload_bibles() def onDeleteClick(self): if self.quickTab.isVisible(): @@ -497,7 +497,7 @@ class BibleMediaItem(MediaManagerItem): QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return self.plugin.manager.delete_bible(bible) - self.reloadBibles() + self.reload_bibles() def onSearchTabBarCurrentChanged(self, index): if index == 0: diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a306ed174..cea17da5f 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -64,9 +64,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.editAllButton.clicked.connect(self.on_edit_all_button_clicked) self.slideListView.currentRowChanged.connect(self.on_current_row_changed) self.slideListView.doubleClicked.connect(self.on_edit_button_clicked) - Registry().register_function(u'theme_update_list', self.loadThemes) + Registry().register_function(u'theme_update_list', self.load_themes) - def loadThemes(self, theme_list): + def load_themes(self, theme_list): """ Load a list of themes into the themes combo box. diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 1a23ff9e4..2280120c1 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -51,7 +51,7 @@ class ImageMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, plugin, icon) self.quickPreviewAllowed = True self.hasSearch = True - Registry().register_function(u'live_theme_changed', self.liveThemeChanged) + Registry().register_function(u'live_theme_changed', self.live_theme_changed) # Allow DnD from the desktop self.listView.activateDnD() @@ -194,7 +194,7 @@ class ImageMediaItem(MediaManagerItem): self.resetAction.setVisible(False) self.live_controller.display.resetImage() - def liveThemeChanged(self): + def live_theme_changed(self): """ Triggered by the change of theme in the slide controller """ diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 3f0821f53..1f4ee8fc0 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -71,9 +71,9 @@ class MediaMediaItem(MediaManagerItem): self.displayController.previewDisplay.screen = {u'size':self.displayController.previewDisplay.geometry()} self.displayController.previewDisplay.setup() self.media_controller.setup_display(self.displayController.previewDisplay, False) - Registry().register_function(u'video_background_replaced', self.videobackgroundReplaced) + Registry().register_function(u'video_background_replaced', self.video_background_replaced) Registry().register_function(u'mediaitem_media_rebuild', self.rebuild_players) - Registry().register_function(u'config_screen_changed', self.displaySetup) + Registry().register_function(u'config_screen_changed', self.display_setup) # Allow DnD from the desktop self.listView.activateDnD() @@ -132,7 +132,7 @@ class MediaMediaItem(MediaManagerItem): self.media_controller.media_reset(self.live_controller) self.resetAction.setVisible(False) - def videobackgroundReplaced(self): + def video_background_replaced(self): """ Triggered by main display on change of serviceitem. """ @@ -213,7 +213,7 @@ class MediaMediaItem(MediaManagerItem): u' '.join(self.media_controller.video_extensions_list), u' '.join(self.media_controller.audio_extensions_list), UiStrings().AllFiles) - def displaySetup(self): + def display_setup(self): self.media_controller.setup_display(self.displayController.previewDisplay, False) def populateDisplayTypes(self): diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 67d040aae..3bda33cb0 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -60,8 +60,8 @@ class PresentationMediaItem(MediaManagerItem): self.message_listener = MessageListener(self) self.hasSearch = True self.singleServiceItem = False - Registry().register_function(u'mediaitem_presentation_rebuild', self.populateDisplayTypes) - Registry().register_function(u'mediaitem_suffixes', self.buildFileMaskString) + Registry().register_function(u'mediaitem_presentation_rebuild', self.populate_display_types) + Registry().register_function(u'mediaitem_suffixes', self.build_file_mask_string) # Allow DnD from the desktop self.listView.activateDnD() @@ -73,7 +73,7 @@ class PresentationMediaItem(MediaManagerItem): self.Automatic = translate('PresentationPlugin.MediaItem', 'Automatic') self.displayTypeLabel.setText(translate('PresentationPlugin.MediaItem', 'Present using:')) - def buildFileMaskString(self): + def build_file_mask_string(self): """ Build the list of file extensions to be used in the Open file dialog """ @@ -121,9 +121,9 @@ class PresentationMediaItem(MediaManagerItem): self.listView.setIconSize(QtCore.QSize(88, 50)) files = Settings().value(self.settingsSection + u'/presentations files') self.loadList(files, True) - self.populateDisplayTypes() + self.populate_display_types() - def populateDisplayTypes(self): + def populate_display_types(self): """ Load the combobox with the enabled presentation controllers, allowing user to select a specific app if settings allow diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 2e6041084..fb4e9f446 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -90,7 +90,7 @@ class PresentationPlugin(Plugin): except Exception: log.warn(u'Failed to start controller process') self.controllers[controller].available = False - self.mediaItem.buildFileMaskString() + self.mediaItem.build_file_mask_string() def finalise(self): """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 4b8d46ccd..e5421990f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -97,7 +97,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.audioRemoveButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveButtonClicked) QtCore.QObject.connect(self.audioRemoveAllButton, QtCore.SIGNAL(u'clicked()'), self.onAudioRemoveAllButtonClicked) - Registry().register_function(u'theme_update_list', self.loadThemes) + Registry().register_function(u'theme_update_list', self.load_themes) self.previewButton = QtGui.QPushButton() self.previewButton.setObjectName(u'previewButton') self.previewButton.setText(UiStrings().SaveAndPreview) @@ -169,7 +169,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): combo.setItemData(row, object.id) set_case_insensitive_completer(cache, combo) - def loadThemes(self, theme_list): + def load_themes(self, theme_list): """ Load the themes into a combobox. """ diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 2ba80ec3c..d4ad0493a 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -95,7 +95,7 @@ class CCLIFileImport(SongImport): self.logError(filename, translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid extension.')) log.info(u'Extension %s is not valid', filename) - if self.stopImportFlag: + if self.stop_import_flag: return def doImportUsrFile(self, textList): diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 4f8d343c4..310d8f4de 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -90,7 +90,7 @@ class DreamBeamImport(SongImport): if isinstance(self.importSource, list): self.importWizard.progressBar.setMaximum(len(self.importSource)) for file in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return self.setDefaults() parser = etree.XMLParser(remove_blank_text=True) diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index 7f9143b70..36ffbeb63 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -58,7 +58,7 @@ class EasySlidesImport(SongImport): song_xml = objectify.fromstring(xml) self.importWizard.progressBar.setMaximum(len(song_xml.Item)) for song in song_xml.Item: - if self.stopImportFlag: + if self.stop_import_flag: return self._parseSong(song) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 86fba0562..8a344c189 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -142,7 +142,7 @@ class EasyWorshipSongImport(SongImport): rec_count = (rec_count + record_size) / record_size # Loop through each record within the current block for i in range(rec_count): - if self.stopImportFlag: + if self.stop_import_flag: break raw_record = db_file.read(record_size) self.fields = self.recordStruct.unpack(raw_record) @@ -216,7 +216,7 @@ class EasyWorshipSongImport(SongImport): if len(self.comments) > 5: self.comments += unicode(translate('SongsPlugin.EasyWorshipSongImport', '\n[above are Song Tags with notes imported from EasyWorship]')) - if self.stopImportFlag: + if self.stop_import_flag: break if not self.finish(): self.logError(self.importSource) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 3a3d29359..d6c232b54 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -124,7 +124,7 @@ class FoilPresenterImport(SongImport): self.importWizard.progressBar.setMaximum(len(self.importSource)) parser = etree.XMLParser(remove_blank_text=True) for file_path in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return self.importWizard.incrementProgressBar( WizardStrings.ImportingType % os.path.basename(file_path)) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b273cf3b8..52c04625f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -100,7 +100,7 @@ class SongMediaItem(MediaManagerItem): triggers=self.onSongMaintenanceClick) self.addSearchToToolBar() # Signals and slots - Registry().register_function(u'songs_load_list', self.onSongListLoad) + Registry().register_function(u'songs_load_list', self.on_song_list_load) Registry().register_function(u'config_updated', self.config_update) Registry().register_function(u'songs_preview', self.onPreviewClick) QtCore.QObject.connect(self.searchTextEdit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick) @@ -199,12 +199,12 @@ class SongMediaItem(MediaManagerItem): Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'), Song.comments.like(u'%' + search_keywords.lower() + u'%'))) - def onSongListLoad(self): + def on_song_list_load(self): """ Handle the exit from the edit dialog and trigger remote updates of songs """ - log.debug(u'onSongListLoad - start') + log.debug(u'on_song_list_load - start') # Called to redisplay the song list screen edit from a search # or from the exit of the Song edit dialog. If remote editing is active # Trigger it and clean up so it will not update again. @@ -213,7 +213,7 @@ class SongMediaItem(MediaManagerItem): item = self.buildServiceItem(self.editItem) self.service_manager.replace_service_item(item) self.onSearchTextButtonClicked() - log.debug(u'onSongListLoad - finished') + log.debug(u'on_song_list_load - finished') def displayResultsSong(self, searchresults): log.debug(u'display results Song') @@ -325,7 +325,7 @@ class SongMediaItem(MediaManagerItem): self.editSongForm.loadSong(song_id, preview) if self.editSongForm.exec_() == QtGui.QDialog.Accepted: self.autoSelectId = -1 - self.onSongListLoad() + self.on_song_list_load() self.remoteSong = song_id self.remoteTriggered = True item = self.buildServiceItem(remote=True) @@ -346,7 +346,7 @@ class SongMediaItem(MediaManagerItem): self.editSongForm.loadSong(item_id, False) self.editSongForm.exec_() self.autoSelectId = -1 - self.onSongListLoad() + self.on_song_list_load() self.editItem = None def onDeleteClick(self): @@ -398,7 +398,7 @@ class SongMediaItem(MediaManagerItem): new_song.title = u'%s <%s>' % (new_song.title, translate('SongsPlugin.MediaItem', 'copy', 'For song cloning')) self.plugin.manager.save_object(new_song) - self.onSongListLoad() + self.on_song_list_load() def generateSlideData(self, service_item, item=None, xmlVersion=False, remote=False, context=ServiceItemContext.Service): diff --git a/openlp/plugins/songs/lib/mediashoutimport.py b/openlp/plugins/songs/lib/mediashoutimport.py index e3358c044..ad88af479 100644 --- a/openlp/plugins/songs/lib/mediashoutimport.py +++ b/openlp/plugins/songs/lib/mediashoutimport.py @@ -66,7 +66,7 @@ class MediaShoutImport(SongImport): songs = cursor.fetchall() self.importWizard.progressBar.setMaximum(len(songs)) for song in songs: - if self.stopImportFlag: + if self.stop_import_flag: break cursor.execute(u'SELECT Type, Number, Text FROM Verses ' u'WHERE Record = %s ORDER BY Type, Number' % song.Record) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index 75a9e60bd..dd45c266f 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -110,7 +110,7 @@ class OpenLP1SongImport(SongImport): self.importWizard.progressBar.setMaximum(len(songs)) for song in songs: self.setDefaults() - if self.stopImportFlag: + if self.stop_import_flag: break song_id = song[0] self.title = song[1] @@ -131,13 +131,13 @@ class OpenLP1SongImport(SongImport): u'WHERE songid = %s' % song_id) author_ids = cursor.fetchall() for author_id in author_ids: - if self.stopImportFlag: + if self.stop_import_flag: break for author in authors: if author[0] == author_id[0]: self.parseAuthor(author[1]) break - if self.stopImportFlag: + if self.stop_import_flag: break if db_has_tracks: cursor.execute(u'-- types int, int') @@ -146,14 +146,14 @@ class OpenLP1SongImport(SongImport): u'WHERE songid = %s ORDER BY listindex' % song_id) track_ids = cursor.fetchall() for track_id, listindex in track_ids: - if self.stopImportFlag: + if self.stop_import_flag: break for track in tracks: if track[0] == track_id: media_file = self.expandMediaFile(track[1]) self.addMediaFile(media_file, listindex) break - if self.stopImportFlag: + if self.stop_import_flag: break if not self.finish(): self.logError(self.importSource) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 7d502d88f..0bcc5461f 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -225,6 +225,6 @@ class OpenLPSongImport(SongImport): progressDialog.setLabelText(WizardStrings.ImportingType % new_song.title) else: self.importWizard.incrementProgressBar(WizardStrings.ImportingType % new_song.title) - if self.stopImportFlag: + if self.stop_import_flag: break engine.dispose() diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 90d592bd5..65505ceb1 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -77,7 +77,7 @@ class OooImport(SongImport): return self.importWizard.progressBar.setMaximum(len(self.importSource)) for filename in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: break filename = unicode(filename) if os.path.isfile(filename): @@ -189,7 +189,7 @@ class OooImport(SongImport): slides = doc.getDrawPages() text = u'' for slide_no in range(slides.getCount()): - if self.stopImportFlag: + if self.stop_import_flag: self.importWizard.incrementProgressBar(u'Import cancelled', 0) return slide = slides.getByIndex(slide_no) diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/openlyricsimport.py index f5b1cdee8..199cb48ce 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/openlyricsimport.py @@ -63,7 +63,7 @@ class OpenLyricsImport(SongImport): self.importWizard.progressBar.setMaximum(len(self.importSource)) parser = etree.XMLParser(remove_blank_text=True) for file_path in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return self.importWizard.incrementProgressBar(WizardStrings.ImportingType % os.path.basename(file_path)) try: diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index f21f2e70f..9eda898ae 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -113,7 +113,7 @@ class OpenSongImport(SongImport): def doImport(self): self.importWizard.progressBar.setMaximum(len(self.importSource)) for filename in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return song_file = open(filename) self.doImportFile(song_file) diff --git a/openlp/plugins/songs/lib/powersongimport.py b/openlp/plugins/songs/lib/powersongimport.py index abb261e91..fa75b738f 100644 --- a/openlp/plugins/songs/lib/powersongimport.py +++ b/openlp/plugins/songs/lib/powersongimport.py @@ -106,7 +106,7 @@ class PowerSongImport(SongImport): return self.importWizard.progressBar.setMaximum(len(self.importSource)) for file in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return self.setDefaults() parse_error = False diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 43f20cf32..e9e4f17a8 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -100,7 +100,7 @@ class SofImport(OooImport): try: paragraphs = self.document.getText().createEnumeration() while paragraphs.hasMoreElements(): - if self.stopImportFlag: + if self.stop_import_flag: return paragraph = paragraphs.nextElement() if paragraph.supportsService("com.sun.star.text.Paragraph"): diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 1d9d047ae..534b1d121 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -109,7 +109,7 @@ class SongBeamerImport(SongImport): return for file in self.importSource: # TODO: check that it is a valid SongBeamer file - if self.stopImportFlag: + if self.stop_import_flag: return self.setDefaults() self.currentVerse = u'' diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 735c7c477..f6a84945c 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -81,9 +81,9 @@ class SongImport(QtCore.QObject): log.debug(self.importSource) self.importWizard = None self.song = None - self.stopImportFlag = False + self.stop_import_flag = False self.setDefaults() - Registry().register_function(u'openlp_stop_wizard', self.stopImport) + Registry().register_function(u'openlp_stop_wizard', self.stop_import) def setDefaults(self): """ @@ -133,12 +133,12 @@ class SongImport(QtCore.QObject): self.importWizard.errorSaveToButton.setVisible(True) self.importWizard.errorReportTextEdit.append(u'- %s (%s)' % (filepath, reason)) - def stopImport(self): + def stop_import(self): """ Sets the flag for importers to stop their import """ log.debug(u'Stopping songs import') - self.stopImportFlag = True + self.stop_import_flag = True def register(self, import_wizard): self.importWizard = import_wizard diff --git a/openlp/plugins/songs/lib/songproimport.py b/openlp/plugins/songs/lib/songproimport.py index 0e6b5ee97..aaf55b41d 100644 --- a/openlp/plugins/songs/lib/songproimport.py +++ b/openlp/plugins/songs/lib/songproimport.py @@ -83,7 +83,7 @@ class SongProImport(SongImport): tag = u'' text = u'' for file_line in songs_file: - if self.stopImportFlag: + if self.stop_import_flag: break file_line = unicode(file_line, u'cp1252') file_text = file_line.rstrip() diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 8677c82c2..c5bb8832d 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -105,7 +105,7 @@ class SongShowPlusImport(SongImport): return self.importWizard.progressBar.setMaximum(len(self.importSource)) for file in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return self.sspVerseOrderList = [] other_count = 0 diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index 5ac69e991..f773183b3 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -66,7 +66,7 @@ class SundayPlusImport(SongImport): def doImport(self): self.importWizard.progressBar.setMaximum(len(self.importSource)) for filename in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return song_file = open(filename) self.doImportFile(song_file) diff --git a/openlp/plugins/songs/lib/wowimport.py b/openlp/plugins/songs/lib/wowimport.py index aa327c0a0..b278d43c1 100644 --- a/openlp/plugins/songs/lib/wowimport.py +++ b/openlp/plugins/songs/lib/wowimport.py @@ -108,7 +108,7 @@ class WowImport(SongImport): if isinstance(self.importSource, list): self.importWizard.progressBar.setMaximum(len(self.importSource)) for source in self.importSource: - if self.stopImportFlag: + if self.stop_import_flag: return self.setDefaults() song_data = open(source, 'rb') diff --git a/openlp/plugins/songs/lib/zionworximport.py b/openlp/plugins/songs/lib/zionworximport.py index c7a63149d..ed9b69e53 100644 --- a/openlp/plugins/songs/lib/zionworximport.py +++ b/openlp/plugins/songs/lib/zionworximport.py @@ -96,7 +96,7 @@ class ZionWorxImport(SongImport): log.info(u'%s records found in CSV file' % num_records) self.importWizard.progressBar.setMaximum(num_records) for index, record in enumerate(records, 1): - if self.stopImportFlag: + if self.stop_import_flag: return self.setDefaults() try: diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index a9b05b1f4..b91468531 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -123,8 +123,8 @@ class SongUsagePlugin(Plugin): def initialise(self): log.info(u'SongUsage Initialising') Plugin.initialise(self) - Registry().register_function(u'slidecontroller_live_started', self.displaySongUsage) - Registry().register_function(u'print_service_started', self.printSongUsage) + Registry().register_function(u'slidecontroller_live_started', self.display_song_usage) + Registry().register_function(u'print_service_started', self.print_song_usage) self.songUsageActive = Settings().value(self.settingsSection + u'/active') # Set the button and checkbox state self.setButtonState() @@ -183,13 +183,13 @@ class SongUsagePlugin(Plugin): self.songUsageStatus.blockSignals(False) - def displaySongUsage(self, item): + def display_song_usage(self, item): """ Song Usage for which has been displayed """ self._add_song_usage(translate('SongUsagePlugin', 'display'), item) - def printSongUsage(self, item): + def print_song_usage(self, item): """ Song Usage for which has been printed """ From 536bee40d46330b6858047fee4db49a94da0b45c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 9 Feb 2013 17:07:33 +0000 Subject: [PATCH 10/16] Test fixes --- tests/functional/openlp_core_lib/test_registry.py | 2 +- tests/interfaces/openlp_core_ui/test_servicenotedialog.py | 8 ++++---- tests/interfaces/openlp_core_ui/test_starttimedialog.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_registry.py b/tests/functional/openlp_core_lib/test_registry.py index 826aafc9b..a2fe60627 100644 --- a/tests/functional/openlp_core_lib/test_registry.py +++ b/tests/functional/openlp_core_lib/test_registry.py @@ -16,7 +16,7 @@ class TestRegistry(TestCase): Test the registry creation and its usage """ # GIVEN: A new registry - registry = Registry.create() + Registry.create() # WHEN: I add a component it should save it mock_1 = MagicMock() diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index e444ff687..f3694fdea 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -14,7 +14,7 @@ class TestStartNoteDialog(TestCase): """ Create the UI """ - registry = Registry.create() + Registry.create() self.app = QtGui.QApplication([]) self.main_window = QtGui.QMainWindow() Registry().register(u'main_window', self.main_window) @@ -36,7 +36,7 @@ class TestStartNoteDialog(TestCase): self.form.text_edit.setPlainText(u'') # WHEN displaying the UI and pressing enter - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_'): self.form.exec_() okWidget = self.form.button_box.button(self.form.button_box.Save) QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton) @@ -47,7 +47,7 @@ class TestStartNoteDialog(TestCase): # WHEN displaying the UI, having set the text and pressing enter text = u'OpenLP is the best worship software' self.form.text_edit.setPlainText(text) - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_'): self.form.exec_() okWidget = self.form.button_box.button(self.form.button_box.Save) QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton) @@ -57,7 +57,7 @@ class TestStartNoteDialog(TestCase): # WHEN displaying the UI, having set the text and pressing enter self.form.text_edit.setPlainText(u'') - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_'): self.form.exec_() self.form.text_edit.setPlainText(text) okWidget = self.form.button_box.button(self.form.button_box.Save) diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index 990f753ba..a9b33a30c 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -14,7 +14,7 @@ class TestStartTimeDialog(TestCase): """ Create the UI """ - registry = Registry.create() + Registry.create() self.app = QtGui.QApplication([]) self.main_window = QtGui.QMainWindow() Registry().register(u'main_window', self.main_window) @@ -67,7 +67,7 @@ class TestStartTimeDialog(TestCase): # WHEN displaying the UI and pressing enter self.form.item = {u'service_item': mocked_serviceitem} - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_'): self.form.exec_() okWidget = self.form.button_box.button(self.form.button_box.Ok) QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton) @@ -80,7 +80,7 @@ class TestStartTimeDialog(TestCase): # WHEN displaying the UI, changing the time to 2min 3secs and pressing enter self.form.item = {u'service_item': mocked_serviceitem} - with patch(u'PyQt4.QtGui.QDialog') as mocked_exec: + with patch(u'PyQt4.QtGui.QDialog.exec_'): self.form.exec_() self.form.minuteSpinBox.setValue(2) self.form.secondSpinBox.setValue(3) From f9dc60898489db3ea1f6e16b2d28fe96e0a7ba7b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 9 Feb 2013 17:13:27 +0000 Subject: [PATCH 11/16] Review fixes --- openlp/core/lib/settings.py | 3 +-- openlp/core/ui/generaltab.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 31e7564de..7e72c6d4c 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -229,8 +229,7 @@ class Settings(QtCore.QSettings): u'user interface/main window splitter geometry': QtCore.QByteArray(), u'user interface/main window state': QtCore.QByteArray(), u'user interface/preview panel': True, - u'user interface/preview splitter geometry': QtCore.QByteArray(), - u'servicemanager/last directory': u'' + u'user interface/preview splitter geometry': QtCore.QByteArray() } __file_path__ = u'' __obsolete_settings__ = [ diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 83c2ee255..a20206f9b 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Registry, Settings, SettingsTab, translate, ScreenList, UiStrings +from openlp.core.lib import Registry, Settings, SettingsTab, ScreenList, UiStrings, translate log = logging.getLogger(__name__) From f92adad31dea218267ba5dc7fb833514793f2110 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 9 Feb 2013 17:23:35 +0000 Subject: [PATCH 12/16] Comment fixes --- openlp/core/lib/registry.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 082592172..d771e79d1 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -69,6 +69,9 @@ class Registry(object): def get(self, key): """ Extracts the registry value from the list based on the key passed in + + ``key`` + The service to be retrieved. """ if key in self.service_list: return self.service_list[key] @@ -79,6 +82,12 @@ class Registry(object): def register(self, key, reference): """ Registers a component against a key. + + ``key`` + The service to be created. + + ``reference`` + The service address to be saved. """ if key in self.service_list: log.error(u'Duplicate service exception %s' % key) @@ -89,7 +98,10 @@ class Registry(object): def remove(self, key): """ Removes the registry value from the list based on the key passed in - (Only valid and active for testing framework) + (Only valid and active for testing framework). + + ``key`` + The service to be deleted. """ if self.running_under_test is False: log.error(u'Invalid Method call for key %s' % key) @@ -101,6 +113,12 @@ class Registry(object): def register_function(self, event, function): """ Register a function and a handler to be called later + + ``event`` + The function description.. + + ``function`` + The function to be called when the event happens. """ if not self.functions_list.has_key(event): self.functions_list[event] = [function] @@ -110,6 +128,12 @@ class Registry(object): def remove_function(self, event, function): """ Register a function and a handler to be called later + + ``event`` + The function description.. + + ``function`` + The function to be called when the event happens. """ if self.running_under_test is False: log.error(u'Invalid Method call for key %s' % event) @@ -121,6 +145,15 @@ class Registry(object): def execute(self, event, *args, **kwargs): """ Execute all the handlers registered passing the data to the handler and returning results + + ``event`` + The function to be processed + + ``*args`` + Parameters to be passed to the function. + + ``*kwargs`` + Parameters to be passed to the function. """ results = [] if event in self.functions_list: From f669032fc9461cd910bf30bb2c1515620c5fbcf0 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 9 Feb 2013 17:30:46 +0000 Subject: [PATCH 13/16] Comment updates --- openlp/core/lib/registry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index d771e79d1..3e889890d 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -84,7 +84,7 @@ class Registry(object): Registers a component against a key. ``key`` - The service to be created. + The service to be created this is usually a major class like "renderer" or "main_window" . ``reference`` The service address to be saved. @@ -115,7 +115,9 @@ class Registry(object): Register a function and a handler to be called later ``event`` - The function description.. + The function description like "config_updated" or "live_display_hide" where a number of places in the + code will/may need to respond to a single action and the caller does not need to understand or know about + the recipients. ``function`` The function to be called when the event happens. From 064a4bad2012fa87aa1dae750067f4c848f916ec Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 10 Feb 2013 16:05:52 +0000 Subject: [PATCH 14/16] Merge fixes --- openlp/core/__init__.py | 2 +- openlp/core/lib/registry.py | 21 +++++++++------------ openlp/core/lib/screen.py | 2 +- openlp/core/lib/settings.py | 1 + openlp/core/ui/mainwindow.py | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index d25e7a284..3ad0e1348 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -150,7 +150,7 @@ class OpenLP(QtGui.QApplication): update_check = Settings().value(u'general/update check') if update_check: VersionThread(self.main_window).start() - self.main_window.blank_check() + self.main_window.is_display_blank() self.main_window.app_startup() return self.exec_() diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 3e889890d..bbc99d4d0 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -60,10 +60,10 @@ class Registry(object): registry = cls() registry.service_list = {} registry.functions_list = {} - registry.running_under_test = True + registry.running_under_test = False # Allow the tests to remove Registry entries but not the live system - if u'openlp.py' in sys.argv[0]: - registry.running_under_test = False + if u'nose' in sys.argv[0]: + registry.running_under_test = True return registry def get(self, key): @@ -106,13 +106,12 @@ class Registry(object): if self.running_under_test is False: log.error(u'Invalid Method call for key %s' % key) raise KeyError(u'Invalid Method call for key %s' % key) - return if key in self.service_list: del self.service_list[key] def register_function(self, event, function): """ - Register a function and a handler to be called later + Register an event and associated function to be called ``event`` The function description like "config_updated" or "live_display_hide" where a number of places in the @@ -122,14 +121,14 @@ class Registry(object): ``function`` The function to be called when the event happens. """ - if not self.functions_list.has_key(event): - self.functions_list[event] = [function] - else: + if event in self.functions_list: self.functions_list[event].append(function) + else: + self.functions_list[event] = [function] def remove_function(self, event, function): """ - Register a function and a handler to be called later + Remove an event and associated handler ``event`` The function description.. @@ -140,13 +139,12 @@ class Registry(object): if self.running_under_test is False: log.error(u'Invalid Method call for key %s' % event) raise KeyError(u'Invalid Method call for key %s' % event) - return if event in self.functions_list: self.functions_list[event].remove(function) def execute(self, event, *args, **kwargs): """ - Execute all the handlers registered passing the data to the handler and returning results + Execute all the handlers associated with the event and return an array of results. ``event`` The function to be processed @@ -170,4 +168,3 @@ class Registry(object): log.debug(inspect.currentframe().f_back.f_locals) log.exception(u'Exception for function %s', function) return results - diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index 65ccd9f2f..913ad539c 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -244,7 +244,7 @@ class ScreenList(object): Loads the screen size and the monitor number from the settings. """ from openlp.core.lib import Settings - # Add the screen settings to the settings dict. This has to be done here due to crycle dependency. + # Add the screen settings to the settings dict. This has to be done here due to cyclic dependency. # Do not do this anywhere else. screen_settings = { u'general/x position': self.current[u'size'].x(), diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 7e72c6d4c..56821f1d1 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -259,6 +259,7 @@ class Settings(QtCore.QSettings): """ Settings.__default_settings__ = dict(default_values.items() + Settings.__default_settings__.items()) + @staticmethod def set_filename(ini_file): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 902078ecc..e86f068a8 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -695,7 +695,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Registry().execute(u'bibles_load_list', True) self.application.set_normal_cursor() - def blank_check(self): + def is_display_blank(self): """ Check and display message if screen blank on setup. """ From fb4cad42d0ea36436d6be1267fdeac5e5c076703 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 12 Feb 2013 16:50:42 +0000 Subject: [PATCH 15/16] Review fix --- openlp/plugins/songusage/forms/songusagedeleteform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index cb26f4dbb..47e8b9256 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -33,6 +33,7 @@ from openlp.core.lib import Registry, translate from openlp.plugins.songusage.lib.db import SongUsageItem from songusagedeletedialog import Ui_SongUsageDeleteDialog + class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): """ Class documentation goes here. @@ -65,6 +66,7 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): self.accept() else: self.reject() + def _get_main_window(self): """ Adds the main window to the class dynamically From 8080fc1f8c55268eec7813e91f712a656a1d02d4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 12 Feb 2013 21:27:43 +0000 Subject: [PATCH 16/16] Remove blank line --- openlp/plugins/songs/lib/mediaitem.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 52c04625f..68820f861 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -35,7 +35,6 @@ import shutil from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ - from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, Settings, \ UiStrings, translate, check_item_selected, create_separated_list, check_directory_exists from openlp.core.lib.ui import create_widget_action