In this branch:

- Added "Full License" field for Bibles (1623631)
- Added a setting for controlling visibility of "Written by:" (1557579)
- Added placeholder texts for Bible metadata fields
- Re-organized uistrings to alphabetical order

bzr-revno: 2716
This commit is contained in:
suutari.olli@gmail.com 2017-01-20 21:57:54 +01:00 committed by Tomas Groth
commit eaacfe0ab8
9 changed files with 125 additions and 23 deletions

View File

@ -59,6 +59,13 @@ class UiStrings(object):
self.Automatic = translate('OpenLP.Ui', 'Automatic')
self.BackgroundColor = translate('OpenLP.Ui', 'Background Color')
self.BackgroundColorColon = translate('OpenLP.Ui', 'Background color:')
self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
'than 3 characters long.</strong><br><br>Please try again with '
'a longer search.')
self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
'Please use the Import Wizard to install one or more Bibles.')
self.Bottom = translate('OpenLP.Ui', 'Bottom')
self.Browse = translate('OpenLP.Ui', 'Browse...')
self.Cancel = translate('OpenLP.Ui', 'Cancel')
@ -118,6 +125,8 @@ class UiStrings(object):
self.OLPV2x = "{name} {version}".format(name=self.OLP, version="2.4")
self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')
self.OpenService = translate('OpenLP.Ui', 'Open service.')
self.OptionalShowInFooter = translate('OpenLP.Ui', 'Optional, this will be displayed in footer.')
self.OptionalHideInFooter = translate('OpenLP.Ui', 'Optional, this won\'t be displayed in footer.')
self.PlaySlidesInLoop = translate('OpenLP.Ui', 'Play Slides in Loop')
self.PlaySlidesToEnd = translate('OpenLP.Ui', 'Play Slides to End')
self.Preview = translate('OpenLP.Ui', 'Preview')
@ -131,6 +140,7 @@ class UiStrings(object):
'player is disabled.')
self.ResetBG = translate('OpenLP.Ui', 'Reset Background')
self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.')
self.RequiredShowInFooter = translate('OpenLP.Ui', 'Required, this will be displayed in footer.')
self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
self.Search = translate('OpenLP.Ui', 'Search')
@ -159,13 +169,6 @@ class UiStrings(object):
self.View = translate('OpenLP.Ui', 'View')
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
self.Video = translate('OpenLP.Ui', 'Video')
self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
'than 3 characters long.</strong><br><br>Please try again with '
'a longer search.')
self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
'Please use the Import Wizard to install one or more Bibles.')
book_chapter = translate('OpenLP.Ui', 'Book Chapter')
chapter = translate('OpenLP.Ui', 'Chapter')
verse = translate('OpenLP.Ui', 'Verse')

View File

@ -408,6 +408,12 @@ class BibleImportForm(OpenLPWizard):
self.permissions_edit = QtWidgets.QLineEdit(self.license_details_page)
self.permissions_edit.setObjectName('PermissionsEdit')
self.license_details_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.permissions_edit)
self.full_license_label = QtWidgets.QLabel(self.license_details_page)
self.full_license_label.setObjectName('FullLicenseLabel')
self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.full_license_label)
self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_page)
self.full_license_edit.setObjectName('FullLicenseEdit')
self.license_details_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.full_license_edit)
self.addPage(self.license_details_page)
def retranslateUi(self):
@ -480,6 +486,7 @@ class BibleImportForm(OpenLPWizard):
self.version_name_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
self.copyright_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
self.permissions_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
self.full_license_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Full license:'))
self.progress_page.setTitle(WizardStrings.Importing)
self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
'Please wait while your Bible is imported.'))
@ -504,6 +511,7 @@ class BibleImportForm(OpenLPWizard):
elif self.currentPage() == self.select_page:
self.version_name_edit.clear()
self.permissions_edit.clear()
self.full_license_edit.clear()
self.copyright_edit.clear()
if self.field('source_format') == BibleFormat.OSIS:
if not self.field('osis_location'):
@ -763,6 +771,7 @@ class BibleImportForm(OpenLPWizard):
self.license_details_page.registerField('license_version', self.version_name_edit)
self.license_details_page.registerField('license_copyright', self.copyright_edit)
self.license_details_page.registerField('license_permissions', self.permissions_edit)
self.license_details_page.registerField("license_full_license", self.full_license_edit, 'plainText')
def set_defaults(self):
"""
@ -787,8 +796,13 @@ class BibleImportForm(OpenLPWizard):
self.setField('proxy_username', settings.value('proxy username'))
self.setField('proxy_password', settings.value('proxy password'))
self.setField('license_version', self.version_name_edit.text())
self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.setField('license_copyright', self.copyright_edit.text())
self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.setField('license_permissions', self.permissions_edit.text())
self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
self.setField('license_full_license', self.full_license_edit.toPlainText())
self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk)
settings.endGroup()
@ -812,6 +826,7 @@ class BibleImportForm(OpenLPWizard):
license_version = self.field('license_version')
license_copyright = self.field('license_copyright')
license_permissions = self.field('license_permissions')
license_full_license = self.field('license_full_license')
importer = None
if bible_type == BibleFormat.OSIS:
# Import an OSIS bible.
@ -861,10 +876,10 @@ class BibleImportForm(OpenLPWizard):
sword_path=self.field('sword_zip_path'),
sword_key=self.sword_zipbible_combo_box.itemData(
self.sword_zipbible_combo_box.currentIndex()))
try:
if importer.do_import(license_version) and not importer.stop_import_flag:
self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions)
self.manager.save_meta_data(license_version, license_version,
license_copyright, license_permissions, license_full_license)
self.manager.reload_bibles()
if bible_type == BibleFormat.WebDownload:
self.progress_label.setText(

View File

@ -68,6 +68,12 @@ class Ui_EditBibleDialog(object):
self.permissions_edit.setObjectName('permissions_edit')
self.permissions_label.setBuddy(self.permissions_edit)
self.license_details_layout.addRow(self.permissions_label, self.permissions_edit)
self.full_license_label = QtWidgets.QLabel(self.license_details_group_box)
self.full_license_label.setObjectName('full_license_label')
self.full_license_edit = QtWidgets.QPlainTextEdit(self.license_details_group_box)
self.full_license_edit.setObjectName('full_license_edit')
self.full_license_label.setBuddy(self.full_license_edit)
self.license_details_layout.addRow(self.full_license_label, self.full_license_edit)
self.meta_tab_layout.addWidget(self.license_details_group_box)
self.language_selection_group_box = QtWidgets.QGroupBox(self.meta_tab)
self.language_selection_group_box.setObjectName('language_selection_group_box')
@ -132,6 +138,7 @@ class Ui_EditBibleDialog(object):
self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
self.full_license_label.setText(translate('BiblesPlugin.EditBibleForm', 'Full license:'))
self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
self.language_selection_label.setText(
translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and '

View File

@ -61,10 +61,28 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
"""
log.debug('Load Bible')
self.bible = bible
self.version_name_edit.setText(self.manager.get_meta_data(self.bible, 'name').value)
self.copyright_edit.setText(self.manager.get_meta_data(self.bible, 'copyright').value)
self.permissions_edit.setText(self.manager.get_meta_data(self.bible, 'permissions').value)
book_name_language = self.manager.get_meta_data(self.bible, 'book_name_language')
"""
Try loading the metadata, if the field does not exist in the metadata, continue executing the code,
missing fields will be created on "self.accept" (save).
"""
meta = self.manager.get_meta_data(self.bible, 'name')
copyright = self.manager.get_meta_data(self.bible, 'copyright')
permission = self.manager.get_meta_data(self.bible, 'permissions')
full_license = self.manager.get_meta_data(self.bible, 'full_license')
if meta:
self.version_name_edit.setText(meta.value)
if copyright:
self.copyright_edit.setText(copyright.value)
if permission:
self.permissions_edit.setText(permission.value)
if full_license:
self.full_license_edit.setPlainText(full_license.value)
# Set placeholder texts for the fields.
self.version_name_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.copyright_edit.setPlaceholderText(UiStrings().RequiredShowInFooter)
self.permissions_edit.setPlaceholderText(UiStrings().OptionalShowInFooter)
self.full_license_edit.setPlaceholderText(UiStrings().OptionalHideInFooter)
if book_name_language and book_name_language.value != 'None':
self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1)
self.books = {}
@ -107,6 +125,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
version = self.version_name_edit.text()
copyright = self.copyright_edit.text()
permissions = self.permissions_edit.text()
full_license = self.full_license_edit.toPlainText()
book_name_language = self.language_selection_combo_box.currentIndex() - 1
if book_name_language == -1:
book_name_language = None
@ -121,7 +140,7 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
if not self.validate_book(custom_names[abbr], abbr):
return
self.application.set_busy_cursor()
self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language)
self.manager.save_meta_data(self.bible, version, copyright, permissions, full_license, book_name_language)
if not self.web_bible:
for abbr, book in self.books.items():
if book:

View File

@ -380,17 +380,17 @@ class BibleManager(OpenLPMixin, RegistryProperties):
else:
return None
def save_meta_data(self, bible, version, copyright, permissions, book_name_language=None):
def save_meta_data(self, bible, version, copyright, permissions, full_license, book_name_language=None):
"""
Saves the bibles meta data.
"""
log.debug('save_meta data {bible}, {version}, {copyright}, {perms}'.format(bible=bible,
version=version,
copyright=copyright,
perms=permissions))
log.debug('save_meta data {bible}, {version}, {copyright},'
' {perms}, {full_license}'.format(bible=bible, version=version, copyright=copyright,
perms=permissions, full_license=full_license))
self.db_cache[bible].save_meta('name', version)
self.db_cache[bible].save_meta('copyright', copyright)
self.db_cache[bible].save_meta('permissions', permissions)
self.db_cache[bible].save_meta('full_license', full_license)
self.db_cache[bible].save_meta('book_name_language', book_name_language)
def get_meta_data(self, bible, key):

View File

@ -126,6 +126,7 @@ class SongMediaItem(MediaManagerItem):
self.update_service_on_edit = Settings().value(self.settings_section + '/update service on edit')
self.add_song_from_service = Settings().value(self.settings_section + '/add song from service')
self.display_songbook = Settings().value(self.settings_section + '/display songbook')
self.display_written_by_text = Settings().value(self.settings_section + '/display written by')
self.display_copyright_symbol = Settings().value(self.settings_section + '/display copyright symbol')
def retranslateUi(self):
@ -640,8 +641,12 @@ class SongMediaItem(MediaManagerItem):
item.raw_footer = []
item.raw_footer.append(song.title)
if authors_none:
item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
authors=create_separated_list(authors_none)))
# If the setting for showing "Written by:" is enabled, show it before unspecified authors.
if Settings().value('songs/display written by'):
item.raw_footer.append("{text}: {authors}".format(text=translate('OpenLP.Ui', 'Written by'),
authors=create_separated_list(authors_none)))
else:
item.raw_footer.append("{authors}".format(authors=create_separated_list(authors_none)))
if authors_words_music:
item.raw_footer.append("{text}: {authors}".format(text=AuthorType.Types[AuthorType.WordsAndMusic],
authors=create_separated_list(authors_words_music)))

View File

@ -53,6 +53,9 @@ class SongsTab(SettingsTab):
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)
self.display_written_by_check_box = QtWidgets.QCheckBox(self.mode_group_box)
self.display_written_by_check_box.setObjectName('written_by_check_box')
self.mode_layout.addWidget(self.display_written_by_check_box)
self.display_copyright_check_box = QtWidgets.QCheckBox(self.mode_group_box)
self.display_copyright_check_box.setObjectName('copyright_check_box')
self.mode_layout.addWidget(self.display_copyright_check_box)
@ -63,16 +66,19 @@ class SongsTab(SettingsTab):
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.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)
def retranslateUi(self):
self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Songs Mode'))
self.mode_group_box.setTitle(translate('SongsPlugin.SongsTab', 'Song related settings'))
self.tool_bar_active_check_box.setText(translate('SongsPlugin.SongsTab',
'Enable "Go to verse" button in Live panel'))
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.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'))
self.display_copyright_check_box.setText(translate('SongsPlugin.SongsTab',
'Display "{symbol}" symbol before copyright '
'info').format(symbol=SongStrings.CopyrightSymbol))
@ -92,6 +98,9 @@ class SongsTab(SettingsTab):
def on_songbook_check_box_changed(self, check_state):
self.display_songbook = (check_state == QtCore.Qt.Checked)
def on_written_by_check_box_changed(self, check_state):
self.display_written_by = (check_state == QtCore.Qt.Checked)
def on_copyright_check_box_changed(self, check_state):
self.display_copyright_symbol = (check_state == QtCore.Qt.Checked)
@ -102,11 +111,13 @@ class SongsTab(SettingsTab):
self.update_edit = settings.value('update service on edit')
self.update_load = settings.value('add song from service')
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')
self.tool_bar_active_check_box.setChecked(self.tool_bar)
self.update_on_edit_check_box.setChecked(self.update_edit)
self.add_from_service_check_box.setChecked(self.update_load)
self.display_songbook_check_box.setChecked(self.display_songbook)
self.display_written_by_check_box.setChecked(self.display_written_by)
self.display_copyright_check_box.setChecked(self.display_copyright_symbol)
settings.endGroup()
@ -117,6 +128,7 @@ class SongsTab(SettingsTab):
settings.setValue('update service on edit', self.update_edit)
settings.setValue('add song from service', self.update_load)
settings.setValue('display songbook', self.display_songbook)
settings.setValue('display written by', self.display_written_by)
settings.setValue('display copyright symbol', self.display_copyright_symbol)
settings.endGroup()
if self.tab_visited:

View File

@ -60,6 +60,7 @@ __default_settings__ = {
'songs/add song from service': True,
'songs/display songbar': True,
'songs/display songbook': False,
'songs/display written by': True,
'songs/display copyright symbol': False,
'songs/last directory import': '',
'songs/last directory export': '',

View File

@ -295,11 +295,18 @@ class TestMediaItem(TestCase, TestMixin):
mock_qlist_widget.setData.assert_called_once_with(MockedUserRole, mock_song.id)
self.media_item.list_view.addItem.assert_called_once_with(mock_qlist_widget)
def test_build_song_footer_one_author(self):
@patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
def test_build_song_footer_one_author_show_written_by(self, MockedSettings):
"""
Test build songs footer with basic song and one author
"""
# GIVEN: A Song and a Service Item
# GIVEN: A Song and a Service Item, mocked settings: True for 'songs/display written by'
# and False for 'core/ccli number' (ccli will cause traceback if true)
mocked_settings = MagicMock()
mocked_settings.value.side_effect = [True, False]
MockedSettings.return_value = mocked_settings
mock_song = MagicMock()
mock_song.title = 'My Song'
mock_song.authors_songs = []
@ -320,6 +327,39 @@ class TestMediaItem(TestCase, TestMixin):
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')
@patch(u'openlp.plugins.songs.lib.mediaitem.Settings')
def test_build_song_footer_one_author_hide_written_by(self, MockedSettings):
"""
Test build songs footer with basic song and one author
"""
# GIVEN: A Song and a Service Item, mocked settings: False for 'songs/display written by'
# and False for 'core/ccli number' (ccli will cause traceback if true)
mocked_settings = MagicMock()
mocked_settings.value.side_effect = [False, False]
MockedSettings.return_value = mocked_settings
mock_song = MagicMock()
mock_song.title = 'My Song'
mock_song.authors_songs = []
mock_author = MagicMock()
mock_author.display_name = 'my author'
mock_author_song = MagicMock()
mock_author_song.author = mock_author
mock_song.authors_songs.append(mock_author_song)
mock_song.copyright = 'My copyright'
service_item = ServiceItem(None)
# WHEN: I generate the Footer with default settings
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', 'my author', 'My copyright'],
'The array should be returned correctly with a song, one author and copyright,'
'text Written by should not be part of the text.')
self.assertEqual(author_list, ['my author'],
'The author list should be returned correctly with one author')
def test_build_song_footer_two_authors(self):
"""
Test build songs footer with basic song and two authors