diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 6abdf5f4f..a9ca71946 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -218,12 +218,12 @@ class Ui_EditSongDialog(object): self.rights_layout.setObjectName('rights_layout') self.copyright_layout = QtGui.QHBoxLayout() self.copyright_layout.setObjectName('copyright_layout') - self.copyright_label = QtGui.QLabel(self.rights_group_box) - self.copyright_label.setObjectName('copyright_label') - self.copyright_layout.addWidget(self.copyright_label) self.copyright_edit = QtGui.QLineEdit(self.rights_group_box) self.copyright_edit.setObjectName('copyright_edit') self.copyright_layout.addWidget(self.copyright_edit) + self.copyright_insert_button = QtGui.QToolButton(self.rights_group_box) + self.copyright_insert_button.setObjectName('copyright_insert_button') + self.copyright_layout.addWidget(self.copyright_insert_button) self.rights_layout.addLayout(self.copyright_layout) self.ccli_layout = QtGui.QHBoxLayout() self.ccli_layout.setObjectName('ccli_layout') @@ -318,7 +318,7 @@ class Ui_EditSongDialog(object): self.theme_group_box.setTitle(UiStrings().Theme) self.theme_add_button.setText(translate('SongsPlugin.EditSongForm', 'New &Theme')) self.rights_group_box.setTitle(translate('SongsPlugin.EditSongForm', 'Copyright Information')) - self.copyright_label.setText(translate('SongsPlugin.EditSongForm', 'Copyright:')) + self.copyright_insert_button.setText(SongStrings.CopyrightSymbol) self.ccli_label.setText(UiStrings().CCLINumberLabel) self.comments_group_box.setTitle(translate('SongsPlugin.EditSongForm', 'Comments')) self.song_tab_widget.setTabText(self.song_tab_widget.indexOf(self.theme_tab), diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 3af7522d2..2125922fe 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -75,6 +75,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.topic_add_button.clicked.connect(self.on_topic_add_button_clicked) self.topic_remove_button.clicked.connect(self.on_topic_remove_button_clicked) self.topics_list_view.itemClicked.connect(self.on_topic_list_view_clicked) + self.copyright_insert_button.clicked.connect(self.on_copyright_insert_button_triggered) self.verse_add_button.clicked.connect(self.on_verse_add_button_clicked) self.verse_list_widget.doubleClicked.connect(self.on_verse_edit_button_clicked) self.verse_edit_button.clicked.connect(self.on_verse_edit_button_clicked) @@ -795,6 +796,18 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): label_text = self.not_all_verses_used_warning self.warning_label.setText(label_text) + def on_copyright_insert_button_triggered(self): + """ + Copyright insert button pressed + """ + text = self.copyright_edit.text() + pos = self.copyright_edit.cursorPosition() + sign = SongStrings.CopyrightSymbol + text = text[:pos] + sign + text[pos:] + self.copyright_edit.setText(text) + self.copyright_edit.setFocus() + self.copyright_edit.setCursorPosition(pos + len(sign)) + def on_maintenance_button_clicked(self): """ Maintenance button pressed diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index c4eaa73e8..d57c8fbcc 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -506,8 +506,7 @@ class SongMediaItem(MediaManagerItem): if authors_translation: item.raw_footer.append("%s: %s" % (AuthorType.Types[AuthorType.Translation], create_separated_list(authors_translation))) - if song.copyright: - item.raw_footer.append('%s %s' % (SongStrings.CopyrightSymbol, song.copyright)) + item.raw_footer.append(song.copyright) if self.display_songbook and song.book: item.raw_footer.append("%s #%s" % (song.book.name, song.song_number)) if Settings().value('core/ccli number'): diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index df841b39c..580ae767d 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -27,7 +27,8 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`upgrade` module provides a way for the database and schema that is the backend for the Songs plugin +The :mod:`upgrade` module provides a way for the database and schema that is the +backend for the Songs plugin """ import logging @@ -38,7 +39,7 @@ from sqlalchemy.sql.expression import func, false, null, text from openlp.core.lib.db import get_upgrade_op log = logging.getLogger(__name__) -__version__ = 5 +__version__ = 4 def upgrade_1(session, metadata): @@ -118,17 +119,3 @@ def upgrade_4(session, metadata): op.rename_table('authors_songs_tmp', 'authors_songs') except OperationalError: log.info('Upgrade 4 has already been run') - - -def upgrade_5(session, metadata): - """ - Version 5 upgrade - - This upgrade removes all hard-coded copyright symbols from the copyright field in the songs. - The copyright symbol is now being added directly in the footer. - """ - try: - op = get_upgrade_op(session) - op.execute('UPDATE songs SET copyright=TRIM(REPLACE(copyright, "©", ""))') - except OperationalError: - log.info('Upgrade 5 has already been run') diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index da6ae4b71..bc22a4577 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -58,7 +58,7 @@ class TestMediaItem(TestCase, TestMixin): author_list = self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned - self.assertEqual(service_item.raw_footer, ['My Song', 'Written by: my author', '© My copyright'], + self.assertEqual(service_item.raw_footer, ['My Song', 'Written by: my author', 'My copyright'], 'The array should be returned correctly with a song, one author and copyright') self.assertEqual(author_list, ['my author'], 'The author list should be returned correctly with one author') @@ -97,7 +97,7 @@ class TestMediaItem(TestCase, TestMixin): # THEN: I get the following Array returned self.assertEqual(service_item.raw_footer, ['My Song', 'Words: another author', 'Music: my author', - 'Translation: translator', '© My copyright'], + 'Translation: translator', 'My copyright'], 'The array should be returned correctly with a song, two authors and copyright') self.assertEqual(author_list, ['another author', 'my author', 'translator'], 'The author list should be returned correctly with two authors') @@ -117,7 +117,7 @@ class TestMediaItem(TestCase, TestMixin): self.media_item.generate_footer(service_item, mock_song) # THEN: I get the following Array returned - self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright', 'CCLI License: 1234'], + self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 1234'], 'The array should be returned correctly with a song, an author, copyright and ccli') # WHEN: I amend the CCLI value @@ -125,7 +125,7 @@ class TestMediaItem(TestCase, TestMixin): self.media_item.generate_footer(service_item, mock_song) # THEN: I would get an amended footer string - self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright', 'CCLI License: 4321'], + self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'CCLI License: 4321'], 'The array should be returned correctly with a song, an author, copyright and amended ccli') def build_song_footer_base_songbook_test(self): @@ -145,14 +145,14 @@ class TestMediaItem(TestCase, TestMixin): self.media_item.generate_footer(service_item, mock_song) # THEN: The songbook should not be in the footer - self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright']) + self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright']) # WHEN: I activate the "display songbook" option self.media_item.display_songbook = True self.media_item.generate_footer(service_item, mock_song) # THEN: The songbook should be in the footer - self.assertEqual(service_item.raw_footer, ['My Song', '© My copyright', 'My songbook #12']) + self.assertEqual(service_item.raw_footer, ['My Song', 'My copyright', 'My songbook #12']) def authors_match_test(self): """