forked from openlp/openlp
Song Exit error message
This commit is contained in:
parent
297c4ab4c3
commit
f6578fc000
@ -23,7 +23,7 @@ import logging
|
|||||||
from PyQt4 import Qt, QtCore, QtGui
|
from PyQt4 import Qt, QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \
|
from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \
|
||||||
EventType, EventManager
|
EventType, EventManager, translate
|
||||||
from openlp.plugins.songs.forms import EditVerseForm
|
from openlp.plugins.songs.forms import EditVerseForm
|
||||||
from openlp.plugins.songs.lib.models import Song
|
from openlp.plugins.songs.lib.models import Song
|
||||||
from editsongdialog import Ui_EditSongDialog
|
from editsongdialog import Ui_EditSongDialog
|
||||||
@ -299,22 +299,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
log.debug(u'Validate Song')
|
log.debug(u'Validate Song')
|
||||||
# Lets be nice and assume the data is correct.
|
# Lets be nice and assume the data is correct.
|
||||||
valid = True
|
valid = True
|
||||||
|
message = u''
|
||||||
if len(self.TitleEditItem.displayText()) == 0:
|
if len(self.TitleEditItem.displayText()) == 0:
|
||||||
valid = False
|
valid = False
|
||||||
self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
|
self.TitleEditItem.setStyleSheet(u'background-color: red; color: white')
|
||||||
|
message = translate(u'SongFormDialog', u'You need to enter a song title \n')
|
||||||
else:
|
else:
|
||||||
self.TitleEditItem.setStyleSheet(u'')
|
self.TitleEditItem.setStyleSheet(u'')
|
||||||
if self.VerseListWidget.count() == 0:
|
if self.VerseListWidget.count() == 0:
|
||||||
valid = False
|
valid = False
|
||||||
self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
|
self.VerseListWidget.setStyleSheet(u'background-color: red; color: white')
|
||||||
|
message = message + translate(u'SongFormDialog', u'You need to enter some verse text \n')
|
||||||
else:
|
else:
|
||||||
self.VerseListWidget.setStyleSheet(u'')
|
self.VerseListWidget.setStyleSheet(u'')
|
||||||
if self.AuthorsListView.count() == 0:
|
if self.AuthorsListView.count() == 0:
|
||||||
valid = False
|
valid = False
|
||||||
self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
|
self.AuthorsListView.setStyleSheet(u'background-color: red; color: white')
|
||||||
|
message = message + translate(u'SongFormDialog', u'You need to provide an author')
|
||||||
else:
|
else:
|
||||||
self.AuthorsListView.setStyleSheet(u'')
|
self.AuthorsListView.setStyleSheet(u'')
|
||||||
return valid
|
return valid, message
|
||||||
|
|
||||||
def on_TitleEditItem_lostFocus(self):
|
def on_TitleEditItem_lostFocus(self):
|
||||||
self.song.title = self.TitleEditItem.text()
|
self.song.title = self.TitleEditItem.text()
|
||||||
@ -345,7 +349,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
log.debug(u'accept')
|
log.debug(u'accept')
|
||||||
if not self._validate_song():
|
valid , message = self._validate_song()
|
||||||
|
if not valid:
|
||||||
|
QtGui.QMessageBox.critical(self,
|
||||||
|
translate(u'SongFormDialog', u'Error'), message,
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
|
||||||
return
|
return
|
||||||
self.song.title = unicode(self.TitleEditItem.displayText())
|
self.song.title = unicode(self.TitleEditItem.displayText())
|
||||||
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
|
||||||
|
Loading…
Reference in New Issue
Block a user