diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index f4b992890..4072672f4 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -93,9 +93,6 @@ class EventReceiver(QtCore.QObject): ``config_updated`` Informs components the config has changed - ``edit_song`` - Requests the current song on the preview display be loaded for edit - ``preview_song`` Tells the song plugin the edit has finished and the song can be previewed Only available if the edit was triggered by the Preview button. diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 68dc2bd62..c2263fcdb 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -597,7 +597,7 @@ class ServiceManager(QtGui.QWidget): 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, + Receiver().send_message(u'%s_edit' % self.serviceItems[item][u'data'].name, u'L:%s' % self.serviceItems[item][u'data'].editId ) def onRemoteEditClear(self): diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index f6ed14398..0aefd5537 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -323,7 +323,7 @@ class SlideController(QtGui.QWidget): """ Allows the Preview toolbar to be customised """ - if item.name == u'Songs' and item.fromPlugin: + if (item.name == u'Songs' or item.name == u'Custom') and item.fromPlugin: self.Toolbar.makeWidgetsVisible(self.song_list) else: self.Toolbar.makeWidgetsInvisible(self.song_list) @@ -561,7 +561,8 @@ class SlideController(QtGui.QWidget): def onEditSong(self): self.songEdit = True - Receiver().send_message(u'edit_song') + Receiver().send_message(u'%s_edit' % self.commandItem.name, u'P:%s' % + self.commandItem.editId ) def onGoLive(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 08005b326..29503585c 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -53,12 +53,10 @@ class SongMediaItem(MediaManagerItem): self.edit_song_form = EditSongForm(self.parent.songmanager, self) self.song_maintenance_form = SongMaintenanceForm( self.parent.songmanager, self) - #fromPreview holds the id of the item if the song editor needs to trigger a preview - #without closing. It is set to -1 if this function is inactive - self.fromPreview = -1 - #fromServiceManager holds the id of the item if the song editor needs to trigger posting - #to the servicemanager without closing. It is set to -1 if this function is inactive - self.fromServiceManager = -1 + #Holds information about whether the edit is remotly triggered and which + #Song is required. + self.remoteTriggered = None + self.remoteSong = -1 def initPluginNameVisible(self): self.PluginNameVisible = self.trUtf8(u'Song') @@ -128,8 +126,6 @@ class SongMediaItem(MediaManagerItem): QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.configUpdated) - QtCore.QObject.connect(Receiver.get_receiver(), - 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(), @@ -172,6 +168,14 @@ class SongMediaItem(MediaManagerItem): search_results = self.parent.songmanager.get_song_from_author( search_keywords) self.displayResultsAuthor(search_results) + #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 displayResultsSong(self, searchresults): log.debug(u'display results Song') @@ -188,12 +192,6 @@ class SongMediaItem(MediaManagerItem): song_name = QtGui.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) self.ListView.addItem(song_name) - if song.id == self.fromPreview: - 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') @@ -213,6 +211,11 @@ class SongMediaItem(MediaManagerItem): self.SearchTextEdit.clear() def onSearchTextEditChanged(self, text): + """ + If search as type enabled invoke the search on each key press. + If the Lyrics are being searched do not start till 7 characters + have been entered. + """ if self.searchAsYouType: search_length = 1 if self.SearchTypeComboBox.currentIndex() == 1: @@ -240,28 +243,30 @@ class SongMediaItem(MediaManagerItem): self.song_maintenance_form.exec_() def onRemoteEditClear(self): - self.fromServiceManager = -1 + self.remoteTriggered = None + self.remoteSong = -1 def onRemoteEdit(self, songid): - valid = self.parent.songmanager.get_song(songid) + """ + 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 = songid.split(u':') + valid = self.parent.songmanager.get_song(fields[1]) if valid is not None: - self.fromServiceManager = songid - self.edit_song_form.loadSong(songid, False) + self.remoteSong = fields[1] + self.remoteTriggered = fields[0] + self.edit_song_form.loadSong(fields[1], (fields[0] == u'P')) 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 = -1 - if preview: - self.fromPreview = item_id - self.edit_song_form.loadSong(item_id, preview) + self.edit_song_form.loadSong(item_id, False) self.edit_song_form.exec_() - def onEventEditSong (self): - self.onEditClick(True) - def onDeleteClick(self): item = self.ListView.currentItem() if item is not None: @@ -271,21 +276,17 @@ class SongMediaItem(MediaManagerItem): self.ListView.takeItem(row) def generateSlideData(self, service_item): - #raw_slides =[] raw_footer = [] author_list = u'' author_audit = [] ccl = u'' - 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 - #if we are in preview mode do not reset the servicemanage id - if self.fromPreview != -1: - self.fromServiceManager = -1 + item_id = self.remoteSong song = self.parent.songmanager.get_song(item_id) service_item.theme = song.theme_name service_item.editEnabled = True