More cleanups

This commit is contained in:
Tim Bentley 2013-01-23 19:53:40 +00:00
parent 3378e32da3
commit 76d259264d
6 changed files with 32 additions and 17 deletions

View File

@ -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),
@ -396,3 +392,4 @@ class Plugin(QtCore.QObject):
return self._main_window
main_window = property(_get_main_window)

View File

@ -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 = []

View File

@ -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)

View File

@ -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')

View File

@ -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)

View File

@ -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)