forked from openlp/openlp
fixes
This commit is contained in:
parent
06033df8ad
commit
e310c20ccc
@ -36,7 +36,7 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB
|
|||||||
class Ui_EditBibleDialog(object):
|
class Ui_EditBibleDialog(object):
|
||||||
def setupUi(self, editBibleDialog):
|
def setupUi(self, editBibleDialog):
|
||||||
editBibleDialog.setObjectName(u'editBibleDialog')
|
editBibleDialog.setObjectName(u'editBibleDialog')
|
||||||
editBibleDialog.resize(600, 400)
|
editBibleDialog.resize(520, 400)
|
||||||
editBibleDialog.setWindowIcon(
|
editBibleDialog.setWindowIcon(
|
||||||
build_icon(u':/icon/openlp-logo-16x16.png'))
|
build_icon(u':/icon/openlp-logo-16x16.png'))
|
||||||
editBibleDialog.setModal(True)
|
editBibleDialog.setModal(True)
|
||||||
@ -103,6 +103,7 @@ class Ui_EditBibleDialog(object):
|
|||||||
self.bookNameTabLayout.setObjectName(u'bookNameTabLayout')
|
self.bookNameTabLayout.setObjectName(u'bookNameTabLayout')
|
||||||
self.bookNameNotice = QtGui.QLabel(self.bookNameTab)
|
self.bookNameNotice = QtGui.QLabel(self.bookNameTab)
|
||||||
self.bookNameNotice.setObjectName(u'bookNameNotice')
|
self.bookNameNotice.setObjectName(u'bookNameNotice')
|
||||||
|
self.bookNameNotice.setWordWrap(True)
|
||||||
self.bookNameTabLayout.addWidget(self.bookNameNotice)
|
self.bookNameTabLayout.addWidget(self.bookNameNotice)
|
||||||
self.scrollArea = QtGui.QScrollArea(self.bookNameTab)
|
self.scrollArea = QtGui.QScrollArea(self.bookNameTab)
|
||||||
self.scrollArea.setWidgetResizable(True)
|
self.scrollArea.setWidgetResizable(True)
|
||||||
@ -162,12 +163,12 @@ class Ui_EditBibleDialog(object):
|
|||||||
'Book name language in search field, search results and on '
|
'Book name language in search field, search results and on '
|
||||||
'display:'))
|
'display:'))
|
||||||
self.languageSelectionComboBox.setItemText(0,
|
self.languageSelectionComboBox.setItemText(0,
|
||||||
translate('BiblesPlugin.EditBibleForm', 'Global Settings'))
|
translate('BiblesPlugin.EditBibleForm', 'Global settings'))
|
||||||
self.languageSelectionComboBox.setItemText(LanguageSelection.Bible + 1,
|
self.languageSelectionComboBox.setItemText(LanguageSelection.Bible + 1,
|
||||||
translate('BiblesPlugin.EditBibleForm', 'Bible Language'))
|
translate('BiblesPlugin.EditBibleForm', 'Bible language'))
|
||||||
self.languageSelectionComboBox.setItemText(
|
self.languageSelectionComboBox.setItemText(
|
||||||
LanguageSelection.Application + 1,
|
LanguageSelection.Application + 1,
|
||||||
translate('BiblesPlugin.EditBibleForm', 'Application Language'))
|
translate('BiblesPlugin.EditBibleForm', 'Application language'))
|
||||||
self.languageSelectionComboBox.setItemText(
|
self.languageSelectionComboBox.setItemText(
|
||||||
LanguageSelection.English + 1,
|
LanguageSelection.English + 1,
|
||||||
translate('BiblesPlugin.EditBibleForm', 'English'))
|
translate('BiblesPlugin.EditBibleForm', 'English'))
|
||||||
|
@ -50,7 +50,6 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.mediaitem = mediaitem
|
self.mediaitem = mediaitem
|
||||||
self.validate_error = []
|
|
||||||
self.booknames = BibleStrings().Booknames
|
self.booknames = BibleStrings().Booknames
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.manager = manager
|
self.manager = manager
|
||||||
@ -80,13 +79,14 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
u'download source')
|
u'download source')
|
||||||
if self.webbible:
|
if self.webbible:
|
||||||
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
|
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
|
||||||
'This is a webbible.\nIt is not possible to customize the Book '
|
'This is a Web Download Bible.\nIt is not possible to '
|
||||||
'Names.'))
|
'customize the Book Names.'))
|
||||||
self.scrollArea.hide()
|
self.scrollArea.hide()
|
||||||
else:
|
else:
|
||||||
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
|
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
|
||||||
'To use the customized Book Names, choose the option "Bible '
|
'To use the customized book names, "Bible language" must be '
|
||||||
'language"\nin global settings or explicit for this Bible.'))
|
'selected on the Meta Data tab or, if "Global settings" is '
|
||||||
|
'selected, on the Bible page in Configure OpenLP.'))
|
||||||
for book in BiblesResourcesDB.get_books():
|
for book in BiblesResourcesDB.get_books():
|
||||||
self.books[book[u'abbreviation']] = self.manager.get_book_by_id(
|
self.books[book[u'abbreviation']] = self.manager.get_book_by_id(
|
||||||
self.bible, book[u'id'])
|
self.bible, book[u'id'])
|
||||||
@ -114,26 +114,21 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
Exit Dialog and save data
|
Exit Dialog and save data
|
||||||
"""
|
"""
|
||||||
log.debug(u'BibleEditForm.accept')
|
log.debug(u'BibleEditForm.accept')
|
||||||
save = True
|
|
||||||
self.version = unicode(self.versionNameEdit.text())
|
self.version = unicode(self.versionNameEdit.text())
|
||||||
self.copyright = unicode(self.copyrightEdit.text())
|
self.copyright = unicode(self.copyrightEdit.text())
|
||||||
self.permissions = unicode(self.permissionsEdit.text())
|
self.permissions = unicode(self.permissionsEdit.text())
|
||||||
self.bookname_language = \
|
self.bookname_language = \
|
||||||
self.languageSelectionComboBox.currentIndex() - 1
|
self.languageSelectionComboBox.currentIndex() - 1
|
||||||
for error in self.validate_error:
|
|
||||||
self.changeBackgroundColor(error)
|
|
||||||
if not self.validateMeta():
|
if not self.validateMeta():
|
||||||
save = False
|
return
|
||||||
if not self.webbible and save:
|
if not self.webbible:
|
||||||
custom_names = {}
|
custom_names = {}
|
||||||
for abbr, book in self.books.iteritems():
|
for abbr, book in self.books.iteritems():
|
||||||
if book:
|
if book:
|
||||||
custom_names[abbr] = unicode(self.bookNameEdit[abbr].text())
|
custom_names[abbr] = unicode(self.bookNameEdit[abbr].text())
|
||||||
if book.name != custom_names[abbr]:
|
if book.name != custom_names[abbr]:
|
||||||
if not self.validateBook(custom_names[abbr], abbr):
|
if not self.validateBook(custom_names[abbr], abbr):
|
||||||
save = False
|
return
|
||||||
break
|
|
||||||
if save:
|
|
||||||
Receiver.send_message(u'openlp_process_events')
|
Receiver.send_message(u'openlp_process_events')
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
self.manager.save_meta_data(self.bible, self.version,
|
self.manager.save_meta_data(self.bible, self.version,
|
||||||
@ -153,16 +148,12 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
Validate the Meta before saving.
|
Validate the Meta before saving.
|
||||||
"""
|
"""
|
||||||
if not self.version:
|
if not self.version:
|
||||||
self.changeBackgroundColor(self.versionNameEdit, u'red')
|
|
||||||
self.validate_error = [self.versionNameEdit]
|
|
||||||
self.versionNameEdit.setFocus()
|
self.versionNameEdit.setFocus()
|
||||||
critical_error_message_box(UiStrings().EmptyField,
|
critical_error_message_box(UiStrings().EmptyField,
|
||||||
translate('BiblesPlugin.BibleEditForm',
|
translate('BiblesPlugin.BibleEditForm',
|
||||||
'You need to specify a version name for your Bible.'))
|
'You need to specify a version name for your Bible.'))
|
||||||
return False
|
return False
|
||||||
elif not self.copyright:
|
elif not self.copyright:
|
||||||
self.changeBackgroundColor(self.copyrightEdit, u'red')
|
|
||||||
self.validate_error = [self.copyrightEdit]
|
|
||||||
self.copyrightEdit.setFocus()
|
self.copyrightEdit.setFocus()
|
||||||
critical_error_message_box(UiStrings().EmptyField,
|
critical_error_message_box(UiStrings().EmptyField,
|
||||||
translate('BiblesPlugin.BibleEditForm',
|
translate('BiblesPlugin.BibleEditForm',
|
||||||
@ -172,8 +163,6 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
elif self.manager.exists(self.version) and \
|
elif self.manager.exists(self.version) and \
|
||||||
self.manager.get_meta_data(self.bible, u'Version').value != \
|
self.manager.get_meta_data(self.bible, u'Version').value != \
|
||||||
self.version:
|
self.version:
|
||||||
self.changeBackgroundColor(self.versionNameEdit, u'red')
|
|
||||||
self.validate_error = [self.versionNameEdit]
|
|
||||||
self.versionNameEdit.setFocus()
|
self.versionNameEdit.setFocus()
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
|
translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
|
||||||
@ -189,8 +178,6 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
"""
|
"""
|
||||||
book_regex = re.compile(u'[\d]*[^\d]+$')
|
book_regex = re.compile(u'[\d]*[^\d]+$')
|
||||||
if not new_bookname:
|
if not new_bookname:
|
||||||
self.changeBackgroundColor(self.bookNameEdit[abbreviation], u'red')
|
|
||||||
self.validate_error = [self.bookNameEdit[abbreviation]]
|
|
||||||
self.bookNameEdit[abbreviation].setFocus()
|
self.bookNameEdit[abbreviation].setFocus()
|
||||||
critical_error_message_box(UiStrings().EmptyField,
|
critical_error_message_box(UiStrings().EmptyField,
|
||||||
unicode(translate('BiblesPlugin.BibleEditForm',
|
unicode(translate('BiblesPlugin.BibleEditForm',
|
||||||
@ -198,40 +185,24 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
|||||||
self.booknames[abbreviation])
|
self.booknames[abbreviation])
|
||||||
return False
|
return False
|
||||||
elif not book_regex.match(new_bookname):
|
elif not book_regex.match(new_bookname):
|
||||||
self.changeBackgroundColor(self.bookNameEdit[abbreviation], u'red')
|
|
||||||
self.validate_error = [self.bookNameEdit[abbreviation]]
|
|
||||||
self.bookNameEdit[abbreviation].setFocus()
|
self.bookNameEdit[abbreviation].setFocus()
|
||||||
critical_error_message_box(UiStrings().EmptyField,
|
critical_error_message_box(UiStrings().EmptyField,
|
||||||
unicode(translate('BiblesPlugin.BibleEditForm',
|
unicode(translate('BiblesPlugin.BibleEditForm',
|
||||||
'The book name "%s" is not correct.\nDecimal digits only could '
|
'The book name "%s" is not correct.\nNumbers can only be used '
|
||||||
'be used at the beginning and\nmust be followed by one or more '
|
'at the beginning and must\nbe followed by one or more '
|
||||||
'non-digit characters')) % new_bookname)
|
'non-numeric characters.')) % new_bookname)
|
||||||
return False
|
return False
|
||||||
for abbr, book in self.books.iteritems():
|
for abbr, book in self.books.iteritems():
|
||||||
if book:
|
if book:
|
||||||
if abbr == abbreviation:
|
if abbr == abbreviation:
|
||||||
continue
|
continue
|
||||||
if unicode(self.bookNameEdit[abbr].text()) == new_bookname:
|
if unicode(self.bookNameEdit[abbr].text()) == new_bookname:
|
||||||
self.changeBackgroundColor(self.bookNameEdit[abbreviation],
|
|
||||||
u'red')
|
|
||||||
self.bookNameEdit[abbreviation].setFocus()
|
self.bookNameEdit[abbreviation].setFocus()
|
||||||
self.changeBackgroundColor(self.bookNameEdit[abbr], u'red')
|
|
||||||
self.validate_error = [self.bookNameEdit[abbr],
|
|
||||||
self.bookNameEdit[abbreviation]]
|
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
translate('BiblesPlugin.BibleEditForm',
|
translate('BiblesPlugin.BibleEditForm',
|
||||||
'Book Name Exists Twice'),
|
'Duplicate Book Name'),
|
||||||
unicode(translate('BiblesPlugin.BibleEditForm',
|
unicode(translate('BiblesPlugin.BibleEditForm',
|
||||||
'The Book Name "%s" exists twice. Please change one.'))
|
'The Book Name "%s" has been entered more than once.'))
|
||||||
% new_bookname)
|
% new_bookname)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def changeBackgroundColor(self, lineedit, color=None):
|
|
||||||
"""
|
|
||||||
Change the Background Color of the given LineEdit
|
|
||||||
"""
|
|
||||||
pal = QtGui.QPalette(self.palette())
|
|
||||||
if color:
|
|
||||||
pal.setColor(QtGui.QPalette.Base, QtGui.QColor(color))
|
|
||||||
lineedit.setPalette(pal)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user