forked from openlp/openlp
Fix error in previous merge for ThemeManager
Get Custom Working with remote editing
This commit is contained in:
parent
b6602e67d4
commit
38e3ca66cb
@ -276,7 +276,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
xml = file_to_xml(xml_file)
|
||||
if not xml:
|
||||
xml = self.baseTheme()
|
||||
return createThemeFromXml(xml, self.path)
|
||||
return self.createThemeFromXml(xml, self.path)
|
||||
|
||||
def checkThemesExists(self, dir):
|
||||
log.debug(u'check themes')
|
||||
|
@ -81,7 +81,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
def onPreview(self, button):
|
||||
log.debug(u'onPreview')
|
||||
if button.text() == unicode(self.trUtf8(u'Save && Preview')) \
|
||||
and self.saveSong():
|
||||
and self.saveCustom():
|
||||
Receiver().send_message(u'preview_custom')
|
||||
|
||||
def initialise(self):
|
||||
@ -105,7 +105,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
for themename in themelist:
|
||||
self.ThemeComboBox.addItem(themename)
|
||||
|
||||
def loadCustom(self, id):
|
||||
def loadCustom(self, id, preview):
|
||||
self.customSlide = CustomSlide()
|
||||
self.initialise()
|
||||
if id != 0:
|
||||
@ -124,17 +124,27 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
self.ThemeComboBox.setCurrentIndex(id)
|
||||
else:
|
||||
self.ThemeComboBox.setCurrentIndex(0)
|
||||
#if not preview hide the preview button
|
||||
self.previewButton.setVisible(False)
|
||||
if preview:
|
||||
self.previewButton.setVisible(True)
|
||||
|
||||
def closePressed(self):
|
||||
Receiver().send_message(u'remote_edit_clear')
|
||||
self.close()
|
||||
|
||||
def accept(self):
|
||||
log.debug(u'accept')
|
||||
if self.saveCustom():
|
||||
Receiver().send_message(u'load_custom_list')
|
||||
self.close()
|
||||
|
||||
def saveCustom(self):
|
||||
valid, message = self._validate()
|
||||
if not valid:
|
||||
QtGui.QMessageBox.critical(self, self.trUtf8(u'Error'), message,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||
return
|
||||
return False
|
||||
sxml = SongXMLBuilder()
|
||||
sxml.new_document()
|
||||
sxml.add_lyrics_to_song()
|
||||
@ -148,8 +158,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
self.customSlide.credits = unicode(self.CreditEdit.displayText())
|
||||
self.customSlide.theme_name = unicode(self.ThemeComboBox.currentText())
|
||||
self.custommanager.save_slide(self.customSlide)
|
||||
Receiver().send_message(u'load_custom_list')
|
||||
self.close()
|
||||
return True
|
||||
|
||||
def onUpButtonPressed(self):
|
||||
selectedRow = self.VerseListView.currentRow()
|
||||
|
@ -50,7 +50,9 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.ListViewWithDnD_class = CustomListView
|
||||
self.servicePath = None
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
self.fromServiceManager = -1
|
||||
# Holds information about whether the edit is remotly triggered and
|
||||
# which Custom is required.
|
||||
self.remoteCustom = -1
|
||||
|
||||
def addEndHeaderBar(self):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -59,6 +61,8 @@ class CustomMediaItem(MediaManagerItem):
|
||||
QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'load_custom_list'), self.initialise)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'preview_custom'), self.onPreviewClick)
|
||||
|
||||
def initPluginNameVisible(self):
|
||||
self.PluginNameVisible = self.trUtf8(u'Custom')
|
||||
@ -69,6 +73,14 @@ class CustomMediaItem(MediaManagerItem):
|
||||
|
||||
def initialise(self):
|
||||
self.loadCustomListView(self.parent.custommanager.get_all_slides())
|
||||
#Called to redisplay the song list screen edith from a search
|
||||
#or from the exit of the Song edit dialog. If remote editing is active
|
||||
#Trigger it and clean up so it will not update again.
|
||||
if self.remoteTriggered == u'L':
|
||||
self.onAddClick()
|
||||
if self.remoteTriggered == u'P':
|
||||
self.onPreviewClick()
|
||||
self.onRemoteEditClear()
|
||||
|
||||
def loadCustomListView(self, list):
|
||||
self.ListView.clear()
|
||||
@ -77,8 +89,6 @@ class CustomMediaItem(MediaManagerItem):
|
||||
custom_name.setData(
|
||||
QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id))
|
||||
self.ListView.addItem(custom_name)
|
||||
if CustomSlide.id == self.fromServiceManager:
|
||||
self.onAddClick()
|
||||
|
||||
def onNewClick(self):
|
||||
self.parent.edit_custom_form.loadCustom(0)
|
||||
@ -86,20 +96,29 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.initialise()
|
||||
|
||||
def onRemoteEditClear(self):
|
||||
self.fromServiceManager = -1
|
||||
self.remoteTriggered = None
|
||||
self.remoteCustom = -1
|
||||
|
||||
def onRemoteEdit(self, item_id):
|
||||
valid = self.parent.custommanager.get_custom(item_id)
|
||||
def onRemoteEdit(self, customid):
|
||||
"""
|
||||
Called by ServiceManager or SlideController by event passing
|
||||
the Song Id in the payload along with an indicator to say which
|
||||
type of display is required.
|
||||
"""
|
||||
fields = customid.split(u':')
|
||||
valid = self.parent.custommanager.get_custom(fields[1])
|
||||
if valid:
|
||||
self.fromServiceManager = item_id
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.remoteCustom = fields[1]
|
||||
self.remoteTriggered = fields[0]
|
||||
self.parent.edit_custom_form.loadCustom(fields[1],
|
||||
(fields[0] == u'P'))
|
||||
self.parent.edit_custom_form.exec_()
|
||||
|
||||
def onEditClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.parent.edit_custom_form.loadCustom(item_id, False)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
self.initialise()
|
||||
|
||||
@ -116,14 +135,13 @@ class CustomMediaItem(MediaManagerItem):
|
||||
raw_footer = []
|
||||
slide = None
|
||||
theme = None
|
||||
if self.fromServiceManager == -1:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.ListView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = self.fromServiceManager
|
||||
self.fromServiceManager = -1
|
||||
item_id = self.remoteCustom
|
||||
customSlide = self.parent.custommanager.get_custom(item_id)
|
||||
title = customSlide.title
|
||||
credit = customSlide.credits
|
||||
@ -137,9 +155,8 @@ class CustomMediaItem(MediaManagerItem):
|
||||
for verse in verseList:
|
||||
raw_slides.append(verse[1])
|
||||
raw_footer.append(title + u' '+ credit)
|
||||
if theme:
|
||||
service_item.title = title
|
||||
for slide in raw_slides:
|
||||
service_item.add_from_text(slide[:30], slide)
|
||||
service_item.raw_footer = raw_footer
|
||||
service_item.title = title
|
||||
for slide in raw_slides:
|
||||
service_item.add_from_text(slide[:30], slide)
|
||||
service_item.raw_footer = raw_footer
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user