"Save and Preview" added to Song editor

This commit is contained in:
Tim Bentley 2009-10-25 18:07:23 +00:00
parent da4a26ef5f
commit 3f69bb7635
3 changed files with 19 additions and 7 deletions

View File

@ -605,7 +605,6 @@ class ServiceManager(QtGui.QWidget):
``theme_list``
A list of current themes to be displayed
"""
self.ThemeComboBox.clear()
self.ThemeMenu.clear()

View File

@ -447,4 +447,3 @@ class Ui_EditSongDialog(object):
self.SongTabWidget.setTabText(
self.SongTabWidget.indexOf(self.ThemeTab),
self.trUtf8(u'Theme, Copyright Info && Comments'))

View File

@ -93,6 +93,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtCore.SIGNAL(u'lostFocus()'), self.onCommentsEditLostFocus)
QtCore.QObject.connect(self.VerseOrderEdit,
QtCore.SIGNAL(u'lostFocus()'), self.onVerseOrderEditLostFocus)
previewButton = QtGui.QPushButton()
previewButton.setText(self.trUtf8(u'Save & Preview'))
self.ButtonBox.addButton(previewButton, QtGui.QDialogButtonBox.ActionRole)
QtCore.QObject.connect(self.ButtonBox,
QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview)
# Create other objects and forms
self.songmanager = songmanager
self.verse_form = EditVerseForm()
@ -391,14 +396,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.loadBooks()
self.loadTopics()
def onPreview(self, button):
log.debug(u'onPreview')
if button.text() == self.trUtf8(u'Save & Preview') and self.saveSong():
Receiver().send_message(u'preview_song')
def accept(self):
log.debug(u'accept')
if self.saveSong():
if self.title_change:
Receiver().send_message(u'load_song_list')
Receiver().send_message(u'preview_song')
self.close()
def saveSong(self):
valid, message = self._validate_song()
if not valid:
QtGui.QMessageBox.critical(
self, self.trUtf8(u'Error'), message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
return
return False
self.song.title = unicode(self.TitleEditItem.displayText())
self.song.copyright = unicode(self.CopyrightEditItem.displayText())
self.song.search_title = unicode(self.TitleEditItem.displayText()) + \
@ -408,10 +425,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.processLyrics()
self.processTitle()
self.songmanager.save_song(self.song)
if self.title_change:
Receiver().send_message(u'load_song_list')
Receiver().send_message(u'preview_song')
self.close()
return True
def processLyrics(self):
log.debug(u'processLyrics')