forked from openlp/openlp
continued save button problem
This commit is contained in:
parent
384a3e4683
commit
2f99a85c4e
@ -162,7 +162,10 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
"""
|
"""
|
||||||
Saves the custom.
|
Saves the custom.
|
||||||
"""
|
"""
|
||||||
if not self._validate():
|
valid, message = self._validate()
|
||||||
|
if not valid:
|
||||||
|
QtGui.QMessageBox.critical(self,
|
||||||
|
translate('CustomPlugin.EditCustomForm', 'Error'), message)
|
||||||
return False
|
return False
|
||||||
sxml = CustomXMLBuilder()
|
sxml = CustomXMLBuilder()
|
||||||
sxml.new_document()
|
sxml.new_document()
|
||||||
@ -196,6 +199,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.verseListView.setCurrentRow(selectedRow + 1)
|
self.verseListView.setCurrentRow(selectedRow + 1)
|
||||||
|
|
||||||
def onClearButtonPressed(self):
|
def onClearButtonPressed(self):
|
||||||
|
#TODO: enable the "big" save button.
|
||||||
self.verseTextEdit.clear()
|
self.verseTextEdit.clear()
|
||||||
self.editAll = False
|
self.editAll = False
|
||||||
self.addButton.setEnabled(True)
|
self.addButton.setEnabled(True)
|
||||||
@ -210,14 +214,18 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.editText(item.text())
|
self.editText(item.text())
|
||||||
|
|
||||||
def onAddButtonPressed(self):
|
def onAddButtonPressed(self):
|
||||||
|
#TODO: enable the "big" save button.
|
||||||
self.verseListView.addItem(self.verseTextEdit.toPlainText())
|
self.verseListView.addItem(self.verseTextEdit.toPlainText())
|
||||||
|
self.editAllButton.setEnabled(True)
|
||||||
self.deleteButton.setEnabled(False)
|
self.deleteButton.setEnabled(False)
|
||||||
self.verseTextEdit.clear()
|
self.verseTextEdit.clear()
|
||||||
|
|
||||||
def onEditButtonPressed(self):
|
def onEditButtonPressed(self):
|
||||||
|
#TODO: disable the "big" save button.
|
||||||
self.editText(self.verseListView.currentItem().text())
|
self.editText(self.verseListView.currentItem().text())
|
||||||
|
|
||||||
def onEditAllButtonPressed(self):
|
def onEditAllButtonPressed(self):
|
||||||
|
#TODO: disable the "big" save button.
|
||||||
self.editAll = True
|
self.editAll = True
|
||||||
self.addButton.setEnabled(False)
|
self.addButton.setEnabled(False)
|
||||||
self.splitButton.setEnabled(True)
|
self.splitButton.setEnabled(True)
|
||||||
@ -240,6 +248,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.clearButton.setEnabled(True)
|
self.clearButton.setEnabled(True)
|
||||||
|
|
||||||
def onSaveButtonPressed(self):
|
def onSaveButtonPressed(self):
|
||||||
|
#TODO: enable the "big" save button.
|
||||||
if self.editAll:
|
if self.editAll:
|
||||||
self.verseListView.clear()
|
self.verseListView.clear()
|
||||||
for row in unicode(self.verseTextEdit.toPlainText()).split(
|
for row in unicode(self.verseTextEdit.toPlainText()).split(
|
||||||
@ -272,9 +281,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
self.verseTextEdit.setFocus()
|
self.verseTextEdit.setFocus()
|
||||||
|
|
||||||
def onDeleteButtonPressed(self):
|
def onDeleteButtonPressed(self):
|
||||||
|
#TODO: make sure the "big" save button is disabled if no slides.
|
||||||
self.verseListView.takeItem(self.verseListView.currentRow())
|
self.verseListView.takeItem(self.verseListView.currentRow())
|
||||||
self.editButton.setEnabled(False)
|
self.editButton.setEnabled(False)
|
||||||
self.editAllButton.setEnabled(True)
|
self.editAllButton.setEnabled(True)
|
||||||
|
if self.verseListView.count() == 0:
|
||||||
|
self.deleteButton.setEnabled(False)
|
||||||
|
self.editAllButton.setEnabled(False)
|
||||||
|
|
||||||
def _validate(self):
|
def _validate(self):
|
||||||
"""
|
"""
|
||||||
@ -283,29 +296,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
|
|||||||
# We must have a title.
|
# We must have a title.
|
||||||
if len(self.titleEdit.displayText()) == 0:
|
if len(self.titleEdit.displayText()) == 0:
|
||||||
self.titleEdit.setFocus()
|
self.titleEdit.setFocus()
|
||||||
QtGui.QMessageBox.critical(self,
|
return False, translate('CustomPlugin.EditCustomForm',
|
||||||
translate('CustomPlugin.EditCustomForm', 'Error'),
|
'You need to type in a title.')
|
||||||
translate('CustomPlugin.EditCustomForm',
|
|
||||||
'You need to type in a title.'))
|
|
||||||
return False
|
|
||||||
# We must have one slide.
|
# We must have one slide.
|
||||||
if self.verseListView.count() == 0:
|
if self.verseListView.count() == 0:
|
||||||
self.verseTextEdit.setFocus()
|
self.verseTextEdit.setFocus()
|
||||||
QtGui.QMessageBox.critical(self,
|
return False, translate('CustomPlugin.EditCustomForm',
|
||||||
translate('CustomPlugin.EditCustomForm', 'Error'),
|
'You need to add at least one slide')
|
||||||
translate('CustomPlugin.EditCustomForm',
|
return True, u''
|
||||||
'You need to add at least one slide.'))
|
|
||||||
return False
|
|
||||||
# We must not have unsaved data.
|
|
||||||
if self.verseTextEdit.toPlainText():
|
|
||||||
if QtGui.QMessageBox.critical(self,
|
|
||||||
translate('CustomPlugin.EditCustomForm', 'Error'),
|
|
||||||
translate('CustomPlugin.EditCustomForm', 'You have one or more '
|
|
||||||
'unsaved slides. Do you want to save them and continue?'),
|
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
|
||||||
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
|
||||||
self.onSaveButtonPressed()
|
|
||||||
else:
|
|
||||||
self.verseTextEdit.setFocus()
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
Loading…
Reference in New Issue
Block a user