← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bootstrap into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bootstrap into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~trb143/openlp/bootstrap/+merge/149163

Start of an idea to load load some classes via a bootstrap mechanism.
Implemented it for the plugins and opened up the troublesome test.
-- 
https://code.launchpad.net/~trb143/openlp/bootstrap/+merge/149163
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bootstrap into lp:openlp.
=== modified file 'openlp/core/__init__.py'
--- openlp/core/__init__.py	2013-02-16 12:30:16 +0000
+++ openlp/core/__init__.py	2013-02-18 21:39:18 +0000
@@ -136,6 +136,7 @@
         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

=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py	2013-02-17 12:57:52 +0000
+++ openlp/core/lib/pluginmanager.py	2013-02-18 21:39:18 +0000
@@ -54,11 +54,37 @@
         """
         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.
@@ -118,56 +144,44 @@
             if plugin.status is not PluginStatus.Disabled:
                 plugin.createMediaManagerItem()
 
-    def hook_settings_tabs(self, settings_form=None):
+    def hook_settings_tabs(self):
         """
         Loop through all the plugins. If a plugin has a valid settings tab
         item, add it to the settings tab.
         Tabs are set for all plugins not just Active ones
 
-        ``settings_form``
-            Defaults to *None*. The settings form to add tabs to.
         """
         for plugin in self.plugins:
             if plugin.status is not PluginStatus.Disabled:
-                plugin.createSettingsTab(settings_form)
-        if settings_form:
-            settings_form.plugins = self.plugins
+                plugin.createSettingsTab(self.settings_form)
 
-    def hook_import_menu(self, import_menu):
+    def hook_import_menu(self):
         """
         Loop through all the plugins and give them an opportunity to add an
         item to the import menu.
 
-        ``import_menu``
-            The Import menu.
         """
         for plugin in self.plugins:
             if plugin.status is not PluginStatus.Disabled:
-                plugin.addImportMenuItem(import_menu)
+                plugin.addImportMenuItem(self.main_window.file_import_menu)
 
-    def hook_export_menu(self, export_menu):
+    def hook_export_menu(self):
         """
         Loop through all the plugins and give them an opportunity to add an
         item to the export menu.
-
-        ``export_menu``
-            The Export menu.
         """
         for plugin in self.plugins:
             if plugin.status is not PluginStatus.Disabled:
-                plugin.addExportMenuItem(export_menu)
+                plugin.addExportMenuItem(self.main_window.file_export_menu)
 
-    def hook_tools_menu(self, tools_menu):
+    def hook_tools_menu(self):
         """
         Loop through all the plugins and give them an opportunity to add an
         item to the tools menu.
-
-        ``tools_menu``
-            The Tools menu.
         """
         for plugin in self.plugins:
             if plugin.status is not PluginStatus.Disabled:
-                plugin.addToolsMenuItem(tools_menu)
+                plugin.addToolsMenuItem(self.main_window.tools_menu)
 
     def initialise_plugins(self):
         """
@@ -211,3 +225,23 @@
             if plugin.isActive():
                 plugin.new_service_created()
 
+    def _get_settings_form(self):
+        """
+        Adds the plugin manager to the class dynamically
+        """
+        if not hasattr(self, u'_settings_form'):
+            self._settings_form = Registry().get(u'settings_form')
+        return self._settings_form
+
+    settings_form = property(_get_settings_form)
+
+    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)
+

=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2013-02-07 08:42:17 +0000
+++ openlp/core/lib/renderer.py	2013-02-18 21:39:18 +0000
@@ -662,4 +662,3 @@
         return self._theme_manager
 
     theme_manager = property(_get_theme_manager)
-

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2013-02-17 12:57:52 +0000
+++ openlp/core/ui/mainwindow.py	2013-02-18 21:39:18 +0000
@@ -105,13 +105,13 @@
         self.controlSplitter.setObjectName(u'controlSplitter')
         self.mainContentLayout.addWidget(self.controlSplitter)
         # Create slide controllers
-        self.previewController = SlideController(self)
-        self.liveController = SlideController(self, True)
+        self.preview_controller = SlideController(self)
+        self.live_controller = SlideController(self, True)
         previewVisible = Settings().value(u'user interface/preview panel')
-        self.previewController.panel.setVisible(previewVisible)
+        self.preview_controller.panel.setVisible(previewVisible)
         liveVisible = Settings().value(u'user interface/live panel')
         panelLocked = Settings().value(u'user interface/lock panel')
-        self.liveController.panel.setVisible(liveVisible)
+        self.live_controller.panel.setVisible(liveVisible)
         # Create menu
         self.menuBar = QtGui.QMenuBar(main_window)
         self.menuBar.setObjectName(u'menuBar')
@@ -119,18 +119,18 @@
         self.fileMenu.setObjectName(u'fileMenu')
         self.recentFilesMenu = QtGui.QMenu(self.fileMenu)
         self.recentFilesMenu.setObjectName(u'recentFilesMenu')
-        self.fileImportMenu = QtGui.QMenu(self.fileMenu)
-        self.fileImportMenu.setObjectName(u'fileImportMenu')
-        self.fileExportMenu = QtGui.QMenu(self.fileMenu)
-        self.fileExportMenu.setObjectName(u'fileExportMenu')
+        self.file_import_menu = QtGui.QMenu(self.fileMenu)
+        self.file_import_menu.setObjectName(u'file_import_menu')
+        self.file_export_menu = QtGui.QMenu(self.fileMenu)
+        self.file_export_menu.setObjectName(u'file_export_menu')
         # View Menu
         self.viewMenu = QtGui.QMenu(self.menuBar)
         self.viewMenu.setObjectName(u'viewMenu')
         self.viewModeMenu = QtGui.QMenu(self.viewMenu)
         self.viewModeMenu.setObjectName(u'viewModeMenu')
         # Tools Menu
-        self.toolsMenu = QtGui.QMenu(self.menuBar)
-        self.toolsMenu.setObjectName(u'toolsMenu')
+        self.tools_menu = QtGui.QMenu(self.menuBar)
+        self.tools_menu.setObjectName(u'tools_menu')
         # Settings Menu
         self.settingsMenu = QtGui.QMenu(self.menuBar)
         self.settingsMenu.setObjectName(u'settingsMenu')
@@ -305,11 +305,11 @@
             shortcuts=[QtGui.QKeySequence(u'Alt+F1')],
             category=UiStrings().Help, triggers=self.onOnlineHelpClicked)
         self.webSiteItem = create_action(main_window, u'webSiteItem', category=UiStrings().Help)
-        add_actions(self.fileImportMenu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem))
-        add_actions(self.fileExportMenu, (self.settingsExportItem, None, self.exportThemeItem, self.exportLanguageItem))
+        add_actions(self.file_import_menu, (self.settingsImportItem, None, self.importThemeItem, self.importLanguageItem))
+        add_actions(self.file_export_menu, (self.settingsExportItem, None, self.exportThemeItem, self.exportLanguageItem))
         add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem,
             self.fileSaveItem, self.fileSaveAsItem, self.recentFilesMenu.menuAction(), None,
-            self.fileImportMenu.menuAction(), self.fileExportMenu.menuAction(), None, self.printServiceOrderItem,
+            self.file_import_menu.menuAction(), self.file_export_menu.menuAction(), None, self.printServiceOrderItem,
             self.fileExitItem))
         add_actions(self.viewModeMenu, (self.modeDefaultItem, self.modeSetupItem, self.modeLiveItem))
         add_actions(self.viewMenu, (self.viewModeMenu.menuAction(), None, self.viewMediaManagerItem,
@@ -326,16 +326,16 @@
         else:
             add_actions(self.settingsMenu, (self.settingsPluginListItem, self.settingsLanguageMenu.menuAction(), None,
                 self.formattingTagItem, self.settingsShortcutsItem, self.settingsConfigureItem))
-        add_actions(self.toolsMenu, (self.toolsAddToolItem, None))
-        add_actions(self.toolsMenu, (self.toolsOpenDataFolder, None))
-        add_actions(self.toolsMenu, (self.toolsFirstTimeWizard, None))
-        add_actions(self.toolsMenu, [self.updateThemeImages])
+        add_actions(self.tools_menu, (self.toolsAddToolItem, None))
+        add_actions(self.tools_menu, (self.toolsOpenDataFolder, None))
+        add_actions(self.tools_menu, (self.toolsFirstTimeWizard, None))
+        add_actions(self.tools_menu, [self.updateThemeImages])
         if os.name == u'nt':
             add_actions(self.helpMenu, (self.offlineHelpItem, self.onlineHelpItem, None, self.webSiteItem,
                 self.aboutItem))
         else:
             add_actions(self.helpMenu, (self.onlineHelpItem, None, self.webSiteItem, self.aboutItem))
-        add_actions(self.menuBar, (self.fileMenu.menuAction(), self.viewMenu.menuAction(), self.toolsMenu.menuAction(),
+        add_actions(self.menuBar, (self.fileMenu.menuAction(), self.viewMenu.menuAction(), self.tools_menu.menuAction(),
             self.settingsMenu.menuAction(), self.helpMenu.menuAction()))
         # Initialise the translation
         self.retranslateUi(main_window)
@@ -356,12 +356,12 @@
         mainWindow.mainTitle = UiStrings().OLPV2x
         mainWindow.setWindowTitle(mainWindow.mainTitle)
         self.fileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
-        self.fileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))
-        self.fileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export'))
+        self.file_import_menu.setTitle(translate('OpenLP.MainWindow', '&Import'))
+        self.file_export_menu.setTitle(translate('OpenLP.MainWindow', '&Export'))
         self.recentFilesMenu.setTitle(translate('OpenLP.MainWindow', '&Recent Files'))
         self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View'))
         self.viewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode'))
-        self.toolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools'))
+        self.tools_menu.setTitle(translate('OpenLP.MainWindow', '&Tools'))
         self.settingsMenu.setTitle(translate('OpenLP.MainWindow', '&Settings'))
         self.settingsLanguageMenu.setTitle(translate('OpenLP.MainWindow', '&Language'))
         self.helpMenu.setTitle(translate('OpenLP.MainWindow', '&Help'))
@@ -475,93 +475,76 @@
         self.playersSettingsSection = u'players'
         self.displayTagsSection = u'displayTags'
         self.headerSection = u'SettingsImport'
+
+        self.recentFiles = []
+        self.timer_id = 0
+        self.timer_version_id = 0
+        self.new_data_path = None
+        self.copy_data = False
         Settings().set_up_default_values()
         Settings().remove_obsolete_settings()
         self.serviceNotSaved = False
         self.aboutForm = AboutForm(self)
-        self.mediaController = MediaController(self)
+        self.media_controller = MediaController(self)
         self.settingsForm = SettingsForm(self)
         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
+
         self.plugin_manager = PluginManager()
-        self.imageManager = ImageManager()
+        self.image_manager = ImageManager()
+
         # Set up the interface
         self.setupUi(self)
+        # Define the media Dock Manager
+        self.mediaDockManager = MediaDockManager(self.mediaToolBox)
+
         # Register the active media players and suffixes
-        self.mediaController.check_available_media_players()
+        self.media_controller.check_available_media_players()
         # Load settings after setupUi so default UI sizes are overwritten
         self.loadSettings()
         # Once settings are loaded update the menu with the recent files.
         self.updateRecentFilesMenu()
         self.pluginForm = PluginForm(self)
-        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)
-        QtCore.QObject.connect(self.exportThemeItem, QtCore.SIGNAL(u'triggered()'),
-            self.themeManagerContents.on_export_theme)
         QtCore.QObject.connect(self.mediaManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'),
-            self.viewMediaManagerItem.setChecked)
+                               self.viewMediaManagerItem.setChecked)
         QtCore.QObject.connect(self.serviceManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'),
-            self.viewServiceManagerItem.setChecked)
+                               self.viewServiceManagerItem.setChecked)
         QtCore.QObject.connect(self.themeManagerDock, QtCore.SIGNAL(u'visibilityChanged(bool)'),
-            self.viewThemeManagerItem.setChecked)
-        QtCore.QObject.connect(self.webSiteItem, QtCore.SIGNAL(u'triggered()'), self.onHelpWebSiteClicked)
-        QtCore.QObject.connect(self.toolsOpenDataFolder, QtCore.SIGNAL(u'triggered()'),
-            self.onToolsOpenDataFolderClicked)
-        QtCore.QObject.connect(self.toolsFirstTimeWizard, QtCore.SIGNAL(u'triggered()'), self.onFirstTimeWizardClicked)
-        QtCore.QObject.connect(self.updateThemeImages, QtCore.SIGNAL(u'triggered()'), self.onUpdateThemeImages)
-        QtCore.QObject.connect(self.formattingTagItem, QtCore.SIGNAL(u'triggered()'), self.onFormattingTagItemClicked)
-        QtCore.QObject.connect(self.settingsConfigureItem, QtCore.SIGNAL(u'triggered()'),
-            self.onSettingsConfigureItemClicked)
-        QtCore.QObject.connect(self.settingsShortcutsItem, QtCore.SIGNAL(u'triggered()'),
-            self.onSettingsShortcutsItemClicked)
-        QtCore.QObject.connect(self.settingsImportItem, QtCore.SIGNAL(u'triggered()'),
-            self.onSettingsImportItemClicked)
-        QtCore.QObject.connect(self.settingsExportItem, QtCore.SIGNAL(u'triggered()'), self.onSettingsExportItemClicked)
+                               self.viewThemeManagerItem.setChecked)
+        self.importThemeItem.triggered.connect(self.themeManagerContents.on_import_theme)
+        self.exportThemeItem.triggered.connect(self.themeManagerContents.on_export_theme)
+        self.webSiteItem.triggered.connect(self.onHelpWebSiteClicked)
+        self.toolsOpenDataFolder.triggered.connect(self.onToolsOpenDataFolderClicked)
+        self.toolsFirstTimeWizard.triggered.connect(self.onFirstTimeWizardClicked)
+        self.updateThemeImages.triggered.connect(self.onUpdateThemeImages)
+        self.formattingTagItem.triggered.connect(self.onFormattingTagItemClicked)
+        self.settingsConfigureItem.triggered.connect(self.onSettingsConfigureItemClicked)
+        self.settingsShortcutsItem.triggered.connect(self.onSettingsShortcutsItemClicked)
+        self.settingsImportItem.triggered.connect(self.onSettingsImportItemClicked)
+        self.settingsExportItem.triggered.connect(self.onSettingsExportItemClicked)
         # i18n set signals for languages
         self.languageGroup.triggered.connect(LanguageManager.set_language)
-        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)
+        self.modeDefaultItem.triggered.connect(self.onModeDefaultItemClicked)
+        self.modeSetupItem.triggered.connect(self.onModeSetupItemClicked)
+        self.modeLiveItem.triggered.connect(self.onModeLiveItemClicked)
         # Media Manager
-        QtCore.QObject.connect(self.mediaToolBox, QtCore.SIGNAL(u'currentChanged(int)'), self.onMediaToolBoxChanged)
+        self.mediaToolBox.currentChanged.connect(self.onMediaToolBoxChanged)
         self.application.set_busy_cursor()
+
         # Simple message boxes
         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)
-        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(self.settingsForm)
-        # 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(self.fileImportMenu)
-        # Call the hook method to pull in export menus.
-        self.plugin_manager.hook_export_menu(self.fileExportMenu)
-        # Call the hook method to pull in tools menus.
-        self.plugin_manager.hook_tools_menu(self.toolsMenu)
-        # 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.previewController.screenSizeChanged()
-        self.liveController.screenSizeChanged()
+        self.preview_controller.screenSizeChanged()
+        self.live_controller.screenSizeChanged()
         log.info(u'Load data from Settings')
         if Settings().value(u'advanced/save current plugin'):
             savedPlugin = Settings().value(u'advanced/current media plugin')
@@ -605,8 +588,8 @@
         Show the main form, as well as the display form
         """
         QtGui.QWidget.show(self)
-        if self.liveController.display.isVisible():
-            self.liveController.display.setFocus()
+        if self.live_controller.display.isVisible():
+            self.live_controller.display.setFocus()
         self.activateWindow()
         if self.arguments:
             args = []
@@ -699,7 +682,7 @@
         Check and display message if screen blank on setup.
         """
         settings = Settings()
-        self.liveController.mainDisplaySetBackground()
+        self.live_controller.mainDisplaySetBackground()
         if settings.value(u'%s/screen blank' % self.generalSettingsSection):
             if settings.value(u'%s/blank warning' % self.generalSettingsSection):
                 QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'),
@@ -806,8 +789,8 @@
         """
         We need to make sure, that the SlidePreview's size is correct.
         """
-        self.previewController.previewSizeChanged()
-        self.liveController.previewSizeChanged()
+        self.preview_controller.previewSizeChanged()
+        self.live_controller.previewSizeChanged()
 
     def onSettingsShortcutsItemClicked(self):
         """
@@ -1015,10 +998,10 @@
         """
         log.debug(u'screen_changed')
         self.application.set_busy_cursor()
-        self.imageManager.update_display()
+        self.image_manager.update_display()
         self.renderer.update_display()
-        self.previewController.screenSizeChanged()
-        self.liveController.screenSizeChanged()
+        self.preview_controller.screenSizeChanged()
+        self.live_controller.screenSizeChanged()
         self.setFocus()
         self.activateWindow()
         self.application.set_normal_cursor()
@@ -1071,8 +1054,8 @@
         ``save_settings``
             Switch to prevent saving settings. Defaults to **True**.
         """
-        self.imageManager.stop_manager = True
-        while self.imageManager.image_thread.isRunning():
+        self.image_manager.stop_manager = True
+        while self.image_manager.image_thread.isRunning():
             time.sleep(0.1)
         # Clean temporary files used by services
         self.serviceManagerContents.clean_up()
@@ -1089,9 +1072,9 @@
         if self.new_data_path:
             self.changeDataDirectory()
         # Close down the display
-        if self.liveController.display:
-            self.liveController.display.close()
-            self.liveController.display = None
+        if self.live_controller.display:
+            self.live_controller.display.close()
+            self.live_controller.display = None
 
     def serviceChanged(self, reset=False, serviceName=None):
         """
@@ -1172,7 +1155,7 @@
                 True - Visible
                 False - Hidden
         """
-        self.previewController.panel.setVisible(visible)
+        self.preview_controller.panel.setVisible(visible)
         Settings().setValue(u'user interface/preview panel', visible)
         self.viewPreviewPanel.setChecked(visible)
 
@@ -1210,7 +1193,7 @@
                 True - Visible
                 False - Hidden
         """
-        self.liveController.panel.setVisible(visible)
+        self.live_controller.panel.setVisible(visible)
         Settings().setValue(u'user interface/live panel', visible)
         self.viewLivePanel.setChecked(visible)
 
@@ -1230,8 +1213,8 @@
         self.move(settings.value(u'main window position'))
         self.restoreGeometry(settings.value(u'main window geometry'))
         self.restoreState(settings.value(u'main window state'))
-        self.liveController.splitter.restoreState(settings.value(u'live splitter geometry'))
-        self.previewController.splitter.restoreState(settings.value(u'preview splitter geometry'))
+        self.live_controller.splitter.restoreState(settings.value(u'live splitter geometry'))
+        self.preview_controller.splitter.restoreState(settings.value(u'preview splitter geometry'))
         self.controlSplitter.restoreState(settings.value(u'main window splitter geometry'))
         settings.endGroup()
 
@@ -1251,8 +1234,8 @@
         settings.setValue(u'main window position', self.pos())
         settings.setValue(u'main window state', self.saveState())
         settings.setValue(u'main window geometry', self.saveGeometry())
-        settings.setValue(u'live splitter geometry', self.liveController.splitter.saveState())
-        settings.setValue(u'preview splitter geometry', self.previewController.splitter.saveState())
+        settings.setValue(u'live splitter geometry', self.live_controller.splitter.saveState())
+        settings.setValue(u'preview splitter geometry', self.preview_controller.splitter.saveState())
         settings.setValue(u'main window splitter geometry', self.controlSplitter.saveState())
         settings.endGroup()
 

=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py	2013-02-07 08:42:17 +0000
+++ openlp/core/ui/settingsform.py	2013-02-18 21:39:18 +0000
@@ -75,7 +75,7 @@
         self.insertTab(self.advancedTab, 2, PluginStatus.Active)
         self.insertTab(self.playerTab, 3, PluginStatus.Active)
         count = 4
-        for plugin in self.plugins:
+        for plugin in self.plugin_manager.plugins:
             if plugin.settingsTab:
                 self.insertTab(plugin.settingsTab, count, plugin.status)
                 count += 1
@@ -126,7 +126,7 @@
         self.themesTab.postSetUp()
         self.advancedTab.postSetUp()
         self.playerTab.postSetUp()
-        for plugin in self.plugins:
+        for plugin in self.plugin_manager.plugins:
             if plugin.settingsTab:
                 plugin.settingsTab.postSetUp()
 
@@ -166,3 +166,13 @@
         return self._service_manager
 
     service_manager = property(_get_service_manager)
+
+    def _get_plugin_manager(self):
+        """
+        Adds the plugin manager to the class dynamically
+        """
+        if not hasattr(self, u'_plugin_manager'):
+            self._plugin_manager = Registry().get(u'plugin_manager')
+        return self._plugin_manager
+
+    plugin_manager = property(_get_plugin_manager)

=== modified file 'openlp/plugins/alerts/alertsplugin.py'
--- openlp/plugins/alerts/alertsplugin.py	2013-02-05 08:05:28 +0000
+++ openlp/plugins/alerts/alertsplugin.py	2013-02-18 21:39:18 +0000
@@ -151,7 +151,7 @@
             text=translate('AlertsPlugin', '&Alert'), icon=u':/plugins/plugin_alerts.png',
             statustip=translate('AlertsPlugin', 'Show an alert message.'),
             visible=False, shortcuts=[u'F7'], triggers=self.onAlertsTrigger)
-        self.main_window.toolsMenu.addAction(self.toolsAlertItem)
+        self.main_window.tools_menu.addAction(self.toolsAlertItem)
 
     def initialise(self):
         log.info(u'Alerts Initialising')

=== modified file 'tests/interfaces/openlp_core_ui/test_servicemanager.py'
--- tests/interfaces/openlp_core_ui/test_servicemanager.py	2013-02-18 19:34:36 +0000
+++ tests/interfaces/openlp_core_ui/test_servicemanager.py	2013-02-18 21:39:18 +0000
@@ -21,15 +21,15 @@
         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 @@
 
         # 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 ')