2009-01-01 10:03:09 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-09-08 19:58:05 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
2009-01-02 20:20:33 +00:00
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2010-12-26 11:04:47 +00:00
|
|
|
# Copyright (c) 2008-2011 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
2010-07-24 22:10:47 +00:00
|
|
|
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
|
|
|
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
|
|
|
# Carsten Tinggaard, Frode Woldsund #
|
2009-09-08 19:58:05 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2009-01-02 20:20:33 +00:00
|
|
|
|
2009-01-01 10:03:09 +00:00
|
|
|
from PyQt4 import QtGui, QtCore
|
2009-10-24 16:40:36 +00:00
|
|
|
|
2010-05-31 22:06:16 +00:00
|
|
|
from openlp.core.lib import translate
|
2011-02-02 23:12:31 +00:00
|
|
|
from openlp.core.lib.ui import critical_error_message_box
|
2010-06-06 10:07:48 +00:00
|
|
|
from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog
|
|
|
|
|
2009-03-09 12:49:55 +00:00
|
|
|
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
2009-01-10 08:33:31 +00:00
|
|
|
Class to control the Maintenance of Authors Dialog
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
2009-07-24 20:40:34 +00:00
|
|
|
def __init__(self, parent=None):
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
2009-01-10 08:33:31 +00:00
|
|
|
Set up the screen and common data
|
2009-01-01 10:03:09 +00:00
|
|
|
"""
|
2009-03-09 12:49:55 +00:00
|
|
|
QtGui.QDialog.__init__(self, parent)
|
2009-01-01 10:03:09 +00:00
|
|
|
self.setupUi(self)
|
2010-05-27 20:56:34 +00:00
|
|
|
self._autoDisplayName = False
|
2011-01-04 21:06:50 +00:00
|
|
|
QtCore.QObject.connect(self.firstNameEdit,
|
2010-05-27 20:56:34 +00:00
|
|
|
QtCore.SIGNAL(u'textEdited(QString)'),
|
|
|
|
self.onFirstNameEditTextEdited)
|
2011-01-04 21:06:50 +00:00
|
|
|
QtCore.QObject.connect(self.lastNameEdit,
|
2010-05-27 20:56:34 +00:00
|
|
|
QtCore.SIGNAL(u'textEdited(QString)'),
|
|
|
|
self.onLastNameEditTextEdited)
|
2009-02-19 22:25:58 +00:00
|
|
|
|
2009-07-24 20:40:34 +00:00
|
|
|
def exec_(self, clear=True):
|
|
|
|
if clear:
|
2011-01-04 21:06:50 +00:00
|
|
|
self.firstNameEdit.clear()
|
|
|
|
self.lastNameEdit.clear()
|
|
|
|
self.displayEdit.clear()
|
|
|
|
self.firstNameEdit.setFocus()
|
2009-07-24 20:40:34 +00:00
|
|
|
return QtGui.QDialog.exec_(self)
|
2009-06-03 16:14:56 +00:00
|
|
|
|
2009-07-24 20:40:34 +00:00
|
|
|
def onFirstNameEditTextEdited(self, text):
|
2010-05-27 20:56:34 +00:00
|
|
|
if not self._autoDisplayName:
|
2009-07-24 20:40:34 +00:00
|
|
|
return
|
|
|
|
display_name = text
|
2011-01-04 21:06:50 +00:00
|
|
|
if self.lastNameEdit.text() != u'':
|
|
|
|
display_name = display_name + u' ' + self.lastNameEdit.text()
|
|
|
|
self.displayEdit.setText(display_name)
|
2009-01-10 08:33:31 +00:00
|
|
|
|
2009-07-24 20:40:34 +00:00
|
|
|
def onLastNameEditTextEdited(self, text):
|
2010-05-27 20:56:34 +00:00
|
|
|
if not self._autoDisplayName:
|
2009-07-24 20:40:34 +00:00
|
|
|
return
|
|
|
|
display_name = text
|
2011-01-04 21:06:50 +00:00
|
|
|
if self.firstNameEdit.text() != u'':
|
|
|
|
display_name = self.firstNameEdit.text() + u' ' + display_name
|
|
|
|
self.displayEdit.setText(display_name)
|
2009-02-19 22:25:58 +00:00
|
|
|
|
2009-07-24 20:40:34 +00:00
|
|
|
def autoDisplayName(self):
|
2010-05-27 20:56:34 +00:00
|
|
|
return self._autoDisplayName
|
2009-02-19 22:25:58 +00:00
|
|
|
|
2009-07-24 20:40:34 +00:00
|
|
|
def setAutoDisplayName(self, on):
|
2010-05-27 20:56:34 +00:00
|
|
|
self._autoDisplayName = on
|
2009-02-19 22:25:58 +00:00
|
|
|
|
2009-07-25 22:07:59 +00:00
|
|
|
def accept(self):
|
2011-01-04 21:06:50 +00:00
|
|
|
if not self.firstNameEdit.text():
|
2011-02-02 23:12:31 +00:00
|
|
|
critical_error_message_box(
|
|
|
|
message=translate('SongsPlugin.AuthorsForm',
|
2011-01-15 00:53:12 +00:00
|
|
|
'You need to type in the first name of the author.'))
|
2011-01-04 21:06:50 +00:00
|
|
|
self.firstNameEdit.setFocus()
|
2009-07-25 22:07:59 +00:00
|
|
|
return False
|
2011-01-04 21:06:50 +00:00
|
|
|
elif not self.lastNameEdit.text():
|
2011-02-02 23:12:31 +00:00
|
|
|
critical_error_message_box(
|
|
|
|
message=translate('SongsPlugin.AuthorsForm',
|
2011-01-15 00:53:12 +00:00
|
|
|
'You need to type in the last name of the author.'))
|
2011-01-04 21:06:50 +00:00
|
|
|
self.lastNameEdit.setFocus()
|
2009-07-25 22:07:59 +00:00
|
|
|
return False
|
2011-01-04 21:06:50 +00:00
|
|
|
elif not self.displayEdit.text():
|
2011-02-02 23:12:31 +00:00
|
|
|
if critical_error_message_box(
|
2011-01-15 19:24:50 +00:00
|
|
|
message=translate('SongsPlugin.AuthorsForm',
|
2011-01-15 00:53:12 +00:00
|
|
|
'You have not set a display name for the '
|
|
|
|
'author, combine the first and last names?'),
|
2011-01-15 20:06:25 +00:00
|
|
|
parent=self, question=True) == QtGui.QMessageBox.Yes:
|
2011-01-04 21:06:50 +00:00
|
|
|
self.displayEdit.setText(self.firstNameEdit.text() + \
|
|
|
|
u' ' + self.lastNameEdit.text())
|
2009-07-26 10:02:18 +00:00
|
|
|
return QtGui.QDialog.accept(self)
|
2009-07-22 06:14:34 +00:00
|
|
|
else:
|
2011-01-04 21:06:50 +00:00
|
|
|
self.displayEdit.setFocus()
|
2009-07-26 10:02:18 +00:00
|
|
|
return False
|
2009-01-12 19:31:29 +00:00
|
|
|
else:
|
2011-01-04 21:06:50 +00:00
|
|
|
return QtGui.QDialog.accept(self)
|