diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py index a09e06abb..8661ad4cf 100644 --- a/openlp/core/lib/event.py +++ b/openlp/core/lib/event.py @@ -27,18 +27,19 @@ class EventType(object): """ # "Default" event - a non-event Default = 0 - TriggerAlert = 1 + #TriggerAlert = 1 # General application events - Ready = 10 + # Ready = 10 # Service events - LoadServiceItem = 20 + #LoadServiceItem = 20 # Preview events - PreviewShow = 30 - LiveShow = 31 + #PreviewShow = 30 + #LiveShow = 31 #Theme Related Events - ThemeListChanged = 40 + #ThemeListChanged = 40 #Plugin Related Events - LoadSongList = 50 + #LoadSongList = 50 + class Event(object): diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 2bb3b6776..5c038a4ff 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -18,6 +18,7 @@ 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 """ +import logging from PyQt4 import QtCore @@ -48,12 +49,14 @@ class EventReceiver(QtCore.QObject): Tell the components we have a new global theme """ - + global log + log = logging.getLogger(u'EventReceiver') def __init__(self): QtCore.QObject.__init__(self) def send_message(self, event, msg=None): + log.debug(u'Event %s passed with payload %s' % (event, msg)) print u'message ', event, msg self.emit(QtCore.SIGNAL(event), msg) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index dbdb70a96..7df147328 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -27,7 +27,7 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ PluginForm from openlp.core.lib import translate, Plugin, MediaManagerItem, \ SettingsTab, EventManager, RenderManager, PluginConfig, \ - SettingsManager, PluginManager, EventType + SettingsManager, PluginManager, EventType, Receiver class Ui_MainWindow(object): def setupUi(self, MainWindow): @@ -458,6 +458,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked) QtCore.QObject.connect(self.OptionsSettingsItem, QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged) #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager @@ -593,5 +595,5 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): title = u'%s - %s*' % (self.mainTitle, service_name) self.setWindowTitle(title) - def DefaultThemeChanged(self, theme): + def defaultThemeChanged(self, theme): self.DefaultThemeLabel.setText(self.defaultThemeText + theme) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a6c420151..1ee7f8777 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -72,7 +72,9 @@ class ThemeManager(QtGui.QWidget): self.Layout.addWidget(self.ThemeListWidget) #Signals QtCore.QObject.connect(self.ThemeListWidget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobal) + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'update_global_theme'), self.changeGlobalFromTab) #Variables self.themelist = [] self.path = os.path.join(ConfigHelper.get_data_path(), u'themes') @@ -86,7 +88,22 @@ class ThemeManager(QtGui.QWidget): def getDefault(self): return self.global_theme - def changeGlobal(self, index): + def changeGlobalFromTab(self, themeName): + log.debug(u'changeGlobalFromTab %s', themeName) + for count in range (0, self.ThemeListWidget.count()): + #reset the old name + item = self.ThemeListWidget.item(count) + oldName = item.text() + newName = unicode(item.data(QtCore.Qt.UserRole).toString()) + if oldName != newName: + self.ThemeListWidget.item(count).setText(newName) + #Set the new name + if themeName == newName: + name = u'%s (%s)' % (newName, translate(u'ThemeManager', u'default')) + self.ThemeListWidget.item(count).setText(name) + + def changeGlobalFromScreen(self, index): + log.debug(u'changeGlobalFromScreen %s', index) for count in range (0, self.ThemeListWidget.count()): item = self.ThemeListWidget.item(count) oldName = item.text() @@ -184,7 +201,6 @@ class ThemeManager(QtGui.QWidget): self.pushThemes() def pushThemes(self): - #self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes())) Receiver().send_message(u'update_themes', self.getThemes() ) def getThemes(self): @@ -195,7 +211,6 @@ class ThemeManager(QtGui.QWidget): xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml') try: xml = file_to_xml(xml_file) - #print xml except: newtheme = ThemeXML() newtheme.new_document(u'New Theme') @@ -206,9 +221,7 @@ class ThemeManager(QtGui.QWidget): unicode(0), unicode(0), unicode(0)) xml = newtheme.extract_xml() theme = ThemeXML() - #print theme theme.parse(xml) - #print "A ", theme theme.extend_image_filename(self.path) return theme diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 489749e94..a1a1d68c0 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -88,14 +88,12 @@ class ThemesTab(SettingsTab): self.LevelLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.GlobalLevelLabel) self.ThemesTabLayout.addWidget(self.LevelGroupBox) - QtCore.QObject.connect(self.SongLevelRadioButton, QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed) QtCore.QObject.connect(self.ServiceLevelRadioButton, QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed) QtCore.QObject.connect(self.GlobalLevelRadioButton, QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed) - QtCore.QObject.connect(self.DefaultComboBox, QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged) QtCore.QObject.connect(Receiver.get_receiver(), @@ -124,6 +122,7 @@ class ThemesTab(SettingsTab): def save(self): self.config.set_config(u'theme global style', self.global_style ) self.config.set_config(u'theme global theme',self.global_theme) + Receiver().send_message(u'update_global_theme', self.global_theme ) def onSongLevelButtonPressed(self): self.global_style= u'Song' diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index fe9b24230..fa936f469 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -51,7 +51,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): QtCore.QObject.connect(self.VerseListView, QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'update_themes'), self.loadThemest) + QtCore.SIGNAL(u'update_themes'), self.loadThemes) # Create other objects and forms self.custommanager = custommanager self.initialise()