From 76d259264dd2a95a68721fe230542d954d11e52c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 23 Jan 2013 19:53:40 +0000 Subject: [PATCH] More cleanups --- openlp/core/lib/plugin.py | 7 ++----- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/settingsform.py | 20 +++++++++++++++----- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 15 ++++++++++++--- openlp/plugins/songs/songsplugin.py | 3 +-- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index ee085875e..b5bfd7e0f 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -165,10 +165,6 @@ class Plugin(QtCore.QObject): self.status = PluginStatus.Inactive self.previewController = plugin_helpers[u'preview'] self.liveController = plugin_helpers[u'live'] - self.renderer = plugin_helpers[u'renderer'] - self.serviceManager = plugin_helpers[u'service'] - self.settingsForm = plugin_helpers[u'settings form'] - self.pluginManager = plugin_helpers[u'pluginmanager'] 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), @@ -395,4 +391,5 @@ class Plugin(QtCore.QObject): self._main_window = Registry().get(u'main_window') return self._main_window - main_window = property(_get_main_window) \ No newline at end of file + main_window = property(_get_main_window) + diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3dff36937..aa8cd0cca 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -475,7 +475,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.serviceNotSaved = False self.aboutForm = AboutForm(self) self.mediaController = MediaController(self) - self.settingsForm = SettingsForm(self, self) + self.settingsForm = SettingsForm(self) self.formattingTagForm = FormattingTagForm(self) self.shortcutForm = ShortcutListForm(self) self.recentFiles = [] diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 2807f215a..f54bc8729 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, build_icon, PluginStatus +from openlp.core.lib import Receiver, build_icon, PluginStatus, Registry from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from openlp.core.ui.media import PlayerTab from settingsdialog import Ui_SettingsDialog @@ -44,21 +44,21 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ Provide the form to manipulate the settings for OpenLP """ - def __init__(self, mainWindow, parent=None): + def __init__(self, parent=None): """ Initialise the settings form """ - self.mainWindow = mainWindow + Registry().register(u'settings_form', self) QtGui.QDialog.__init__(self, parent) self.setupUi(self) # General tab self.generalTab = GeneralTab(self) # Themes tab - self.themesTab = ThemesTab(self, mainWindow) + self.themesTab = ThemesTab(self, self.main_window) # Advanced tab self.advancedTab = AdvancedTab(self) # Advanced tab - self.playerTab = PlayerTab(self, mainWindow) + self.playerTab = PlayerTab(self, self.main_window) def exec_(self): # load all the settings @@ -142,3 +142,13 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): if self.resetSuffixes: self.mainWindow.serviceManagerContents.resetSupportedSuffixes() self.resetSuffixes = False + + 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/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index e81c53d67..1bac08cec 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -139,7 +139,7 @@ class AlertsPlugin(Plugin): 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.serviceManager.mainwindow.toolsMenu.addAction(self.toolsAlertItem) + self.main_window.toolsMenu.addAction(self.toolsAlertItem) def initialise(self): log.info(u'Alerts Initialising') diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index e22937cd1..7de317334 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -38,7 +38,8 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, check_directory_exists +from openlp.core.lib import PluginStatus, Receiver, MediaType, translate, create_separated_list, \ + check_directory_exists, 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 @@ -87,8 +88,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.onVerseListViewClicked) QtCore.QObject.connect(self.verseOrderEdit, QtCore.SIGNAL(u'textChanged(QString)'), self.onVerseOrderTextChanged) - QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'), - self.mediaitem.plugin.renderer.theme_manager.onAddTheme) + QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'), self.theme_manager.onAddTheme) QtCore.QObject.connect(self.maintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked) QtCore.QObject.connect(self.audioAddFromFileButton, QtCore.SIGNAL(u'clicked()'), self.onAudioAddFromFileButtonClicked) @@ -908,3 +908,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) + def _get_theme_manager(self): + """ + Adds the theme manager to the class dynamically + """ + if not hasattr(self, u'_theme_manager'): + self._theme_manager = Registry().get(u'theme_manager') + return self._theme_manager + + theme_manager = property(_get_theme_manager) \ No newline at end of file diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 075810d99..e5541960f 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -187,8 +187,7 @@ class SongsPlugin(Plugin): ``newTheme`` The new name the plugin should now use. """ - songsUsingTheme = self.manager.get_all_objects(Song, - Song.theme_name == oldTheme) + songsUsingTheme = self.manager.get_all_objects(Song, Song.theme_name == oldTheme) for song in songsUsingTheme: song.theme_name = newTheme self.manager.save_object(song)