From 4b30d6cd29227419a45d36a229f7b43fa617951e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 18 Feb 2013 21:36:36 +0000 Subject: [PATCH] Openup servicemanager again --- openlp/core/__init__.py | 1 + openlp/core/lib/pluginmanager.py | 26 +++++++++++++++++++ openlp/core/ui/mainwindow.py | 23 ++-------------- .../openlp_core_ui/test_servicemanager.py | 13 +++++----- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 3ad0e1348..781c19627 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -136,6 +136,7 @@ class OpenLP(QtGui.QApplication): self.processEvents() # start the main app window self.main_window = MainWindow() + Registry().execute(u'bootstrap') self.main_window.show() if show_splash: # now kill the splashscreen diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 7ae00a4d0..98bca2529 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -54,11 +54,37 @@ class PluginManager(object): """ log.info(u'Plugin manager Initialising') Registry().register(u'plugin_manager', self) + Registry().register_function(u'bootstrap', self.bootstrap) self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir)) log.debug(u'Base path %s ', self.base_path) self.plugins = [] log.info(u'Plugin manager Initialised') + def bootstrap(self): + """ + Bootstrap all the plugin manager functions + """ + log.info(u'Bootstrap') + self.find_plugins() + # hook methods have to happen after find_plugins. Find plugins needs + # the controllers hence the hooks have moved from setupUI() to here + # Find and insert settings tabs + log.info(u'hook settings') + self.hook_settings_tabs() + # Find and insert media manager items + log.info(u'hook media') + self.hook_media_manager() + # Call the hook method to pull in import menus. + log.info(u'hook menus') + self.hook_import_menu() + # Call the hook method to pull in export menus. + self.hook_export_menu() + # Call the hook method to pull in tools menus. + self.hook_tools_menu() + # Call the initialise method to setup plugins. + log.info(u'initialise plugins') + self.initialise_plugins() + def find_plugins(self): """ Scan a directory for objects inheriting from the ``Plugin`` class. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index c0384aa6b..1202228fa 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -492,7 +492,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Set up the path with plugins self.plugin_manager = PluginManager() - self.imageManager = ImageManager() + self.image_manager = ImageManager() # Set up the interface self.setupUi(self) @@ -541,26 +541,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.renderer = Renderer() - log.info(u'Load Plugins') - self.plugin_manager.find_plugins() - # hook methods have to happen after find_plugins. Find plugins needs - # the controllers hence the hooks have moved from setupUI() to here - # Find and insert settings tabs - log.info(u'hook settings') - self.plugin_manager.hook_settings_tabs() - # Find and insert media manager items - log.info(u'hook media') - self.plugin_manager.hook_media_manager() - # Call the hook method to pull in import menus. - log.info(u'hook menus') - self.plugin_manager.hook_import_menu() - # Call the hook method to pull in export menus. - self.plugin_manager.hook_export_menu() - # Call the hook method to pull in tools menus. - self.plugin_manager.hook_tools_menu() - # Call the initialise method to setup plugins. - log.info(u'initialise plugins') - self.plugin_manager.initialise_plugins() + # Create the displays as all necessary components are loaded. self.preview_controller.screenSizeChanged() self.live_controller.screenSizeChanged() diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 97212f326..db161022b 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -21,15 +21,15 @@ class TestServiceManager(TestCase): self.app = QtGui.QApplication.instance() ScreenList.create(self.app.desktop()) Registry().register(u'application', MagicMock()) - #with patch(u'openlp.core.lib.PluginManager'): - # self.main_window = MainWindow() - #self.service_manager = Registry().get(u'service_manager') + with patch(u'openlp.core.lib.PluginManager'): + self.main_window = MainWindow() + self.service_manager = Registry().get(u'service_manager') def tearDown(self): """ Delete all the C++ objects at the end so that we don't have a segfault """ - #del self.main_window + del self.main_window del self.app def basic_service_manager_test(self): @@ -40,6 +40,5 @@ class TestServiceManager(TestCase): # WHEN I have an empty display # THEN the count of items should be zero - #self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0, - # u'The service manager list should be empty ') - pass + self.assertEqual(self.service_manager.service_manager_list.topLevelItemCount(), 0, + u'The service manager list should be empty ')