diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index 6fb1ae6aa..d245f31a4 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -57,6 +57,9 @@ class Ui_customEditDialog(object): self.DeleteButton = QtGui.QPushButton(self.ButtonWidge) self.DeleteButton.setObjectName("DeleteButton") self.ButtonLayout_3.addWidget(self.DeleteButton) + self.ClearButton = QtGui.QPushButton(self.ButtonWidge) + self.ClearButton.setObjectName("ClearButton") + self.ButtonLayout_3.addWidget(self.ClearButton) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.ButtonLayout_3.addItem(spacerItem) self.EditLayout_3.addWidget(self.ButtonWidge) @@ -102,5 +105,6 @@ class Ui_customEditDialog(object): self.EditButton_3.setText(QtGui.QApplication.translate("customEditDialog", "Edit", None, QtGui.QApplication.UnicodeUTF8)) self.SaveButton_3.setText(QtGui.QApplication.translate("customEditDialog", "Save", None, QtGui.QApplication.UnicodeUTF8)) self.DeleteButton.setText(QtGui.QApplication.translate("customEditDialog", "Delete", None, QtGui.QApplication.UnicodeUTF8)) + self.ClearButton.setText(QtGui.QApplication.translate("customEditDialog", "Clear", None, QtGui.QApplication.UnicodeUTF8)) self.ThemeLabel.setText(QtGui.QApplication.translate("customEditDialog", "Theme:", None, QtGui.QApplication.UnicodeUTF8)) self.CreditLabel.setText(QtGui.QApplication.translate("customEditDialog", "Credits:", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 111c914ef..159868a99 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -38,20 +38,32 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): QtCore.QObject.connect(self.EditButton_3, QtCore.SIGNAL("pressed()"), self.onEditButtonPressed) QtCore.QObject.connect(self.SaveButton_3, QtCore.SIGNAL("pressed()"), self.onSaveButtonPressed) QtCore.QObject.connect(self.DeleteButton, QtCore.SIGNAL("pressed()"), self.onDeleteButtonPressed) + QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL("pressed()"), self.onClearButtonPressed) + QtCore.QObject.connect(self.TitleEdit, QtCore.SIGNAL("lostFocus()"), self.validate) + QtCore.QObject.connect(self.VerseListView, QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem*)"), self.onVerseListViewSelected) # Create other objects and forms self.custommanager = custommanager self.initialise() - + self.VerseListView.setAlternatingRowColors(True) #self.savebutton = self.ButtonBox.button(QtGui.QDialogButtonBox.Save) def accept(self): - pass - + self.validate() + if self.valid: + self.close() + def rejected(self): self.close() + def onClearButtonPressed(self): + self.VerseTextEdit_3.clear() + + def onVerseListViewSelected(self, item): + self.VerseTextEdit_3.setPlainText(item.text()) + def onAddButtonPressed(self): - pass + print self.VerseTextEdit_3 + self.VerseListView.addItem(self.VerseTextEdit_3.toPlainText()) def onEditButtonPressed(self): pass @@ -62,16 +74,28 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): def onDeleteButtonPressed(self): pass + def validate(self): + invalid = 0 + self.valid = True + if len(self.TitleEdit.displayText()) == 0: + invalid += 1 + self.TitleLabel.setStyleSheet('color: red') + else: + self.TitleLabel.setStyleSheet('color: black') + if invalid == 1: + self.valid = False + def initialise(self): + self.valid = True pass # list = self.songmanager.get_authors() # self.AuthorsSelectionComboItem.clear() # for i in list: # self.AuthorsSelectionComboItem.addItem( i.display_name) - def loadSong(self, id): + def loadCustomItem(self, id): pass -# self.song = self.songmanager.get_song(id) + #self.item = self.songmanager.get_song(id) # self.TitleEditItem.setText(self.song.title) # self.LyricsTextEdit.setText(self.song.lyrics) # self.CopyrightEditItem.setText(self.song.copyright)