forked from openlp/openlp
Change Topics Form handling to allow save button to be enabled.
This commit is contained in:
parent
ec81608fe0
commit
69df159f17
@ -51,7 +51,8 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
Refresh the screen and rest fields
|
Refresh the screen and rest fields
|
||||||
"""
|
"""
|
||||||
self.TopicsListWidget.clear()
|
self.TopicsListWidget.clear()
|
||||||
self.onClearButtonClick() # tidy up screen
|
# tidy up screen
|
||||||
|
self.onClearButtonClick()
|
||||||
topics = self.songmanager.get_topics()
|
topics = self.songmanager.get_topics()
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
topic_name = QtGui.QListWidgetItem(topic.name)
|
topic_name = QtGui.QListWidgetItem(topic.name)
|
||||||
@ -77,6 +78,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
"""
|
"""
|
||||||
Sent New or update details to the database
|
Sent New or update details to the database
|
||||||
"""
|
"""
|
||||||
|
if self._validate_form():
|
||||||
if self.topic == None:
|
if self.topic == None:
|
||||||
self.topic = Topic()
|
self.topic = Topic()
|
||||||
self.topic.name = unicode(self.TopicNameEdit.displayText())
|
self.topic.name = unicode(self.TopicNameEdit.displayText())
|
||||||
@ -91,7 +93,6 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
self.TopicNameEdit.setText(u'')
|
self.TopicNameEdit.setText(u'')
|
||||||
self.MessageLabel.setText(u'')
|
self.MessageLabel.setText(u'')
|
||||||
self.DeleteButton.setEnabled(False)
|
self.DeleteButton.setEnabled(False)
|
||||||
self.AddUpdateButton.setEnabled(True)
|
|
||||||
self.topic = None
|
self.topic = None
|
||||||
self._validate_form()
|
self._validate_form()
|
||||||
|
|
||||||
@ -115,7 +116,10 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog):
|
|||||||
|
|
||||||
def _validate_form(self):
|
def _validate_form(self):
|
||||||
# We need at lease a display name
|
# We need at lease a display name
|
||||||
|
valid = True
|
||||||
if len(self.TopicNameEdit.displayText()) == 0:
|
if len(self.TopicNameEdit.displayText()) == 0:
|
||||||
self.AddUpdateButton.setEnabled(False)
|
valid = False
|
||||||
|
self.TopicNameEdit.setStyleSheet(u'background-color: red; color: white')
|
||||||
else:
|
else:
|
||||||
self.AddUpdateButton.setEnabled(True)
|
self.TopicNameEdit.setStyleSheet(u'')
|
||||||
|
return valid
|
||||||
|
Loading…
Reference in New Issue
Block a user