forked from openlp/openlp
Refactored validation of edit all form so that it does not crash on empty textedit, and so that it does not allow empty verses.
Ideally we would accept empty verses, but these are removed automatically else where. Changed the save button to OK as per the reasons in my email.
This commit is contained in:
parent
d41f69ce8c
commit
33510c3346
@ -66,7 +66,7 @@ class Ui_EditVerseDialog(object):
|
|||||||
self.verseTypeLayout.addStretch()
|
self.verseTypeLayout.addStretch()
|
||||||
self.dialogLayout.addLayout(self.verseTypeLayout)
|
self.dialogLayout.addLayout(self.verseTypeLayout)
|
||||||
self.buttonBox = create_button_box(editVerseDialog, u'buttonBox',
|
self.buttonBox = create_button_box(editVerseDialog, u'buttonBox',
|
||||||
[u'cancel', u'save'])
|
[u'cancel', u'ok'])
|
||||||
self.dialogLayout.addWidget(self.buttonBox)
|
self.dialogLayout.addWidget(self.buttonBox)
|
||||||
self.retranslateUi(editVerseDialog)
|
self.retranslateUi(editVerseDialog)
|
||||||
|
|
||||||
|
@ -188,21 +188,10 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||||||
def accept(self):
|
def accept(self):
|
||||||
value = unicode(self.getVerse()[0])
|
value = unicode(self.getVerse()[0])
|
||||||
if not self.hasSingleVerse:
|
if not self.hasSingleVerse:
|
||||||
value = value.split(u'\n')
|
value = not u'' in re.split(r'---\[[^\]]*\]---\n*', value)[1:]
|
||||||
if len(value) <= 1:
|
|
||||||
critical_error_message_box(
|
|
||||||
message=translate('SongsPlugin.EditSongForm',
|
|
||||||
'Invalid entry, you need a verse splitter and some text.'))
|
|
||||||
return False
|
|
||||||
if not value:
|
|
||||||
lines = unicode(self.getVerse()[0]).split(u'\n')
|
|
||||||
index = 2
|
|
||||||
while index < len(lines) and not value:
|
|
||||||
value = lines[index]
|
|
||||||
index += 1
|
|
||||||
if not value:
|
if not value:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
message=translate('SongsPlugin.EditSongForm',
|
message=translate('SongsPlugin.EditSongForm',
|
||||||
'You need to type some text in to the verse.'))
|
'You must enter text for each verse.'))
|
||||||
return False
|
return False
|
||||||
QtGui.QDialog.accept(self)
|
QtGui.QDialog.accept(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user