openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #14984
[Merge] lp:~m2j/openlp/bug-959116 into lp:openlp
Meinert Jordan has proposed merging lp:~m2j/openlp/bug-959116 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~m2j/openlp/bug-959116/+merge/100422
Bug #959116: Split slide button inserts tag on its own line
--
https://code.launchpad.net/~m2j/openlp/bug-959116/+merge/100422
Your team OpenLP Core is requested to review the proposed merge of lp:~m2j/openlp/bug-959116 into lp:openlp.
=== modified file 'openlp/plugins/custom/forms/editcustomslideform.py'
--- openlp/plugins/custom/forms/editcustomslideform.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/custom/forms/editcustomslideform.py 2012-04-02 14:26:20 +0000
@@ -72,16 +72,25 @@
"""
Adds a slide split at the cursor.
"""
- if self.slideTextEdit.textCursor().columnNumber() != 0:
- self.slideTextEdit.insertPlainText(u'\n')
- self.slideTextEdit.insertPlainText(u'[===]\n')
+ self.insertSingleLineTextAtCursor(u'[===]')
self.slideTextEdit.setFocus()
def onSplitButtonPressed(self):
"""
Adds a virtual split at cursor.
"""
- if self.slideTextEdit.textCursor().columnNumber() != 0:
- self.slideTextEdit.insertPlainText(u'\n')
- self.slideTextEdit.insertPlainText(u'[---]')
+ self.insertSingleLineTextAtCursor(u'[---]')
self.slideTextEdit.setFocus()
+
+ def insertSingleLineTextAtCursor(self, text):
+ """
+ Adds ``text`` in a single line at the cursor position.
+ """
+ full_text = self.slideTextEdit.toPlainText()
+ position = self.slideTextEdit.textCursor().position()
+ if position and full_text[position-1] != u'\n':
+ text = u'\n' + text
+ if position == len(full_text) or full_text[position] != u'\n':
+ text += u'\n'
+ self.slideTextEdit.insertPlainText(text)
+
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/forms/editverseform.py 2012-04-02 14:26:20 +0000
@@ -75,10 +75,14 @@
self.verseTextEdit.setFocus()
def onSplitButtonClicked(self):
- verse_type_index = self.verseTypeComboBox.currentIndex()
- if self.verseTextEdit.textCursor().columnNumber() != 0:
- self.verseTextEdit.insertPlainText(u'\n')
- self.verseTextEdit.insertPlainText(u'[---]')
+ text = self.verseTextEdit.toPlainText()
+ position = self.verseTextEdit.textCursor().position()
+ insert_string = u'[---]'
+ if position and text[position-1] != u'\n':
+ insert_string = u'\n' + insert_string
+ if position == len(text) or text[position] != u'\n':
+ insert_string += u'\n'
+ self.verseTextEdit.insertPlainText(insert_string)
self.verseTextEdit.setFocus()
def onInsertButtonClicked(self):
@@ -113,8 +117,7 @@
verse_num = int(match.group(2))
except ValueError:
verse_num = 1
- verse_type_index = VerseType.from_loose_input(verse_tag, None)
- if verse_type_index is not None:
+ if VerseType.from_loose_input(verse_tag, False):
self.verseNumberBox.setValue(verse_num)
def onCursorPositionChanged(self):
Follow ups