openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #29550
[Merge] lp:~suutari-olli/openlp/force-split into lp:openlp
Azaziah has proposed merging lp:~suutari-olli/openlp/force-split into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~suutari-olli/openlp/force-split/+merge/294033
- Added "Split" button for Song editor:
This adds the currently selected Verses tag to
the given position, thus creating a "Force split"
- Increased Optional Split limit from < 5 to < 51
--
Your team OpenLP Core is requested to review the proposed merge of lp:~suutari-olli/openlp/force-split into lp:openlp.
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2016-01-23 12:38:08 +0000
+++ openlp/core/lib/renderer.py 2016-05-06 17:07:43 +0000
@@ -241,7 +241,7 @@
elif item.is_capable(ItemCapabilities.CanSoftBreak):
pages = []
if '[---]' in text:
- # Remove two or more option slide breaks next to each other (causing infinite loop).
+ # Remove two or more optional splits next to each other (causing infinite loop).
while '\n[---]\n[---]\n' in text:
text = text.replace('\n[---]\n[---]\n', '\n[---]\n')
while ' [---]' in text:
@@ -249,8 +249,8 @@
while '[---] ' in text:
text = text.replace('[---] ', '[---]')
count = 0
- # only loop 5 times as there will never be more than 5 incorrect logical splits on a single slide.
- while True and count < 5:
+ # only loop 50 times as there will never be more than 50 optional splits on a single slide.
+ while True and count < 51:
slides = text.split('\n[---]\n', 2)
# If there are (at least) two occurrences of [---] we use the first two slides (and neglect the last
# for now).
=== modified file 'openlp/plugins/songs/forms/editversedialog.py'
--- openlp/plugins/songs/forms/editversedialog.py 2015-12-31 22:46:06 +0000
+++ openlp/plugins/songs/forms/editversedialog.py 2016-05-06 17:07:43 +0000
@@ -44,6 +44,10 @@
self.split_button.setIcon(build_icon(':/general/general_add.png'))
self.split_button.setObjectName('split_button')
self.verse_type_layout.addWidget(self.split_button)
+ 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.verse_type_label = QtWidgets.QLabel(edit_verse_dialog)
self.verse_type_label.setObjectName('verse_type_label')
self.verse_type_layout.addWidget(self.verse_type_label)
@@ -78,6 +82,8 @@
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', '&Split'))
+ self.force_split_button.setToolTip(translate('SongsPlugin.EditVerseForm', 'Split the verse.'))
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.'))
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py 2016-01-09 16:26:14 +0000
+++ openlp/plugins/songs/forms/editverseform.py 2016-05-06 17:07:43 +0000
@@ -46,6 +46,7 @@
self.has_single_verse = False
self.insert_button.clicked.connect(self.on_insert_button_clicked)
self.split_button.clicked.connect(self.on_split_button_clicked)
+ self.force_split_button.clicked.connect(self.on_force_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)
@@ -64,7 +65,7 @@
def on_split_button_clicked(self):
"""
- The split button has been pressed
+ The (optional) split button has been pressed
"""
text = self.verse_text_edit.toPlainText()
position = self.verse_text_edit.textCursor().position()
@@ -76,6 +77,35 @@
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
+ Find the last used verse tag by using given position and regex.
+ Then insert the tag and create a new line if required.
+ """
+ position = self.verse_text_edit.textCursor().position()
+ text = self.verse_text_edit.toPlainText()
+ position = text.rfind('---[', 0, position)
+ # If no text is found, do nothing - this prevents tracebacks.
+ if position == -1:
+ return
+ text = text[position:]
+ position = text.find(']---')
+ if position == -1:
+ return
+ text = text[:position + 4]
+ match = re.match(('---\[.*\]---'), text)
+ insert_string = match.group()
+ # Reset text & position data for checking if new line is required or not.
+ text = self.verse_text_edit.toPlainText()
+ position = self.verse_text_edit.textCursor().position()
+ 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