forked from openlp/openlp
Add forced dividers to songs
This commit is contained in:
parent
4183f186ce
commit
c8295eef11
@ -41,6 +41,10 @@ class Ui_EditVerseDialog(object):
|
||||
self.dialog_layout.addWidget(self.verse_text_edit)
|
||||
self.verse_type_layout = QtWidgets.QHBoxLayout()
|
||||
self.verse_type_layout.setObjectName('verse_type_layout')
|
||||
self.force_split_button = QtWidgets.QPushButton(edit_verse_dialog)
|
||||
self.force_split_button.setIcon(build_icon(':/general/general_add.png'))
|
||||
self.force_split_button.setObjectName('force_split_button')
|
||||
self.verse_type_layout.addWidget(self.force_split_button)
|
||||
self.split_button = QtWidgets.QPushButton(edit_verse_dialog)
|
||||
self.split_button.setIcon(build_icon(':/general/general_add.png'))
|
||||
self.split_button.setObjectName('split_button')
|
||||
@ -79,6 +83,9 @@ class Ui_EditVerseDialog(object):
|
||||
self.verse_type_combo_box.setItemText(VerseType.Other, VerseType.translated_names[VerseType.Other])
|
||||
self.split_button.setText(UiStrings().Split)
|
||||
self.split_button.setToolTip(UiStrings().SplitToolTip)
|
||||
self.force_split_button.setText(translate('SongsPlugin.EditVerseForm', '&Divide'))
|
||||
self.force_split_button.setToolTip(translate('SongsPlugin.EditVerseForm', 'Divide the verse when displayed '
|
||||
'regardless of the screen size.'))
|
||||
self.insert_button.setText(translate('SongsPlugin.EditVerseForm', '&Insert'))
|
||||
self.insert_button.setToolTip(translate('SongsPlugin.EditVerseForm',
|
||||
'Split a slide into two by inserting a verse splitter.'))
|
||||
|
@ -48,6 +48,7 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
|
||||
self.split_button.clicked.connect(self.on_split_button_clicked)
|
||||
self.verse_text_edit.cursorPositionChanged.connect(self.on_cursor_position_changed)
|
||||
self.verse_type_combo_box.currentIndexChanged.connect(self.on_verse_type_combo_box_changed)
|
||||
self.force_split_button.clicked.connect(self.on_force_split_button_clicked)
|
||||
|
||||
def insert_verse(self, verse_tag, verse_num=1):
|
||||
"""
|
||||
@ -76,6 +77,20 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog):
|
||||
self.verse_text_edit.insertPlainText(insert_string)
|
||||
self.verse_text_edit.setFocus()
|
||||
|
||||
def on_force_split_button_clicked(self):
|
||||
"""
|
||||
The force split button has been pressed so we need add the split
|
||||
"""
|
||||
text = self.verse_text_edit.toPlainText()
|
||||
position = self.verse_text_edit.textCursor().position()
|
||||
insert_string = '[##-divide-##]'
|
||||
if position and text[position - 1] != '\n':
|
||||
insert_string = '\n' + insert_string
|
||||
if position == len(text) or text[position] != '\n':
|
||||
insert_string += '\n'
|
||||
self.verse_text_edit.insertPlainText(insert_string)
|
||||
self.verse_text_edit.setFocus()
|
||||
|
||||
def on_insert_button_clicked(self):
|
||||
"""
|
||||
The insert button has been pressed
|
||||
|
@ -573,7 +573,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
if not song.verse_order.strip():
|
||||
for verse in verse_list:
|
||||
# We cannot use from_loose_input() here, because database is supposed to contain English lowercase
|
||||
# singlechar tags.
|
||||
# single char tags.
|
||||
verse_tag = verse[0]['type']
|
||||
verse_index = None
|
||||
if len(verse_tag) > 1:
|
||||
@ -584,7 +584,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
verse_index = VerseType.from_tag(verse_tag)
|
||||
verse_tag = VerseType.translated_tags[verse_index].upper()
|
||||
verse_def = '{tag}{label}'.format(tag=verse_tag, label=verse[0]['label'])
|
||||
service_item.add_from_text(str(verse[1]), verse_def)
|
||||
force_verse = verse[1].split('[##-divide-##]\n', 2)
|
||||
for split_verse in force_verse:
|
||||
service_item.add_from_text(split_verse, verse_def)
|
||||
else:
|
||||
# Loop through the verse list and expand the song accordingly.
|
||||
for order in song.verse_order.lower().split():
|
||||
@ -599,7 +601,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
verse_index = VerseType.from_tag(verse[0]['type'])
|
||||
verse_tag = VerseType.translated_tags[verse_index]
|
||||
verse_def = '{tag}{text}'.format(tag=verse_tag, text=verse[0]['label'])
|
||||
service_item.add_from_text(verse[1], verse_def)
|
||||
force_verse = verse[1].split('[##-divide-##]\n', 2)
|
||||
for split_verse in force_verse:
|
||||
service_item.add_from_text(split_verse, verse_def)
|
||||
service_item.title = song.title
|
||||
author_list = self.generate_footer(service_item, song)
|
||||
service_item.data_string = {'title': song.search_title, 'authors': ', '.join(author_list)}
|
||||
|
Loading…
Reference in New Issue
Block a user