diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index a338175a8..3cf555136 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -45,6 +45,9 @@ class Plugin(object): ``log`` A log object used to log debugging messages. This is pre-instantiated. + ``weight`` + A numerical value used to order the plugins. + **Hook Functions** ``check_pre_conditions()`` diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index fa936f469..a223a9429 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import Qt, QtCore, QtGui from editcustomdialog import Ui_customEditDialog -from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver +from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver, translate from openlp.plugins.custom.lib.models import CustomSlide class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): @@ -44,7 +44,6 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): QtCore.QObject.connect(self.ClearButton, QtCore.SIGNAL(u'pressed()'), self.onClearButtonPressed) QtCore.QObject.connect(self.UpButton, QtCore.SIGNAL(u'pressed()'), self.onUpButtonPressed) QtCore.QObject.connect(self.DownButton, QtCore.SIGNAL(u'pressed()'), self.onDownButtonPressed) - QtCore.QObject.connect(self.TitleEdit, QtCore.SIGNAL(u'lostFocus()'), self.validate) QtCore.QObject.connect(self.VerseListView, QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected) @@ -92,25 +91,29 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): if id == -1: id = 0 # Not Found self.ThemecomboBox.setCurrentIndex(id) - self.validate() else: self.ThemecomboBox.setCurrentIndex(0) def accept(self): - if self.validate(): - sxml=SongXMLBuilder() - sxml.new_document() - sxml.add_lyrics_to_song() - count = 1 - for i in range (0, self.VerseListView.count()): - sxml.add_verse_to_lyrics(u'custom', unicode(count), unicode(self.VerseListView.item(i).text())) - count += 1 - self.customSlide.title = unicode(self.TitleEdit.displayText()) - self.customSlide.text = unicode(sxml.extract_xml()) - self.customSlide.credits = unicode(self.CreditEdit.displayText()) - self.customSlide.theme_name = unicode(self.ThemecomboBox.currentText()) - self.custommanager.save_slide(self.customSlide) - self.close() + valid , message = self._validate() + if not valid: + QtGui.QMessageBox.critical(self, + translate(u'customEditDialog', u'Error'), message, + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + return + sxml=SongXMLBuilder() + sxml.new_document() + sxml.add_lyrics_to_song() + count = 1 + for i in range (0, self.VerseListView.count()): + sxml.add_verse_to_lyrics(u'custom', unicode(count), unicode(self.VerseListView.item(i).text())) + count += 1 + self.customSlide.title = unicode(self.TitleEdit.displayText()) + self.customSlide.text = unicode(sxml.extract_xml()) + self.customSlide.credits = unicode(self.CreditEdit.displayText()) + self.customSlide.theme_name = unicode(self.ThemecomboBox.currentText()) + self.custommanager.save_slide(self.customSlide) + self.close() def rejected(self): self.close() @@ -138,25 +141,34 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.EditButton.setEnabled(True) def onVerseListViewSelected(self, item): - self.VerseTextEdit.setPlainText(item.text()) - self.DeleteButton.setEnabled(False) - self.EditButton.setEnabled(False) - self.SaveButton.setEnabled(True) + self.editText(item.text()) def onAddButtonPressed(self): self.VerseListView.addItem(self.VerseTextEdit.toPlainText()) self.DeleteButton.setEnabled(False) self.VerseTextEdit.clear() - self.validate() def onEditButtonPressed(self): - self.VerseTextEdit.setPlainText(self.VerseListView.currentItem().text()) + self.editText(self.VerseListView.currentItem().text()) + + def editText(self, text): + self.beforeText = text + self.VerseTextEdit.setPlainText(text) self.DeleteButton.setEnabled(False) self.EditButton.setEnabled(False) self.SaveButton.setEnabled(True) def onSaveButtonPressed(self): self.VerseListView.currentItem().setText(self.VerseTextEdit.toPlainText()) + #number of lines has change + if len(self.beforeText.split(u'\n')) != len(self.VerseTextEdit.toPlainText().split(u'\n')): + tempList = {} + for row in range(0, self.VerseListView.count()): + tempList[row] = self.VerseListView.item(row).text() + self.VerseListView.clear() + for row in range (0, len(tempList)): + self.VerseListView.addItem(tempList[row]) + self.VerseListView.repaint() self.SaveButton.setEnabled(False) self.EditButton.setEnabled(False) @@ -164,17 +176,14 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.VerseListView.takeItem(self.VerseListView.currentRow()) self.EditButton.setEnabled(False) - def validate(self): + def _validate(self): valid = True + message = u'' if len(self.TitleEdit.displayText()) == 0: valid = False - self.TitleEdit.setStyleSheet(u'background-color: red; color: white') - else: - self.TitleEdit.setStyleSheet(u'') + message = translate(u'customEditDialog', u'You need to enter a title \n') # must have 1 slide if self.VerseListView.count() == 0: valid = False - self.VerseListView.setStyleSheet(u'background-color: red; color: white') - else: - self.VerseListView.setStyleSheet(u'') - return valid + message += translate(u'customEditDialog', u'You need to enter a slide \n') + return valid, message diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index eadcb05ca..6852e08d2 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -35,10 +35,6 @@ class RemotesPlugin(Plugin): # Call the parent constructor Plugin.__init__(self, u'Remotes', u'1.9.0', plugin_helpers) self.weight = -1 - self.server = QtNetwork.QUdpSocket() - self.server.bind(int(self.config.get_config(u'remote port', 4316))) - QtCore.QObject.connect(self.server, - QtCore.SIGNAL(u'readyRead()'), self.readData) def check_pre_conditions(self): """ @@ -51,6 +47,12 @@ class RemotesPlugin(Plugin): else: return False + def initialise(self): + self.server = QtNetwork.QUdpSocket() + self.server.bind(int(self.config.get_config(u'remote port', 4316))) + QtCore.QObject.connect(self.server, + QtCore.SIGNAL(u'readyRead()'), self.readData) + def get_settings_tab(self): """ Create the settings Tab @@ -60,7 +62,8 @@ class RemotesPlugin(Plugin): def readData(self): log.info(u'Remoted data has arrived') while self.server.hasPendingDatagrams(): - datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize()) + datagram, host, port = self.server.readDatagram( + self.server.pendingDatagramSize()) self.handle_datagram(datagram) def handle_datagram(self, datagram): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c44131eb6..08f34691b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -290,9 +290,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onVerseEditButtonClicked(self): item = self.VerseListWidget.currentItem() if item is not None: - self.verse_form.setVerse(item.text()) + tempText = item.text() + self.verse_form.setVerse(tempText) self.verse_form.exec_() - item.setText(self.verse_form.getVerse()) + afterText = self.verse_form.getVerse() + item.setText(afterText) + #number of lines has change + if len(tempText.split(u'\n')) != len(afterText.split(u'\n')): + tempList = {} + for row in range(0, self.VerseListWidget.count()): + tempList[row] = self.VerseListWidget.item(row).text() + self.VerseListWidget.clear() + for row in range (0, len(tempList)): + self.VerseListWidget.addItem(tempList[row]) + self.VerseListWidget.repaint() self.VerseEditButton.setEnabled(False) self.VerseDeleteButton.setEnabled(False) diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 5aff9053e..a7712c059 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -47,7 +47,7 @@ class Ui_SongMaintenanceDialog(object): self.TypeListWidget.setIconSize(QtCore.QSize(112, 100)); self.TypeListWidget.setMovement(QtGui.QListView.Static); self.TypeListWidget.setMaximumWidth(118); - self.TypeListWidget.setSpacing(3); + self.TypeListWidget.setSpacing(0); self.TypeListWidget.setSortingEnabled(False) self.TypeListWidget.setUniformItemSizes(True) self.TypeListWidget.setObjectName(u'TypeListWidget')