forked from openlp/openlp
Remote editing for custom and theme fix
bzr-revno: 659
This commit is contained in:
commit
87d3cbf289
@ -256,3 +256,26 @@ class ServiceItem(object):
|
||||
self.add_from_command(path, text_image)
|
||||
elif self.service_item_type == ServiceItemType.Video:
|
||||
pass
|
||||
|
||||
def merge(self, other):
|
||||
"""
|
||||
Updates the uuid with the value from the original one
|
||||
The uuid is unique for a give service item but this allows one to
|
||||
replace an original version.
|
||||
"""
|
||||
self.uuid = other.uuid
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
Confirms the service items are for the same instance
|
||||
"""
|
||||
if not other:
|
||||
return False
|
||||
return self.uuid == other.uuid
|
||||
|
||||
def __ne__(self, other):
|
||||
"""
|
||||
Confirms the service items are not for the same instance
|
||||
"""
|
||||
return self.uuid != other.uuid
|
||||
|
||||
|
@ -544,7 +544,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
sitem, count = self.findServiceItem()
|
||||
item.render()
|
||||
if self.remoteEditTriggered:
|
||||
item.uuid = self.serviceItems[sitem][u'data'].uuid
|
||||
item.merge(self.serviceItems[sitem][u'data'])
|
||||
self.serviceItems[sitem][u'data'] = item
|
||||
self.remoteEditTriggered = False
|
||||
self.repaintServiceList(sitem + 1, 0)
|
||||
|
@ -361,8 +361,7 @@ class SlideController(QtGui.QWidget):
|
||||
"""
|
||||
Replacement item following a remote edit
|
||||
"""
|
||||
if self.commandItem and \
|
||||
item.uuid == self.commandItem.uuid:
|
||||
if item.__eq__(self.commandItem):
|
||||
self.addServiceManagerItem(item, self.PreviewListWidget.currentRow())
|
||||
|
||||
def addServiceManagerItem(self, item, slideno):
|
||||
|
@ -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')
|
||||
|
@ -21,6 +21,7 @@
|
||||
# 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, QtGui
|
||||
|
||||
@ -32,6 +33,9 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
"""
|
||||
Class documentation goes here.
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'EditCustomForm')
|
||||
log.info(u'Custom Editor loaded')
|
||||
def __init__(self, custommanager, parent = None):
|
||||
"""
|
||||
Constructor
|
||||
@ -40,6 +44,12 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
#self.parent = parent
|
||||
self.setupUi(self)
|
||||
# Connecting signals and slots
|
||||
self.previewButton = QtGui.QPushButton()
|
||||
self.previewButton.setText(self.trUtf8(u'Save && Preview'))
|
||||
self.buttonBox.addButton(
|
||||
self.previewButton, QtGui.QDialogButtonBox.ActionRole)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
|
||||
QtCore.QObject.connect(self.AddButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
|
||||
QtCore.QObject.connect(self.EditButton,
|
||||
@ -68,6 +78,12 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
self.custommanager = custommanager
|
||||
self.initialise()
|
||||
|
||||
def onPreview(self, button):
|
||||
log.debug(u'onPreview')
|
||||
if button.text() == unicode(self.trUtf8(u'Save && Preview')) \
|
||||
and self.saveCustom():
|
||||
Receiver().send_message(u'preview_custom')
|
||||
|
||||
def initialise(self):
|
||||
self.editAll = False
|
||||
self.DeleteButton.setEnabled(False)
|
||||
@ -89,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:
|
||||
@ -108,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()
|
||||
@ -132,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
|
||||
|
@ -462,7 +462,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
text = text.replace(u'}', u'')
|
||||
text = text.replace(u'?', u'')
|
||||
self.song.search_lyrics = unicode(text)
|
||||
self.song.lyrics = unicode(sxml.extract_xml())
|
||||
self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
|
||||
except:
|
||||
log.exception(u'Problem processing song Lyrics \n%s',
|
||||
sxml.dump_xml())
|
||||
|
@ -1 +1 @@
|
||||
1.9.0-658
|
||||
1.9.0-659
|
||||
|
Loading…
Reference in New Issue
Block a user