forked from openlp/openlp
Edit Songs and Custom for Service Manager and auto replace
bzr-revno: 634
This commit is contained in:
commit
3c6d1e7efb
@ -78,6 +78,9 @@ class EventReceiver(QtCore.QObject):
|
||||
``{plugin}_stop``
|
||||
Requests a plugin to handle a stop event
|
||||
|
||||
``{plugin}_edit``
|
||||
Requests a plugin edit a database item with the key as the payload
|
||||
|
||||
``songusage_live``
|
||||
Sends live song audit requests to the audit component
|
||||
|
||||
@ -97,6 +100,10 @@ class EventReceiver(QtCore.QObject):
|
||||
``slidecontroller_change``
|
||||
Informs the slidecontroller that a slide change has occurred
|
||||
|
||||
|
||||
``remote_edite_clear``
|
||||
Informs all components that remote edit has been aborted.
|
||||
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'EventReceiver')
|
||||
|
@ -70,6 +70,7 @@ class ServiceItem(object):
|
||||
self.theme = None
|
||||
self.service_item_path = None
|
||||
self.service_item_type = None
|
||||
self.editEnabled = False
|
||||
self.service_frames = []
|
||||
|
||||
def addIcon(self, icon):
|
||||
|
@ -38,6 +38,24 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
||||
QtGui.QTreeWidget.__init__(self,parent)
|
||||
self.parent = parent
|
||||
|
||||
# def mousePressEvent(self, event):
|
||||
# if event.button() == QtCore.Qt.RightButton:
|
||||
# item = self.itemAt(event.pos())
|
||||
# parentitem = item.parent()
|
||||
# if parentitem is None:
|
||||
# pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
# else:
|
||||
# pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
# serviceItem = self.parent.serviceItems[pos - 1]
|
||||
# if serviceItem[u'data'].editEnabled:
|
||||
# self.parent.editAction.setVisible(True)
|
||||
# else:
|
||||
# self.parent.editAction.setVisible(False)
|
||||
# event.accept()
|
||||
# else:
|
||||
# event.ignore()
|
||||
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
if type(event) == QtGui.QKeyEvent:
|
||||
#here accept the event and do something
|
||||
@ -111,6 +129,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceItems = []
|
||||
self.serviceName = u''
|
||||
self.isNew = True
|
||||
self.remoteEditTriggered = False
|
||||
self.Layout = QtGui.QVBoxLayout(self)
|
||||
self.Layout.setSpacing(0)
|
||||
self.Layout.setMargin(0)
|
||||
@ -157,6 +176,12 @@ class ServiceManager(QtGui.QWidget):
|
||||
# Add a context menu to the service manager list
|
||||
self.ServiceManagerList.setContextMenuPolicy(
|
||||
QtCore.Qt.ActionsContextMenu)
|
||||
self.editAction = contextMenuAction(
|
||||
self.ServiceManagerList, ':/system/system_live.png',
|
||||
self.trUtf8(u'&Edit Item'), self.remoteEdit)
|
||||
self.ServiceManagerList.addAction(self.editAction)
|
||||
self.ServiceManagerList.addAction(contextMenuSeparator(
|
||||
self.ServiceManagerList))
|
||||
self.ServiceManagerList.addAction(contextMenuAction(
|
||||
self.ServiceManagerList, ':/system/system_preview.png',
|
||||
self.trUtf8(u'&Preview Verse'), self.makePreview))
|
||||
@ -205,6 +230,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'remote_edit_clear'), self.onRemoteEditClear)
|
||||
# Last little bits of setting up
|
||||
self.config = PluginConfig(u'ServiceManager')
|
||||
self.servicePath = self.config.get_data_path()
|
||||
@ -510,14 +537,19 @@ class ServiceManager(QtGui.QWidget):
|
||||
"""
|
||||
sitem, count = self.findServiceItem()
|
||||
item.render()
|
||||
if sitem == -1:
|
||||
self.serviceItems.append({u'data': item,
|
||||
u'order': len(self.serviceItems) + 1, u'expanded':True})
|
||||
self.repaintServiceList(len(self.serviceItems) + 1, 0)
|
||||
else:
|
||||
self.serviceItems.insert(sitem + 1, {u'data': item,
|
||||
u'order': len(self.serviceItems)+1, u'expanded':True})
|
||||
if self.remoteEditTriggered:
|
||||
self.serviceItems[sitem][u'data'] = item
|
||||
self.remoteEditTriggered = False
|
||||
self.repaintServiceList(sitem + 1, 0)
|
||||
else:
|
||||
if sitem == -1:
|
||||
self.serviceItems.append({u'data': item,
|
||||
u'order': len(self.serviceItems) + 1, u'expanded':True})
|
||||
self.repaintServiceList(len(self.serviceItems) + 1, 0)
|
||||
else:
|
||||
self.serviceItems.insert(sitem + 1, {u'data': item,
|
||||
u'order': len(self.serviceItems)+1, u'expanded':True})
|
||||
self.repaintServiceList(sitem + 1, 0)
|
||||
self.parent.serviceChanged(False, self.serviceName)
|
||||
|
||||
def makePreview(self):
|
||||
@ -536,6 +568,19 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.parent.LiveController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'data'], count)
|
||||
|
||||
def remoteEdit(self):
|
||||
"""
|
||||
Posts a remote edit message to a plugin to allow item to be edited.
|
||||
"""
|
||||
item, count = self.findServiceItem()
|
||||
if self.serviceItems[item][u'data'].editEnabled:
|
||||
self.remoteEditTriggered = True
|
||||
Receiver().send_message(u'%s_edit' % self.serviceItems[item][u'data'].name,
|
||||
self.serviceItems[item][u'data'].editId )
|
||||
|
||||
def onRemoteEditClear(self):
|
||||
self.remoteEditTriggered = False
|
||||
|
||||
def findServiceItem(self):
|
||||
"""
|
||||
Finds a ServiceItem in the list
|
||||
|
@ -266,7 +266,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
try:
|
||||
xml = file_to_xml(xml_file)
|
||||
except:
|
||||
xml = baseTheme()
|
||||
xml = self.baseTheme()
|
||||
theme = ThemeXML()
|
||||
theme.parse(xml)
|
||||
self.cleanTheme(theme)
|
||||
|
@ -69,4 +69,4 @@ class CustomPlugin(Plugin):
|
||||
self.remove_toolbox_item()
|
||||
|
||||
def about(self):
|
||||
return u'<b>Custom Plugin</b> <br>This plugin allows slides to be displayed on the screen in the same way songs are. The difference between this plugin and songs is this plugin provides greater freedom.<br><br>This is a core plugin and cannot be made inactive</b>'
|
||||
return u'<b>Custom Plugin</b> <br>This plugin allows slides to be displayed on the screen in the same way songs are. The difference between this plugin and songs is this plugin provides greater freedom.<br>'
|
||||
|
@ -54,7 +54,8 @@ class Ui_customEditDialog(object):
|
||||
self.UpButton.setIcon(icon1)
|
||||
self.UpButton.setObjectName(u'UpButton')
|
||||
self.verticalLayout.addWidget(self.UpButton)
|
||||
spacerItem = QtGui.QSpacerItem(20, 128, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
spacerItem = QtGui.QSpacerItem(20, 128,
|
||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.verticalLayout.addItem(spacerItem)
|
||||
self.DownButton = QtGui.QPushButton(customEditDialog)
|
||||
icon2 = buildIcon(u':/services/service_down.png')
|
||||
@ -94,7 +95,8 @@ class Ui_customEditDialog(object):
|
||||
self.ClearButton = QtGui.QPushButton(self.ButtonWidge)
|
||||
self.ClearButton.setObjectName(u'ClearButton')
|
||||
self.verticalLayout_2.addWidget(self.ClearButton)
|
||||
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
spacerItem1 = QtGui.QSpacerItem(20, 40,
|
||||
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
|
||||
self.verticalLayout_2.addItem(spacerItem1)
|
||||
self.EditLayout_3.addWidget(self.ButtonWidge)
|
||||
self.gridLayout.addWidget(self.EditWidget, 2, 0, 1, 1)
|
||||
@ -117,11 +119,16 @@ class Ui_customEditDialog(object):
|
||||
self.horizontalLayout_2.addWidget(self.CreditEdit)
|
||||
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
|
||||
self.buttonBox = QtGui.QDialogButtonBox(customEditDialog)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setStandardButtons(
|
||||
QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(u'buttonBox')
|
||||
self.gridLayout.addWidget(self.buttonBox, 5, 0, 1, 1)
|
||||
|
||||
self.retranslateUi(customEditDialog)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), customEditDialog.closePressed)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), customEditDialog.accept)
|
||||
QtCore.QMetaObject.connectSlotsByName(customEditDialog)
|
||||
customEditDialog.setTabOrder(self.TitleEdit, self.VerseTextEdit)
|
||||
customEditDialog.setTabOrder(self.VerseTextEdit, self.AddButton)
|
||||
|
@ -40,10 +40,6 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
#self.parent = parent
|
||||
self.setupUi(self)
|
||||
# Connecting signals and slots
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), self.rejected)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), self.accept)
|
||||
QtCore.QObject.connect(self.AddButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onAddButtonPressed)
|
||||
QtCore.QObject.connect(self.EditButton,
|
||||
@ -113,6 +109,10 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
else:
|
||||
self.ThemeComboBox.setCurrentIndex(0)
|
||||
|
||||
def closePressed(self):
|
||||
Receiver().send_message(u'remote_edit_clear')
|
||||
self.close()
|
||||
|
||||
def accept(self):
|
||||
valid, message = self._validate()
|
||||
if not valid:
|
||||
@ -132,9 +132,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)
|
||||
self.close()
|
||||
|
||||
def rejected(self):
|
||||
Receiver().send_message(u'load_custom_list')
|
||||
self.close()
|
||||
|
||||
def onUpButtonPressed(self):
|
||||
|
@ -26,7 +26,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD
|
||||
from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD, Receiver
|
||||
|
||||
class CustomListView(BaseListWithDnD):
|
||||
def __init__(self, parent=None):
|
||||
@ -53,6 +53,15 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.servicePath = None
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
self.parent = parent
|
||||
self.fromServiceManager = -1
|
||||
|
||||
def addEndHeaderBar(self):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_edit' % self.parent.name), self.onRemoteEdit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'load_custom_list'), self.initialise)
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
@ -68,12 +77,24 @@ 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)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
self.initialise()
|
||||
|
||||
def onRemoteEditClear(self):
|
||||
self.fromServiceManager = -1
|
||||
|
||||
def onRemoteEdit(self, item_id):
|
||||
valid = self.parent.custommanager.get_custom(item_id)
|
||||
if valid is not None:
|
||||
self.fromServiceManager = item_id
|
||||
self.parent.edit_custom_form.loadCustom(item_id)
|
||||
self.parent.edit_custom_form.exec_()
|
||||
|
||||
def onEditClick(self):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
@ -95,13 +116,19 @@ class CustomMediaItem(MediaManagerItem):
|
||||
raw_footer = []
|
||||
slide = None
|
||||
theme = None
|
||||
item = self.ListView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
if self.fromServiceManager == -1:
|
||||
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
|
||||
customSlide = self.parent.custommanager.get_custom(item_id)
|
||||
title = customSlide.title
|
||||
credit = customSlide.credits
|
||||
service_item.editEnabled = True
|
||||
service_item.editId = item_id
|
||||
theme = customSlide.theme_name
|
||||
if len(theme) is not 0 :
|
||||
service_item.theme = theme
|
||||
|
@ -383,7 +383,7 @@ class Ui_EditSongDialog(object):
|
||||
|
||||
self.retranslateUi(EditSongDialog)
|
||||
QtCore.QObject.connect(self.ButtonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), EditSongDialog.close)
|
||||
QtCore.SIGNAL(u'rejected()'), EditSongDialog.closePressed)
|
||||
QtCore.QObject.connect(self.ButtonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), EditSongDialog.accept)
|
||||
QtCore.QMetaObject.connectSlotsByName(EditSongDialog)
|
||||
|
@ -400,15 +400,18 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def onPreview(self, button):
|
||||
log.debug(u'onPreview')
|
||||
if button.text() == self.trUtf8(u'Save & Preview') and self.saveSong():
|
||||
if button.text() == unicode(self.trUtf8(u'Save && Preview')) \
|
||||
and self.saveSong():
|
||||
Receiver().send_message(u'preview_song')
|
||||
|
||||
def closePressed(self):
|
||||
Receiver().send_message(u'remote_edit_clear')
|
||||
self.close()
|
||||
|
||||
def accept(self):
|
||||
log.debug(u'accept')
|
||||
if self.saveSong():
|
||||
if self.title_change:
|
||||
Receiver().send_message(u'load_song_list')
|
||||
Receiver().send_message(u'preview_song')
|
||||
Receiver().send_message(u'load_song_list')
|
||||
self.close()
|
||||
|
||||
def saveSong(self):
|
||||
|
@ -55,7 +55,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
|
||||
self.song_maintenance_form = SongMaintenanceForm(
|
||||
self.parent.songmanager, self)
|
||||
self.fromPreview = None
|
||||
self.fromPreview = -1
|
||||
self.fromServiceManager = -1
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
@ -126,6 +127,10 @@ class SongMediaItem(MediaManagerItem):
|
||||
QtCore.SIGNAL(u'edit_song'), self.onEventEditSong)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'preview_song'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_edit' % self.parent.name), self.onRemoteEdit)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'remote_edit_clear' ), self.onRemoteEditClear)
|
||||
|
||||
def configUpdated(self):
|
||||
self.searchAsYouType = str_to_bool(
|
||||
@ -179,8 +184,11 @@ class SongMediaItem(MediaManagerItem):
|
||||
song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id))
|
||||
self.ListView.addItem(song_name)
|
||||
if song.id == self.fromPreview:
|
||||
self.fromPreview = 0
|
||||
self.ListView.setCurrentItem(song_name)
|
||||
self.onPreviewClick()
|
||||
self.fromPreview = -1
|
||||
if song.id == self.fromServiceManager:
|
||||
self.onAddClick()
|
||||
|
||||
def displayResultsAuthor(self, searchresults):
|
||||
log.debug(u'display results Author')
|
||||
@ -226,11 +234,21 @@ class SongMediaItem(MediaManagerItem):
|
||||
def onSongMaintenanceClick(self):
|
||||
self.song_maintenance_form.exec_()
|
||||
|
||||
def onRemoteEditClear(self):
|
||||
self.fromServiceManager = -1
|
||||
|
||||
def onRemoteEdit(self, songid):
|
||||
valid = self.parent.songmanager.get_song(songid)
|
||||
if valid is not None:
|
||||
self.fromServiceManager = songid
|
||||
self.edit_song_form.loadSong(songid)
|
||||
self.edit_song_form.exec_()
|
||||
|
||||
def onEditClick(self, preview=False):
|
||||
item = self.ListView.currentItem()
|
||||
if item is not None:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
self.fromPreview = 0
|
||||
self.fromPreview = -1
|
||||
if preview:
|
||||
self.fromPreview = item_id
|
||||
self.edit_song_form.loadSong(item_id)
|
||||
@ -253,12 +271,18 @@ class SongMediaItem(MediaManagerItem):
|
||||
author_list = u''
|
||||
author_audit = []
|
||||
ccl = u''
|
||||
item = self.ListView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
if self.fromServiceManager == -1:
|
||||
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
|
||||
song = self.parent.songmanager.get_song(item_id)
|
||||
service_item.theme = song.theme_name
|
||||
service_item.editEnabled = True
|
||||
service_item.editId = item_id
|
||||
if song.lyrics.startswith(u'<?xml version='):
|
||||
songXML=SongXMLParser(song.lyrics)
|
||||
verseList = songXML.get_verses()
|
||||
|
@ -180,4 +180,4 @@ class SongsPlugin(Plugin):
|
||||
self.opensong_export_form.show()
|
||||
|
||||
def about(self):
|
||||
return u'<b>Song Plugin</b> <br>This plugin allows Songs to be managed and displayed.<br><br>This is a core plugin and cannot be made inactive</b>'
|
||||
return u'<b>Song Plugin</b> <br>This plugin allows Songs to be managed and displayed.<br>'
|
||||
|
Loading…
Reference in New Issue
Block a user