forked from openlp/openlp
Add a Checkbox at the Bibles settings tab to show or hide the verse numbers
bzr-revno: 2299
This commit is contained in:
commit
f4ab0b23b8
@ -48,6 +48,7 @@ __default_settings__ = {
|
|||||||
'bibles/verse layout style': LayoutStyle.VersePerSlide,
|
'bibles/verse layout style': LayoutStyle.VersePerSlide,
|
||||||
'bibles/book name language': LanguageSelection.Bible,
|
'bibles/book name language': LanguageSelection.Bible,
|
||||||
'bibles/display brackets': DisplayStyle.NoBrackets,
|
'bibles/display brackets': DisplayStyle.NoBrackets,
|
||||||
|
'bibles/is verse number visible': True,
|
||||||
'bibles/display new chapter': False,
|
'bibles/display new chapter': False,
|
||||||
'bibles/second bibles': True,
|
'bibles/second bibles': True,
|
||||||
'bibles/advanced bible': '',
|
'bibles/advanced bible': '',
|
||||||
|
@ -58,6 +58,9 @@ class BiblesTab(SettingsTab):
|
|||||||
self.verse_display_group_box.setObjectName('verse_display_group_box')
|
self.verse_display_group_box.setObjectName('verse_display_group_box')
|
||||||
self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box)
|
self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box)
|
||||||
self.verse_display_layout.setObjectName('verse_display_layout')
|
self.verse_display_layout.setObjectName('verse_display_layout')
|
||||||
|
self.is_verse_number_visible_check_box = QtGui.QCheckBox(self.verse_display_group_box)
|
||||||
|
self.is_verse_number_visible_check_box.setObjectName('is_verse_number_visible_check_box')
|
||||||
|
self.verse_display_layout.addRow(self.is_verse_number_visible_check_box)
|
||||||
self.new_chapters_check_box = QtGui.QCheckBox(self.verse_display_group_box)
|
self.new_chapters_check_box = QtGui.QCheckBox(self.verse_display_group_box)
|
||||||
self.new_chapters_check_box.setObjectName('new_chapters_check_box')
|
self.new_chapters_check_box.setObjectName('new_chapters_check_box')
|
||||||
self.verse_display_layout.addRow(self.new_chapters_check_box)
|
self.verse_display_layout.addRow(self.new_chapters_check_box)
|
||||||
@ -134,6 +137,7 @@ class BiblesTab(SettingsTab):
|
|||||||
self.left_layout.addStretch()
|
self.left_layout.addStretch()
|
||||||
self.right_layout.addStretch()
|
self.right_layout.addStretch()
|
||||||
# Signals and slots
|
# Signals and slots
|
||||||
|
self.is_verse_number_visible_check_box.stateChanged.connect(self.on_is_verse_number_visible_check_box_changed)
|
||||||
self.new_chapters_check_box.stateChanged.connect(self.on_new_chapters_check_box_changed)
|
self.new_chapters_check_box.stateChanged.connect(self.on_new_chapters_check_box_changed)
|
||||||
self.display_style_combo_box.activated.connect(self.on_display_style_combo_box_changed)
|
self.display_style_combo_box.activated.connect(self.on_display_style_combo_box_changed)
|
||||||
self.bible_theme_combo_box.activated.connect(self.on_bible_theme_combo_box_changed)
|
self.bible_theme_combo_box.activated.connect(self.on_bible_theme_combo_box_changed)
|
||||||
@ -156,6 +160,7 @@ class BiblesTab(SettingsTab):
|
|||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display'))
|
self.verse_display_group_box.setTitle(translate('BiblesPlugin.BiblesTab', 'Verse Display'))
|
||||||
|
self.is_verse_number_visible_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Show verse numbers'))
|
||||||
self.new_chapters_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers'))
|
self.new_chapters_check_box.setText(translate('BiblesPlugin.BiblesTab', 'Only show new chapter numbers'))
|
||||||
self.layout_style_label.setText(UiStrings().LayoutStyle)
|
self.layout_style_label.setText(UiStrings().LayoutStyle)
|
||||||
self.display_style_label.setText(UiStrings().DisplayStyle)
|
self.display_style_label.setText(UiStrings().DisplayStyle)
|
||||||
@ -208,6 +213,13 @@ class BiblesTab(SettingsTab):
|
|||||||
def on_language_selection_combo_box_changed(self):
|
def on_language_selection_combo_box_changed(self):
|
||||||
self.language_selection = self.language_selection_combo_box.currentIndex()
|
self.language_selection = self.language_selection_combo_box.currentIndex()
|
||||||
|
|
||||||
|
def on_is_verse_number_visible_check_box_changed(self, check_state):
|
||||||
|
"""
|
||||||
|
Event handler for the 'verse number visible' check box
|
||||||
|
"""
|
||||||
|
self.is_verse_number_visible = (check_state == QtCore.Qt.Checked)
|
||||||
|
self.check_is_verse_number_visible()
|
||||||
|
|
||||||
def on_new_chapters_check_box_changed(self, check_state):
|
def on_new_chapters_check_box_changed(self, check_state):
|
||||||
self.show_new_chapters = False
|
self.show_new_chapters = False
|
||||||
# We have a set value convert to True/False.
|
# We have a set value convert to True/False.
|
||||||
@ -299,11 +311,14 @@ class BiblesTab(SettingsTab):
|
|||||||
def load(self):
|
def load(self):
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
settings.beginGroup(self.settings_section)
|
settings.beginGroup(self.settings_section)
|
||||||
|
self.is_verse_number_visible = settings.value('is verse number visible')
|
||||||
self.show_new_chapters = settings.value('display new chapter')
|
self.show_new_chapters = settings.value('display new chapter')
|
||||||
self.display_style = settings.value('display brackets')
|
self.display_style = settings.value('display brackets')
|
||||||
self.layout_style = settings.value('verse layout style')
|
self.layout_style = settings.value('verse layout style')
|
||||||
self.bible_theme = settings.value('bible theme')
|
self.bible_theme = settings.value('bible theme')
|
||||||
self.second_bibles = settings.value('second bibles')
|
self.second_bibles = settings.value('second bibles')
|
||||||
|
self.is_verse_number_visible_check_box.setChecked(self.is_verse_number_visible)
|
||||||
|
self.check_is_verse_number_visible()
|
||||||
self.new_chapters_check_box.setChecked(self.show_new_chapters)
|
self.new_chapters_check_box.setChecked(self.show_new_chapters)
|
||||||
self.display_style_combo_box.setCurrentIndex(self.display_style)
|
self.display_style_combo_box.setCurrentIndex(self.display_style)
|
||||||
self.layout_style_combo_box.setCurrentIndex(self.layout_style)
|
self.layout_style_combo_box.setCurrentIndex(self.layout_style)
|
||||||
@ -351,6 +366,7 @@ class BiblesTab(SettingsTab):
|
|||||||
def save(self):
|
def save(self):
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
settings.beginGroup(self.settings_section)
|
settings.beginGroup(self.settings_section)
|
||||||
|
settings.setValue('is verse number visible', self.is_verse_number_visible)
|
||||||
settings.setValue('display new chapter', self.show_new_chapters)
|
settings.setValue('display new chapter', self.show_new_chapters)
|
||||||
settings.setValue('display brackets', self.display_style)
|
settings.setValue('display brackets', self.display_style)
|
||||||
settings.setValue('verse layout style', self.layout_style)
|
settings.setValue('verse layout style', self.layout_style)
|
||||||
@ -405,3 +421,12 @@ class BiblesTab(SettingsTab):
|
|||||||
color.setAlpha(128)
|
color.setAlpha(128)
|
||||||
palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color)
|
palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color)
|
||||||
return palette
|
return palette
|
||||||
|
|
||||||
|
def check_is_verse_number_visible(self):
|
||||||
|
"""
|
||||||
|
Enables / Disables verse settings dependent on is_verse_number_visible
|
||||||
|
"""
|
||||||
|
self.new_chapters_check_box.setEnabled(self.is_verse_number_visible)
|
||||||
|
self.display_style_label.setEnabled(self.is_verse_number_visible)
|
||||||
|
self.display_style_combo_box.setEnabled(self.is_verse_number_visible)
|
||||||
|
|
||||||
|
@ -803,20 +803,20 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
verses.add(book, chapter, verse, version, copyright, permissions)
|
verses.add(book, chapter, verse, version, copyright, permissions)
|
||||||
verse_text = self.formatVerse(old_chapter, chapter, verse)
|
verse_text = self.formatVerse(old_chapter, chapter, verse)
|
||||||
if second_bible:
|
if second_bible:
|
||||||
bible_text = '%s %s\n\n%s %s' % (verse_text, text, verse_text, second_text)
|
bible_text = '%s%s\n\n%s %s' % (verse_text, text, verse_text, second_text)
|
||||||
raw_slides.append(bible_text.rstrip())
|
raw_slides.append(bible_text.rstrip())
|
||||||
bible_text = ''
|
bible_text = ''
|
||||||
# If we are 'Verse Per Slide' then create a new slide.
|
# If we are 'Verse Per Slide' then create a new slide.
|
||||||
elif self.settings.layout_style == LayoutStyle.VersePerSlide:
|
elif self.settings.layout_style == LayoutStyle.VersePerSlide:
|
||||||
bible_text = '%s %s' % (verse_text, text)
|
bible_text = '%s%s' % (verse_text, text)
|
||||||
raw_slides.append(bible_text.rstrip())
|
raw_slides.append(bible_text.rstrip())
|
||||||
bible_text = ''
|
bible_text = ''
|
||||||
# If we are 'Verse Per Line' then force a new line.
|
# If we are 'Verse Per Line' then force a new line.
|
||||||
elif self.settings.layout_style == LayoutStyle.VersePerLine:
|
elif self.settings.layout_style == LayoutStyle.VersePerLine:
|
||||||
bible_text = '%s%s %s\n' % (bible_text, verse_text, text)
|
bible_text = '%s%s%s\n' % (bible_text, verse_text, text)
|
||||||
# We have to be 'Continuous'.
|
# We have to be 'Continuous'.
|
||||||
else:
|
else:
|
||||||
bible_text = '%s %s %s\n' % (bible_text, verse_text, text)
|
bible_text = '%s %s%s\n' % (bible_text, verse_text, text)
|
||||||
bible_text = bible_text.strip(' ')
|
bible_text = bible_text.strip(' ')
|
||||||
if not old_item:
|
if not old_item:
|
||||||
start_item = bitem
|
start_item = bitem
|
||||||
@ -943,17 +943,19 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
The verse number (int).
|
The verse number (int).
|
||||||
"""
|
"""
|
||||||
verse_separator = get_reference_separator('sep_v_display')
|
verse_separator = get_reference_separator('sep_v_display')
|
||||||
|
if not self.settings.is_verse_number_visible:
|
||||||
|
return ''
|
||||||
if not self.settings.show_new_chapters or old_chapter != chapter:
|
if not self.settings.show_new_chapters or old_chapter != chapter:
|
||||||
verse_text = str(chapter) + verse_separator + str(verse)
|
verse_text = str(chapter) + verse_separator + str(verse)
|
||||||
else:
|
else:
|
||||||
verse_text = str(verse)
|
verse_text = str(verse)
|
||||||
if self.settings.display_style == DisplayStyle.Round:
|
if self.settings.display_style == DisplayStyle.Round:
|
||||||
return '{su}(%s){/su}' % verse_text
|
return '{su}(%s){/su} ' % verse_text
|
||||||
if self.settings.display_style == DisplayStyle.Curly:
|
if self.settings.display_style == DisplayStyle.Curly:
|
||||||
return '{su}{%s}{/su}' % verse_text
|
return '{su}{%s}{/su} ' % verse_text
|
||||||
if self.settings.display_style == DisplayStyle.Square:
|
if self.settings.display_style == DisplayStyle.Square:
|
||||||
return '{su}[%s]{/su}' % verse_text
|
return '{su}[%s]{/su} ' % verse_text
|
||||||
return '{su}%s{/su}' % verse_text
|
return '{su}%s{/su} ' % verse_text
|
||||||
|
|
||||||
def search(self, string, showError):
|
def search(self, string, showError):
|
||||||
"""
|
"""
|
||||||
|
@ -0,0 +1,116 @@
|
|||||||
|
"""
|
||||||
|
This module contains tests for the versereferencelist submodule of the Bibles plugin.
|
||||||
|
"""
|
||||||
|
from unittest import TestCase
|
||||||
|
from openlp.plugins.bibles.lib.versereferencelist import VerseReferenceList
|
||||||
|
|
||||||
|
class TestVerseReferenceList(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
"""
|
||||||
|
Initializes all we need
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_first_verse_test(self):
|
||||||
|
"""
|
||||||
|
Test the addition of a verse to the empty list
|
||||||
|
"""
|
||||||
|
# GIVEN: an empty list
|
||||||
|
reference_list = VerseReferenceList()
|
||||||
|
book = 'testBook'
|
||||||
|
chapter = 1
|
||||||
|
verse = 1
|
||||||
|
version = 'testVersion'
|
||||||
|
copyright = 'testCopyright'
|
||||||
|
permission = 'testPermision'
|
||||||
|
|
||||||
|
# WHEN: We add it to the verse list
|
||||||
|
reference_list.add(book, chapter, verse, version, copyright, permission)
|
||||||
|
|
||||||
|
# THEN: The entries should be in the first entry of the list
|
||||||
|
self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
|
||||||
|
self.assertEqual(reference_list.verse_list[0]['book'], book, 'The book in first entry should be %s' % book)
|
||||||
|
self.assertEqual(reference_list.verse_list[0]['chapter'], chapter, 'The chapter in first entry should be %u' % chapter)
|
||||||
|
self.assertEqual(reference_list.verse_list[0]['start'], verse, 'The start in first entry should be %u' % verse)
|
||||||
|
self.assertEqual(reference_list.verse_list[0]['version'], version, 'The version in first entry should be %s' % version)
|
||||||
|
self.assertEqual(reference_list.verse_list[0]['end'], verse, 'The end in first entry should be %u' % verse)
|
||||||
|
|
||||||
|
def add_next_verse_test(self):
|
||||||
|
"""
|
||||||
|
Test the addition of the following verse
|
||||||
|
"""
|
||||||
|
# GIVEN: 1 line in the list of verses
|
||||||
|
book = 'testBook'
|
||||||
|
chapter = 1
|
||||||
|
verse = 1
|
||||||
|
next_verse = 2
|
||||||
|
version = 'testVersion'
|
||||||
|
copyright = 'testCopyright'
|
||||||
|
permission = 'testPermision'
|
||||||
|
reference_list = VerseReferenceList()
|
||||||
|
reference_list.add(book, chapter, verse, version, copyright, permission)
|
||||||
|
|
||||||
|
# WHEN: We add the following verse to the verse list
|
||||||
|
reference_list.add(book, chapter, next_verse, version, copyright, permission)
|
||||||
|
|
||||||
|
# THEN: The current index should be 0 and the end pointer of the entry should be '2'
|
||||||
|
self.assertEqual(reference_list.current_index, 0, 'The current index should be 0')
|
||||||
|
self.assertEqual(reference_list.verse_list[0]['end'], next_verse, 'The end in first entry should be %u' % next_verse)
|
||||||
|
|
||||||
|
def add_another_verse_test(self):
|
||||||
|
"""
|
||||||
|
Test the addition of a verse in another book
|
||||||
|
"""
|
||||||
|
# GIVEN: 1 line in the list of verses
|
||||||
|
book = 'testBook'
|
||||||
|
chapter = 1
|
||||||
|
verse = 1
|
||||||
|
next_verse = 2
|
||||||
|
another_book = 'testBook2'
|
||||||
|
another_chapter = 2
|
||||||
|
another_verse = 5
|
||||||
|
version = 'testVersion'
|
||||||
|
copyright = 'testCopyright'
|
||||||
|
permission = 'testPermision'
|
||||||
|
reference_list = VerseReferenceList()
|
||||||
|
reference_list.add(book, chapter, verse, version, copyright, permission)
|
||||||
|
|
||||||
|
# WHEN: We add a verse of another book to the verse list
|
||||||
|
reference_list.add(another_book, another_chapter, another_verse, version, copyright, permission)
|
||||||
|
|
||||||
|
# THEN: the current index should be 1
|
||||||
|
self.assertEqual(reference_list.current_index, 1, 'The current index should be 1')
|
||||||
|
|
||||||
|
def add_version_test(self):
|
||||||
|
"""
|
||||||
|
Test the addition of a version to the list
|
||||||
|
"""
|
||||||
|
# GIVEN: version, copyright and permission
|
||||||
|
reference_list = VerseReferenceList()
|
||||||
|
version = 'testVersion'
|
||||||
|
copyright = 'testCopyright'
|
||||||
|
permission = 'testPermision'
|
||||||
|
|
||||||
|
# WHEN: a not existing version will be added
|
||||||
|
reference_list.add_version(version, copyright, permission)
|
||||||
|
|
||||||
|
# THEN: the data will be appended to the list
|
||||||
|
self.assertEqual(len(reference_list.version_list), 1, 'The version data should be appended')
|
||||||
|
self.assertEqual(reference_list.version_list[0], {'version': version, 'copyright': copyright, 'permission': permission},
|
||||||
|
'The version data should be appended')
|
||||||
|
|
||||||
|
def add_existing_version_test(self):
|
||||||
|
"""
|
||||||
|
Test the addition of an existing version to the list
|
||||||
|
"""
|
||||||
|
# GIVEN: version, copyright and permission, added to the version list
|
||||||
|
reference_list = VerseReferenceList()
|
||||||
|
version = 'testVersion'
|
||||||
|
copyright = 'testCopyright'
|
||||||
|
permission = 'testPermision'
|
||||||
|
reference_list.add_version(version, copyright, permission)
|
||||||
|
|
||||||
|
# WHEN: an existing version will be added
|
||||||
|
reference_list.add_version(version, copyright, permission)
|
||||||
|
|
||||||
|
# THEN: the data will not be appended to the list
|
||||||
|
self.assertEqual(len(reference_list.version_list), 1, 'The version data should not be appended')
|
Loading…
Reference in New Issue
Block a user