From 9e0cb247d6742190155da18cfc737458b022d012 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 23 Feb 2018 08:27:33 +0000 Subject: [PATCH] add song book as first slide --- openlp/plugins/songs/lib/db.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 13 ++++++++++++- openlp/plugins/songs/lib/songstab.py | 11 +++++++++++ openlp/plugins/songs/songsplugin.py | 1 + 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index bf78d8d55..fef160010 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -164,7 +164,7 @@ class Song(BaseModel): """ Add a Songbook Entry to the song if it not yet exists - :param songbook_name: Name of the Songbook. + :param songbook: Name of the Songbook. :param entry: Entry in the Songbook (usually a number) """ for songbook_entry in self.songbook_entries: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index cd2ed258d..69c317692 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -577,6 +577,14 @@ class SongMediaItem(MediaManagerItem): service_item.theme = song.theme_name service_item.edit_id = item_id verse_list = SongXML().get_verses(song.lyrics) + if Settings().value('songs/add songbook slide') and song.songbook_entries: + first_slide = "\n" + for songbook_entry in song.songbook_entries: + first_slide = first_slide + "{book}/{num}/{pub}\n\n".format(book=songbook_entry.songbook.name, + num=songbook_entry.entry, + pub=songbook_entry.songbook.publisher) + + service_item.add_from_text(first_slide, "O1") # no verse list or only 1 space (in error) verse_tags_translated = False if VerseType.from_translated_string(str(verse_list[0][0]['type'])) is not None: @@ -623,6 +631,9 @@ class SongMediaItem(MediaManagerItem): if song.media_files: service_item.add_capability(ItemCapabilities.HasBackgroundAudio) service_item.background_audio = [m.file_path for m in song.media_files] + item.metadata.append("{label}: {media}". + format(label=translate('SongsPlugin.MediaItem', 'Media'), + media=service_item.background_audio)) return True def generate_footer(self, item, song): @@ -696,7 +707,7 @@ class SongMediaItem(MediaManagerItem): for songbook_entry in song.songbook_entries: item.metadata.append("{label}: {book}/{num}/{pub}". format(label=translate('SongsPlugin.MediaItem', 'Songbook'), - book=songbook_entry.songbook.name, + book=songbook_entry.songbook.name, num=songbook_entry.entry, pub=songbook_entry.songbook.publisher)) if song.topics: diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 173957b82..524943bb7 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -51,6 +51,9 @@ class SongsTab(SettingsTab): self.add_from_service_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.add_from_service_check_box.setObjectName('add_from_service_check_box') self.mode_layout.addWidget(self.add_from_service_check_box) + self.songbook_slide_check_box = QtWidgets.QCheckBox(self.mode_group_box) + self.songbook_slide_check_box.setObjectName('songbook_slide_check_box') + self.mode_layout.addWidget(self.songbook_slide_check_box) self.display_songbook_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.display_songbook_check_box.setObjectName('songbook_check_box') self.mode_layout.addWidget(self.display_songbook_check_box) @@ -95,6 +98,7 @@ class SongsTab(SettingsTab): self.tool_bar_active_check_box.stateChanged.connect(self.on_tool_bar_active_check_box_changed) self.update_on_edit_check_box.stateChanged.connect(self.on_update_on_edit_check_box_changed) self.add_from_service_check_box.stateChanged.connect(self.on_add_from_service_check_box_changed) + self.songbook_slide_check_box.stateChanged.connect(self.on_songbook_slide_check_box_changed) self.display_songbook_check_box.stateChanged.connect(self.on_songbook_check_box_changed) self.display_written_by_check_box.stateChanged.connect(self.on_written_by_check_box_changed) self.display_copyright_check_box.stateChanged.connect(self.on_copyright_check_box_changed) @@ -111,6 +115,8 @@ class SongsTab(SettingsTab): self.update_on_edit_check_box.setText(translate('SongsPlugin.SongsTab', 'Update service from song edit')) self.add_from_service_check_box.setText(translate('SongsPlugin.SongsTab', 'Import missing songs from Service files')) + self.songbook_slide_check_box.setText(translate('SongsPlugin.SongsTab', + 'Add Songbooks as first side')) self.display_songbook_check_box.setText(translate('SongsPlugin.SongsTab', 'Display songbook in footer')) self.display_written_by_check_box.setText(translate( 'SongsPlugin.SongsTab', 'Show "Written by:" in footer for unspecified authors')) @@ -141,6 +147,9 @@ class SongsTab(SettingsTab): def on_add_from_service_check_box_changed(self, check_state): self.update_load = (check_state == QtCore.Qt.Checked) + def on_songbook_slide_check_box_changed(self, check_state): + self.songbook_slide = (check_state == QtCore.Qt.Checked) + def on_songbook_check_box_changed(self, check_state): self.display_songbook = (check_state == QtCore.Qt.Checked) @@ -171,6 +180,7 @@ class SongsTab(SettingsTab): self.tool_bar = settings.value('display songbar') self.update_edit = settings.value('update service on edit') self.update_load = settings.value('add song from service') + self.songbook_slide = settings.value('add songbook slide') self.display_songbook = settings.value('display songbook') self.display_written_by = settings.value('display written by') self.display_copyright_symbol = settings.value('display copyright symbol') @@ -208,6 +218,7 @@ class SongsTab(SettingsTab): settings.setValue('mainview chords', self.mainview_chords) settings.setValue('disable chords import', self.disable_chords_import) settings.setValue('chord notation', self.chord_notation) + settings.setValue('add songbook slide', self.songbook_slide) settings.endGroup() if self.tab_visited: self.settings_form.register_post_process('songs_config_updated') diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index e8fff3f2a..31f239063 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -61,6 +61,7 @@ __default_settings__ = { 'songs/last import type': SongFormat.OpenLyrics, 'songs/update service on edit': False, 'songs/add song from service': True, + 'songs/add songbook slide': False, 'songs/display songbar': True, 'songs/display songbook': False, 'songs/display written by': True,