From 0efcf157529a28f6cf6850c911ffea4a42badf4d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 7 Sep 2009 21:39:17 +0100 Subject: [PATCH 1/8] Move network code to initialise(). Add weight to plugin attibutes documentation --- openlp/core/lib/plugin.py | 3 +++ openlp/plugins/remotes/remoteplugin.py | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) 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/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index eadcb05ca..6d6717685 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()'), seld.readData) + def get_settings_tab(self): """ Create the settings Tab From 38ff2f92acfe68826a8af0caa647972eeb0c0108 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 8 Sep 2009 18:51:34 +0100 Subject: [PATCH 2/8] Fix typo in previous commit --- openlp/plugins/remotes/remoteplugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 6d6717685..6852e08d2 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -51,7 +51,7 @@ class RemotesPlugin(Plugin): 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()'), seld.readData) + QtCore.SIGNAL(u'readyRead()'), self.readData) def get_settings_tab(self): """ @@ -62,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): From 4dd19eb6431a8509436106b825fb97a8c9456a4b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Sep 2009 17:34:24 +0100 Subject: [PATCH 3/8] Song editing fix --- openlp/plugins/songs/forms/editsongform.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 6419e989f..7b13571f7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -282,9 +282,21 @@ 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.insert(row, self.VerseListWidget.item(row)) + self.VerseListWidget.clear() + for row in range (0, len(tempList)): + item = tempList[row] + self.VerseListWidget.addItem(item) + self.VerseListWidget.repaint() self.VerseEditButton.setEnabled(False) self.VerseDeleteButton.setEnabled(False) From d7ecd8a49370b9634aee5b5030c8a84a4b9f735f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Sep 2009 18:01:02 +0100 Subject: [PATCH 4/8] Song editing fix --- openlp/plugins/songs/forms/editsongform.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 7b13571f7..685d40c83 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -289,13 +289,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item.setText(afterText) #number of lines has change if len(tempText.split(u'\n')) != len(afterText.split(u'\n')): - tempList = [] + tempList = {} for row in range(0, self.VerseListWidget.count()): - tempList.insert(row, self.VerseListWidget.item(row)) + item = self.VerseListWidget.item(row) + tempList[row] = item.text() self.VerseListWidget.clear() for row in range (0, len(tempList)): - item = tempList[row] - self.VerseListWidget.addItem(item) + text = tempList[row] + print text + self.VerseListWidget.addItem(text) self.VerseListWidget.repaint() self.VerseEditButton.setEnabled(False) self.VerseDeleteButton.setEnabled(False) From 05761ef442a194326e6b94b121751b6b61d48bca Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Sep 2009 18:02:44 +0100 Subject: [PATCH 5/8] Song editing fix - final --- openlp/plugins/songs/forms/editsongform.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 685d40c83..bda64a271 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -291,13 +291,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if len(tempText.split(u'\n')) != len(afterText.split(u'\n')): tempList = {} for row in range(0, self.VerseListWidget.count()): - item = self.VerseListWidget.item(row) - tempList[row] = item.text() + tempList[row] = self.VerseListWidget.item(row).text() self.VerseListWidget.clear() for row in range (0, len(tempList)): - text = tempList[row] - print text - self.VerseListWidget.addItem(text) + self.VerseListWidget.addItem(tempList[row]) self.VerseListWidget.repaint() self.VerseEditButton.setEnabled(False) self.VerseDeleteButton.setEnabled(False) From cb1d5c2abb2a5fc8e0a4fb6a064609957d9a4c3b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Sep 2009 18:30:33 +0100 Subject: [PATCH 6/8] Custom editing fix part 1 --- openlp/plugins/custom/forms/editcustomform.py | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index fa936f469..a602b4605 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() @@ -147,7 +150,6 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): 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()) @@ -164,17 +166,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 From 457885019b8f0fbd6d8f432f4467d9fb63693a3a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Sep 2009 18:40:12 +0100 Subject: [PATCH 7/8] Custom editing fix part 2 --- openlp/plugins/custom/forms/editcustomform.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index a602b4605..4cb93270e 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -141,10 +141,7 @@ 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()) @@ -152,13 +149,27 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.VerseTextEdit.clear() 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) From e0a2e5e1f3bed95a42c67a9fa9f98e86ab2955ff Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 9 Sep 2009 19:09:17 +0100 Subject: [PATCH 8/8] For space police --- openlp/plugins/custom/forms/editcustomform.py | 5 ++--- openlp/plugins/songs/forms/editsongform.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 4cb93270e..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, translate +from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver, translate from openlp.plugins.custom.lib.models import CustomSlide class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): @@ -166,10 +166,9 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): 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)): + for row in range (0, len(tempList)): self.VerseListView.addItem(tempList[row]) self.VerseListView.repaint() - self.SaveButton.setEnabled(False) self.EditButton.setEnabled(False) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index bda64a271..60b7906cb 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -293,7 +293,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): 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)): + for row in range (0, len(tempList)): self.VerseListWidget.addItem(tempList[row]) self.VerseListWidget.repaint() self.VerseEditButton.setEnabled(False)