From 388a5969226921fd3c925f86b6d79b332645b794 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 22 Nov 2009 20:33:39 +0000 Subject: [PATCH 01/14] Add verse number code to song plugin --- openlp/core/lib/renderer.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 19 +- openlp/plugins/songs/forms/editversedialog.py | 106 +++++++---- openlp/plugins/songs/forms/editverseform.py | 26 ++- resources/forms/editversedialog.ui | 180 ++++++++++++++---- 5 files changed, 255 insertions(+), 78 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index b8d9b7172..4c666c38e 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 714442de1..547613def 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -216,11 +216,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): songXML = SongXMLParser(self.song.lyrics) verseList = songXML.get_verses() for verse in verseList: - self.VerseListWidget.addItem(verse[1]) + if verse[0][u'type'] == u'Verse': + variant = verse[0][u'label'] + else: + variant = verse[0][u'type'] + item = QtGui.QListWidgetItem(verse[1]) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant)) + self.VerseListWidget.addItem(item) else: verses = self.song.lyrics.split(u'\n\n') - for verse in verses: - self.VerseListWidget.addItem(verse) + for count, verse in enumerate(verses): + item = QtGui.QListWidgetItem(verse) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(count + 1)) + self.VerseListWidget.addItem(item) # clear the results self.AuthorsListView.clear() for author in self.song.authors: @@ -314,7 +322,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.VerseListWidget.currentItem() if item: tempText = item.text() - self.verse_form.setVerse(tempText) + verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) + self.verse_form.setVerse(tempText, True, verseId) self.verse_form.exec_() afterText = self.verse_form.getVerse() item.setText(afterText) @@ -335,6 +344,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.VerseListWidget.count() > 0: for row in range(0, self.VerseListWidget.count()): item = self.VerseListWidget.item(row) + verse_list += u'<%s>\n' % \ + unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) verse_list += item.text() verse_list += u'\n---\n' self.verse_form.setVerse(verse_list) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index f69a2fe6f..ca9b44fa3 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -1,52 +1,84 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2009 Raoul Snyman # -# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # -# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # -# --------------------------------------------------------------------------- # -# 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 # -############################################################################### +# Form implementation generated from reading ui file 'editversedialog.ui' +# +# Created: Sun Nov 22 13:33:41 2009 +# by: PyQt4 UI code generator 4.5.4 +# +# WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_EditVerseDialog(object): def setupUi(self, EditVerseDialog): - EditVerseDialog.setObjectName(u'EditVerseDialog') - EditVerseDialog.resize(492, 373) + EditVerseDialog.setObjectName("EditVerseDialog") + EditVerseDialog.resize(492, 494) EditVerseDialog.setModal(True) - self.DialogLayout = QtGui.QVBoxLayout(EditVerseDialog) - self.DialogLayout.setSpacing(8) - self.DialogLayout.setMargin(8) - self.DialogLayout.setObjectName(u'DialogLayout') - self.VerseTextEdit = QtGui.QTextEdit(EditVerseDialog) + self.widget = QtGui.QWidget(EditVerseDialog) + self.widget.setGeometry(QtCore.QRect(8, 11, 471, 461)) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.VerseListComboBox = QtGui.QComboBox(self.widget) + self.VerseListComboBox.setObjectName("VerseListComboBox") + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.setItemText(0, "") + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.horizontalLayout.addWidget(self.VerseListComboBox) + self.SubVerseListComboBox = QtGui.QComboBox(self.widget) + self.SubVerseListComboBox.setObjectName("SubVerseListComboBox") + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.setItemText(0, "") + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.horizontalLayout.addWidget(self.SubVerseListComboBox) + self.verticalLayout.addLayout(self.horizontalLayout) + self.VerseTextEdit = QtGui.QTextEdit(self.widget) self.VerseTextEdit.setAcceptRichText(False) - self.VerseTextEdit.setObjectName(u'VerseTextEdit') - self.DialogLayout.addWidget(self.VerseTextEdit) - self.ButtonBox = QtGui.QDialogButtonBox(EditVerseDialog) + self.VerseTextEdit.setObjectName("VerseTextEdit") + self.verticalLayout.addWidget(self.VerseTextEdit) + self.ButtonBox = QtGui.QDialogButtonBox(self.widget) self.ButtonBox.setOrientation(QtCore.Qt.Horizontal) self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) - self.ButtonBox.setObjectName(u'ButtonBox') - self.DialogLayout.addWidget(self.ButtonBox) + self.ButtonBox.setObjectName("ButtonBox") + self.verticalLayout.addWidget(self.ButtonBox) + self.retranslateUi(EditVerseDialog) - QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), EditVerseDialog.accept) - QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), EditVerseDialog.reject) + QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), EditVerseDialog.accept) + QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), EditVerseDialog.reject) QtCore.QMetaObject.connectSlotsByName(EditVerseDialog) - self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason) def retranslateUi(self, EditVerseDialog): - EditVerseDialog.setWindowTitle(self.trUtf8(u'Edit Verse')) + EditVerseDialog.setWindowTitle(QtGui.QApplication.translate("EditVerseDialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "Chorus", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "Bridge", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "1", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "2", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "3", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(6, QtGui.QApplication.translate("EditVerseDialog", "4", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(7, QtGui.QApplication.translate("EditVerseDialog", "5", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(8, QtGui.QApplication.translate("EditVerseDialog", "6", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(9, QtGui.QApplication.translate("EditVerseDialog", "7", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(11, QtGui.QApplication.translate("EditVerseDialog", "9", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(10, QtGui.QApplication.translate("EditVerseDialog", "8", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "a", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "b", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "c", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "d", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "e", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 93f5040d9..2d13b5537 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -38,8 +38,30 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) - def setVerse(self, verse): - self.VerseTextEdit.setPlainText(verse) + def setVerse(self, text, single=False, id=0): + posVerse = 0 + posSub = 0 + if single: + if len(id) <= 2: + if len(id) == 1: + posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) + else: + posVerse = self.VerseListComboBox.findText(id[0], QtCore.Qt.MatchExactly) + posSub = self.SubVerseListComboBox.findText(id[1], QtCore.Qt.MatchExactly) + else: + posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) + if posVerse == -1: + posVerse = 0 + if posSub == -1: + posSub = 0 + self.VerseListComboBox.setEnabled(True) + self.SubVerseListComboBox.setEnabled(True) + else: + self.VerseListComboBox.setEnabled(False) + self.SubVerseListComboBox.setEnabled(False) + self.VerseListComboBox.setCurrentIndex(posVerse) + self.SubVerseListComboBox.setCurrentIndex(posSub) + self.VerseTextEdit.setPlainText(text) self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason) def getVerse(self): diff --git a/resources/forms/editversedialog.ui b/resources/forms/editversedialog.ui index 68417ed41..822807f1b 100644 --- a/resources/forms/editversedialog.ui +++ b/resources/forms/editversedialog.ui @@ -1,45 +1,157 @@ - + + EditVerseDialog - - + + 0 0 492 - 373 + 494 - + Dialog - + true - - - 8 + + + + 8 + 11 + 471 + 461 + - - 8 - - - - - false - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Save - - - - + + + + + + + + + + + + + Verse + + + + + Chorus + + + + + Bridge + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 9 + + + + + 8 + + + + + + + + + + + + + + a + + + + + b + + + + + c + + + + + d + + + + + e + + + + + + + + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + @@ -49,11 +161,11 @@ EditVerseDialog accept() - + 248 254 - + 157 274 @@ -65,11 +177,11 @@ EditVerseDialog reject() - + 316 260 - + 286 274 From 50aa14344616c252bb81d08a4a7f3080b8d498c5 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 22 Nov 2009 20:51:52 +0000 Subject: [PATCH 02/14] Save verse details --- openlp/plugins/songs/forms/editsongform.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 547613def..2f0ef424c 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -356,7 +356,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse_list = verse_list.replace(u'\r\n', u'\n') self.VerseListWidget.clear() for row in verse_list.split(u'\n---\n'): - self.VerseListWidget.addItem(row) + bits = row.split(u'>\n') + item = QtGui.QListWidgetItem(bits[1]) + verse = bits[0][1:] + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse)) + self.VerseListWidget.addItem(item) self.VerseListWidget.repaint() def onVerseDeleteButtonClicked(self): @@ -456,10 +460,17 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = u' ' verse_order = u'' for i in range (0, self.VerseListWidget.count()): - sxml.add_verse_to_lyrics(u'Verse', unicode(count), + verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) + if len(verseId) <= 2: + type = u'Verse' + value = verseId + else: + type = verseId + value = 0 + sxml.add_verse_to_lyrics(type, verseId, unicode(self.VerseListWidget.item(i).text())) text = text + unicode(self.VerseListWidget.item(i).text()) + u' ' - verse_order = verse_order + unicode(count) + u' ' + verse_order = verse_order + verseId + u' ' count += 1 if self.song.verse_order is None: self.song.verse_order = verse_order From 5e2beba4eafb42968b1958d7af20c7324ad7bf9e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 23 Nov 2009 17:28:21 +0000 Subject: [PATCH 03/14] More song tagging changes --- openlp/plugins/songs/forms/editsongform.py | 6 ++++-- openlp/plugins/songs/forms/editverseform.py | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 2f0ef424c..f6c972bbc 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -322,10 +322,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.VerseListWidget.currentItem() if item: tempText = item.text() - verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) + verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) self.verse_form.setVerse(tempText, True, verseId) self.verse_form.exec_() - afterText = self.verse_form.getVerse() + afterText, verse, subVerse = self.verse_form.getVerse() + data = u'%s%s' %(verse , subVerse) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) #number of lines has change if len(tempText.split(u'\n')) != len(afterText.split(u'\n')): diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 2d13b5537..8aa6f3bd7 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -30,13 +30,21 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): """ This is the form that is used to edit the verses of the song. """ - def __init__(self, parent=None): """ Constructor """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) + QtCore.QObject.connect(self.VerseListComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onVerseListComboBoxChanged) + + def onVerseListComboBoxChanged(self, value): + if unicode(self.VerseListComboBox.currentText()).isdigit(): + self.SubVerseListComboBox.setEnabled(True) + else: + self.SubVerseListComboBox.setCurrentIndex(0) + self.SubVerseListComboBox.setEnabled(False) def setVerse(self, text, single=False, id=0): posVerse = 0 @@ -65,4 +73,6 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason) def getVerse(self): - return self.VerseTextEdit.toPlainText() + return self.VerseTextEdit.toPlainText(), \ + unicode(self.VerseListComboBox.currentText()), \ + unicode(self.SubVerseListComboBox.currentText()) From fe2d35a937d29ce98d04079de4bbb6fd22c5af0c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 23 Nov 2009 17:54:47 +0000 Subject: [PATCH 04/14] More song tagging changes - fixes --- openlp/plugins/songs/forms/editsongform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index f6c972bbc..3576252f7 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -347,7 +347,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for row in range(0, self.VerseListWidget.count()): item = self.VerseListWidget.item(row) verse_list += u'<%s>\n' % \ - unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) + unicode((item.data(QtCore.Qt.UserRole)).toString()) verse_list += item.text() verse_list += u'\n---\n' self.verse_form.setVerse(verse_list) From 1d359c750362a6ea6debc6a2721854208b654a85 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 26 Nov 2009 18:41:39 +0000 Subject: [PATCH 05/14] More Song tagging fixes --- openlp/core/ui/servicemanager.py | 4 +-- openlp/plugins/songs/forms/editsongform.py | 37 +++++++++++++++------ openlp/plugins/songs/forms/editverseform.py | 7 +++- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 8a927fc68..ba9764907 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -433,9 +433,9 @@ class ServiceManager(QtGui.QWidget): {u'serviceitem':item[u'service_item'].get_service_repr()}) if item[u'service_item'].service_item_type == ServiceItemType.Image or \ item[u'service_item'].service_item_type == ServiceItemType.Command: - for frame in item[u'service_item'].frames: + for frame in item[u'service_item'].get_frames: path_from = unicode(os.path.join( - item[u'service_item'].service_item_path, frame[u'title'])) + item[u'service_item'].service_item_path, frame.get_frame_title())) zip.write(path_from) file = open(servicefile, u'wb') cPickle.dump(service, file) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 3576252f7..dc279a460 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -23,6 +23,7 @@ ############################################################################### import logging +import re from PyQt4 import QtCore, QtGui @@ -110,6 +111,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.AuthorsListView.setAlternatingRowColors(True) self.TopicsListView.setSortingEnabled(False) self.TopicsListView.setAlternatingRowColors(True) + self.findVerseSplit = re.compile(u'---\[\]---\n', re.UNICODE) def initialise(self): self.VerseEditButton.setEnabled(False) @@ -346,23 +348,36 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.VerseListWidget.count() > 0: for row in range(0, self.VerseListWidget.count()): item = self.VerseListWidget.item(row) - verse_list += u'<%s>\n' % \ - unicode((item.data(QtCore.Qt.UserRole)).toString()) + field = unicode((item.data(QtCore.Qt.UserRole)).toString()) + if len(field) <= 2: + verse_list += u'---[v%s]---\n' % field + else: + verse_list += u'---[%s]---\n' % field verse_list += item.text() - verse_list += u'\n---\n' + verse_list += u'\n' self.verse_form.setVerse(verse_list) else: self.verse_form.setVerse(u'') if self.verse_form.exec_(): - verse_list = self.verse_form.getVerse() - verse_list = verse_list.replace(u'\r\n', u'\n') + verse_list = self.verse_form.getVerseAll() + verse_list = unicode(verse_list.replace(u'\r\n', u'\n')) self.VerseListWidget.clear() - for row in verse_list.split(u'\n---\n'): - bits = row.split(u'>\n') - item = QtGui.QListWidgetItem(bits[1]) - verse = bits[0][1:] - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse)) - self.VerseListWidget.addItem(item) + print self.findVerseSplit.split(verse_list) + for row in self.findVerseSplit.split(verse_list): + print row +# parts = unicode(row).split(u']---\n') +# print len(parts) , parts +# verse = u'' +# if len(parts) > 1: +# item = QtGui.QListWidgetItem(parts[1]) +# if parts[0][0].lower() == u'v': +# verse = parts[0][1:] +# else: +# verse = parts[0] +# else: +# item = QtGui.QListWidgetItem(parts[0]) +# item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse)) +# self.VerseListWidget.addItem(item) self.VerseListWidget.repaint() def onVerseDeleteButtonClicked(self): diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 8aa6f3bd7..c4209d590 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -51,7 +51,9 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): posSub = 0 if single: if len(id) <= 2: - if len(id) == 1: + if len(id) == 0: + pass + elif len(id) == 1: posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) else: posVerse = self.VerseListComboBox.findText(id[0], QtCore.Qt.MatchExactly) @@ -76,3 +78,6 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): return self.VerseTextEdit.toPlainText(), \ unicode(self.VerseListComboBox.currentText()), \ unicode(self.SubVerseListComboBox.currentText()) + + def getVerseAll(self): + return self.VerseTextEdit.toPlainText() From ab5b0ee0d5861f2590e0bda84da96b2bb9a0e019 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 27 Nov 2009 21:54:37 +0000 Subject: [PATCH 06/14] Amended plugin to use correct stat values Fixed bible media item to initialise in correct order Fixed servicemanager to use correct methods on service loading Sorted out lots of issues tagging the song verses --- openlp/core/lib/plugin.py | 6 +- openlp/core/ui/maindisplay.py | 36 +++--- openlp/core/ui/pluginform.py | 10 +- openlp/core/ui/slidecontroller.py | 26 ++--- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 25 ++--- openlp/plugins/songs/forms/editversedialog.py | 85 +++++++------- openlp/plugins/songs/forms/editverseform.py | 44 ++++---- resources/forms/editversedialog.ui | 104 ++++++++++-------- 9 files changed, 178 insertions(+), 160 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 38302cea1..ad2b9335f 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -31,9 +31,9 @@ class PluginStatus(object): """ Defines the status of the plugin """ - Active = 0 - Inactive = 1 - Disabled = 2 + Active = 1 + Inactive = 0 + Disabled = -1 class Plugin(QtCore.QObject): """ diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index a387deaef..72ded51f8 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -26,7 +26,7 @@ import logging import os from PyQt4 import QtCore, QtGui -from PyQt4.phonon import Phonon +#from PyQt4.phonon import Phonon from openlp.core.lib import Receiver @@ -92,13 +92,13 @@ class MainDisplay(DisplayWidget): self.layout.setSpacing(0) self.layout.setMargin(0) self.layout.setObjectName(u'layout') - self.mediaObject = Phonon.MediaObject(self) - self.video = Phonon.VideoWidget() - self.video.setVisible(False) - self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) - Phonon.createPath(self.mediaObject, self.video) - Phonon.createPath(self.mediaObject, self.audio) - self.layout.insertWidget(0, self.video) + #self.mediaObject = Phonon.MediaObject(self) + #self.video = Phonon.VideoWidget() + #self.video.setVisible(False) + #self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) + #Phonon.createPath(self.mediaObject, self.video) + #Phonon.createPath(self.mediaObject, self.audio) + #self.layout.insertWidget(0, self.video) self.display = QtGui.QLabel(self) self.display.setScaledContents(True) self.layout.insertWidget(0, self.display) @@ -116,16 +116,16 @@ class MainDisplay(DisplayWidget): QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_slide_show'), self.showDisplay) - QtCore.QObject.connect(self.mediaObject, - QtCore.SIGNAL(u'finished()'), self.onMediaFinish) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_start'), self.onMediaQueue) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_play'), self.onMediaPlay) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_pause'), self.onMediaPaws) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'media_stop'), self.onMediaStop) +# QtCore.QObject.connect(self.mediaObject, +# QtCore.SIGNAL(u'finished()'), self.onMediaFinish) +# QtCore.QObject.connect(Receiver.get_receiver(), +# QtCore.SIGNAL(u'media_start'), self.onMediaQueue) +# QtCore.QObject.connect(Receiver.get_receiver(), +# QtCore.SIGNAL(u'media_play'), self.onMediaPlay) +# QtCore.QObject.connect(Receiver.get_receiver(), +# QtCore.SIGNAL(u'media_pause'), self.onMediaPaws) +# QtCore.QObject.connect(Receiver.get_receiver(), +# QtCore.SIGNAL(u'media_stop'), self.onMediaStop) def setup(self, screenNumber): """ diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index a6b57e7c5..d230fe018 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -86,7 +86,10 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self.VersionNumberLabel.setText(self.activePlugin.version) self.AboutTextBrowser.setHtml(self.activePlugin.about()) self.programaticChange = True - self.StatusComboBox.setCurrentIndex(int(self.activePlugin.status)) + status = 1 + if self.activePlugin.status == PluginStatus.Active: + status = 0 + self.StatusComboBox.setCurrentIndex(status) self.StatusComboBox.setEnabled(True) self.programaticChange = False @@ -108,10 +111,11 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): def onStatusComboBoxChanged(self, status): if self.programaticChange: return - self.activePlugin.toggle_status(status) - if status == PluginStatus.Active: + if status == 0: + self.activePlugin.toggle_status(PluginStatus.Active) self.activePlugin.initialise() else: + self.activePlugin.toggle_status(PluginStatus.Inactive) self.activePlugin.finalise() status_text = 'Inactive' if self.activePlugin.status == PluginStatus.Active: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 9edf906b3..9d81c3cbf 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -26,7 +26,7 @@ import time import os from PyQt4 import QtCore, QtGui -from PyQt4.phonon import Phonon +#from PyQt4.phonon import Phonon from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, PluginConfig @@ -197,11 +197,11 @@ class SlideController(QtGui.QWidget): self.Mediabar.addToolbarButton( u'Media Stop', u':/slides/media_playback_stop.png', self.trUtf8(u'Start playing media'), self.onMediaStop) - self.volumeSlider = Phonon.VolumeSlider() - self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) - self.volumeSlider.setObjectName(u'volumeSlider') - self.Mediabar.addToolbarWidget( - u'Audio Volume', self.volumeSlider) + #self.volumeSlider = Phonon.VolumeSlider() + #self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) + #self.volumeSlider.setObjectName(u'volumeSlider') + #self.Mediabar.addToolbarWidget( + # u'Audio Volume', self.volumeSlider) self.ControllerLayout.addWidget(self.Mediabar) # Build the Song Toolbar if isLive: @@ -236,13 +236,13 @@ class SlideController(QtGui.QWidget): self.SlideLayout.setSpacing(0) self.SlideLayout.setMargin(0) self.SlideLayout.setObjectName(u'SlideLayout') - self.mediaObject = Phonon.MediaObject(self) - self.video = Phonon.VideoWidget() - self.video.setVisible(False) - self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) - Phonon.createPath(self.mediaObject, self.video) - Phonon.createPath(self.mediaObject, self.audio) - self.SlideLayout.insertWidget(0, self.video) + # self.mediaObject = Phonon.MediaObject(self) + #self.video = Phonon.VideoWidget() + #self.video.setVisible(False) + #self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) + #Phonon.createPath(self.mediaObject, self.video) + #Phonon.createPath(self.mediaObject, self.audio) + #self.SlideLayout.insertWidget(0, self.video) # Actual preview screen self.SlidePreview = QtGui.QLabel(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d2f469242..c15e5bfac 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -276,8 +276,8 @@ class BibleMediaItem(MediaManagerItem): def initialise(self): log.debug(u'bible manager initialise') - self.loadBibles() self.parent.biblemanager.media = self + self.loadBibles() self.configUpdated() log.debug(u'bible manager initialise complete') diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index dc279a460..db872184a 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -218,10 +218,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): songXML = SongXMLParser(self.song.lyrics) verseList = songXML.get_verses() for verse in verseList: - if verse[0][u'type'] == u'Verse': - variant = verse[0][u'label'] - else: - variant = verse[0][u'type'] + variant = u'%s:%s' % (verse[0][u'type'], verse[0][u'label']) item = QtGui.QListWidgetItem(verse[1]) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant)) self.VerseListWidget.addItem(item) @@ -328,7 +325,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verse_form.setVerse(tempText, True, verseId) self.verse_form.exec_() afterText, verse, subVerse = self.verse_form.getVerse() - data = u'%s%s' %(verse , subVerse) + data = u'%s:%s' %(verse , subVerse) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) #number of lines has change @@ -349,10 +346,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for row in range(0, self.VerseListWidget.count()): item = self.VerseListWidget.item(row) field = unicode((item.data(QtCore.Qt.UserRole)).toString()) - if len(field) <= 2: - verse_list += u'---[v%s]---\n' % field - else: - verse_list += u'---[%s]---\n' % field + verse_list += u'---[%s]---\n' % field verse_list += item.text() verse_list += u'\n' self.verse_form.setVerse(verse_list) @@ -477,15 +471,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = u' ' verse_order = u'' for i in range (0, self.VerseListWidget.count()): - verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) - if len(verseId) <= 2: - type = u'Verse' - value = verseId - else: - type = verseId - value = 0 - sxml.add_verse_to_lyrics(type, verseId, - unicode(self.VerseListWidget.item(i).text())) + item = self.VerseListWidget.item(i) + verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) + bits = verseId.split(u':') + sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) text = text + unicode(self.VerseListWidget.item(i).text()) + u' ' verse_order = verse_order + verseId + u' ' count += 1 diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index ca9b44fa3..b5dccf3dc 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'editversedialog.ui' # -# Created: Sun Nov 22 13:33:41 2009 -# by: PyQt4 UI code generator 4.5.4 +# Created: Fri Nov 27 18:35:12 2009 +# by: PyQt4 UI code generator 4.6.2 # # WARNING! All changes made in this file will be lost! @@ -15,7 +15,7 @@ class Ui_EditVerseDialog(object): EditVerseDialog.resize(492, 494) EditVerseDialog.setModal(True) self.widget = QtGui.QWidget(EditVerseDialog) - self.widget.setGeometry(QtCore.QRect(8, 11, 471, 461)) + self.widget.setGeometry(QtCore.QRect(9, 12, 471, 471)) self.widget.setObjectName("widget") self.verticalLayout = QtGui.QVBoxLayout(self.widget) self.verticalLayout.setObjectName("verticalLayout") @@ -23,35 +23,45 @@ class Ui_EditVerseDialog(object): self.horizontalLayout.setObjectName("horizontalLayout") self.VerseListComboBox = QtGui.QComboBox(self.widget) self.VerseListComboBox.setObjectName("VerseListComboBox") - self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem("") self.VerseListComboBox.setItemText(0, "") - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) - self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem("") + self.VerseListComboBox.addItem("") + self.VerseListComboBox.addItem("") self.horizontalLayout.addWidget(self.VerseListComboBox) self.SubVerseListComboBox = QtGui.QComboBox(self.widget) self.SubVerseListComboBox.setObjectName("SubVerseListComboBox") - self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem("") self.SubVerseListComboBox.setItemText(0, "") - self.SubVerseListComboBox.addItem(QtCore.QString()) - self.SubVerseListComboBox.addItem(QtCore.QString()) - self.SubVerseListComboBox.addItem(QtCore.QString()) - self.SubVerseListComboBox.addItem(QtCore.QString()) - self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") + self.SubVerseListComboBox.addItem("") self.horizontalLayout.addWidget(self.SubVerseListComboBox) self.verticalLayout.addLayout(self.horizontalLayout) self.VerseTextEdit = QtGui.QTextEdit(self.widget) self.VerseTextEdit.setAcceptRichText(False) self.VerseTextEdit.setObjectName("VerseTextEdit") self.verticalLayout.addWidget(self.VerseTextEdit) + self.horizontalLayout_2 = QtGui.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.addVerse = QtGui.QPushButton(self.widget) + self.addVerse.setObjectName("addVerse") + self.horizontalLayout_2.addWidget(self.addVerse) + self.addChorus = QtGui.QPushButton(self.widget) + self.addChorus.setObjectName("addChorus") + self.horizontalLayout_2.addWidget(self.addChorus) + self.addBridge = QtGui.QPushButton(self.widget) + self.addBridge.setObjectName("addBridge") + self.horizontalLayout_2.addWidget(self.addBridge) + self.verticalLayout.addLayout(self.horizontalLayout_2) self.ButtonBox = QtGui.QDialogButtonBox(self.widget) self.ButtonBox.setOrientation(QtCore.Qt.Horizontal) self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) @@ -65,20 +75,21 @@ class Ui_EditVerseDialog(object): def retranslateUi(self, EditVerseDialog): EditVerseDialog.setWindowTitle(QtGui.QApplication.translate("EditVerseDialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "Chorus", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "Bridge", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "1", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "2", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "3", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(6, QtGui.QApplication.translate("EditVerseDialog", "4", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(7, QtGui.QApplication.translate("EditVerseDialog", "5", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(8, QtGui.QApplication.translate("EditVerseDialog", "6", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(9, QtGui.QApplication.translate("EditVerseDialog", "7", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(11, QtGui.QApplication.translate("EditVerseDialog", "9", None, QtGui.QApplication.UnicodeUTF8)) - self.VerseListComboBox.setItemText(10, QtGui.QApplication.translate("EditVerseDialog", "8", None, QtGui.QApplication.UnicodeUTF8)) - self.SubVerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "a", None, QtGui.QApplication.UnicodeUTF8)) - self.SubVerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "b", None, QtGui.QApplication.UnicodeUTF8)) - self.SubVerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "c", None, QtGui.QApplication.UnicodeUTF8)) - self.SubVerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "d", None, QtGui.QApplication.UnicodeUTF8)) - self.SubVerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "e", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "Verse", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "Chorus", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "Bridge", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "1", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "1a", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "1b", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "2", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "2a", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(6, QtGui.QApplication.translate("EditVerseDialog", "2b", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(7, QtGui.QApplication.translate("EditVerseDialog", "3", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(8, QtGui.QApplication.translate("EditVerseDialog", "4", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(9, QtGui.QApplication.translate("EditVerseDialog", "5", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(10, QtGui.QApplication.translate("EditVerseDialog", "6", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(11, QtGui.QApplication.translate("EditVerseDialog", "7", None, QtGui.QApplication.UnicodeUTF8)) + self.addVerse.setText(QtGui.QApplication.translate("EditVerseDialog", "Verse", None, QtGui.QApplication.UnicodeUTF8)) + self.addChorus.setText(QtGui.QApplication.translate("EditVerseDialog", "Chorus", None, QtGui.QApplication.UnicodeUTF8)) + self.addBridge.setText(QtGui.QApplication.translate("EditVerseDialog", "Bridge", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index c4209d590..b639f16ed 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -23,7 +23,6 @@ ############################################################################### from PyQt4 import QtCore, QtGui - from editversedialog import Ui_EditVerseDialog class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): @@ -36,39 +35,44 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - QtCore.QObject.connect(self.VerseListComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onVerseListComboBoxChanged) + QtCore.QObject.connect(self.addVerse, + QtCore.SIGNAL(u'clicked()'), self.onAddVerse) + QtCore.QObject.connect(self.addChorus, + QtCore.SIGNAL(u'clicked()'), self.onAddChorus) + QtCore.QObject.connect(self.addBridge, + QtCore.SIGNAL(u'clicked()'), self.onAddBridge) - def onVerseListComboBoxChanged(self, value): - if unicode(self.VerseListComboBox.currentText()).isdigit(): - self.SubVerseListComboBox.setEnabled(True) - else: - self.SubVerseListComboBox.setCurrentIndex(0) - self.SubVerseListComboBox.setEnabled(False) + def onAddBridge(self): + self.VerseTextEdit.insertPlainText(u'---[Bridge:1]---\n') - def setVerse(self, text, single=False, id=0): + def onAddChorus(self): + self.VerseTextEdit.insertPlainText(u'---[Chorus:1]---\n') + + def onAddVerse(self): + self.VerseTextEdit.insertPlainText(u'---[Verse:1]---\n') + + def setVerse(self, text, single=False, tag=0): posVerse = 0 posSub = 0 if single: - if len(id) <= 2: - if len(id) == 0: - pass - elif len(id) == 1: - posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) - else: - posVerse = self.VerseListComboBox.findText(id[0], QtCore.Qt.MatchExactly) - posSub = self.SubVerseListComboBox.findText(id[1], QtCore.Qt.MatchExactly) - else: - posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) + id = tag.split(u':') + posVerse = self.VerseListComboBox.findText(id[0], QtCore.Qt.MatchExactly) + posSub = self.SubVerseListComboBox.findText(id[1], QtCore.Qt.MatchExactly) if posVerse == -1: posVerse = 0 if posSub == -1: posSub = 0 self.VerseListComboBox.setEnabled(True) self.SubVerseListComboBox.setEnabled(True) + self.addBridge.setEnabled(False) + self.addChorus.setEnabled(False) + self.addVerse.setEnabled(False) else: self.VerseListComboBox.setEnabled(False) self.SubVerseListComboBox.setEnabled(False) + self.addBridge.setEnabled(True) + self.addChorus.setEnabled(True) + self.addVerse.setEnabled(True) self.VerseListComboBox.setCurrentIndex(posVerse) self.SubVerseListComboBox.setCurrentIndex(posSub) self.VerseTextEdit.setPlainText(text) diff --git a/resources/forms/editversedialog.ui b/resources/forms/editversedialog.ui index 822807f1b..e629eaa87 100644 --- a/resources/forms/editversedialog.ui +++ b/resources/forms/editversedialog.ui @@ -19,10 +19,10 @@ - 8 - 11 + 9 + 12 471 - 461 + 471 @@ -50,16 +50,45 @@ Bridge + + + + + + + + + 1 + + + 1a + + + + + 1b + + 2 + + + 2a + + + + + 2b + + 3 @@ -85,50 +114,6 @@ 7 - - - 9 - - - - - 8 - - - - - - - - - - - - - - a - - - - - b - - - - - c - - - - - d - - - - - e - - @@ -140,6 +125,31 @@ + + + + + + Verse + + + + + + + Chorus + + + + + + + Bridge + + + + + From 23d945a4541d21260321a13f647fd8888a81e702 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 28 Nov 2009 06:49:53 +0000 Subject: [PATCH 07/14] Replace phonon code, add framework for transitions --- openlp/core/lib/renderer.py | 2 +- openlp/core/ui/maindisplay.py | 50 +++++++++++----------- openlp/core/ui/slidecontroller.py | 30 ++++++------- openlp/plugins/songs/forms/editsongform.py | 2 +- 4 files changed, 41 insertions(+), 43 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f825498df..69252ecde 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -261,7 +261,7 @@ class Renderer(object): bbox = self._render_lines_unaligned(footer_lines, True, (self._rect_footer.left(), self._rect_footer.top()), True) log.debug(u'generate_frame_from_lines - Finish') - return self._frame + return {u'main':self._frame, u'trans':None} def _generate_background_frame(self): """ diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 72ded51f8..8e35ed896 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -26,7 +26,7 @@ import logging import os from PyQt4 import QtCore, QtGui -#from PyQt4.phonon import Phonon +from PyQt4.phonon import Phonon from openlp.core.lib import Receiver @@ -92,13 +92,13 @@ class MainDisplay(DisplayWidget): self.layout.setSpacing(0) self.layout.setMargin(0) self.layout.setObjectName(u'layout') - #self.mediaObject = Phonon.MediaObject(self) - #self.video = Phonon.VideoWidget() - #self.video.setVisible(False) - #self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) - #Phonon.createPath(self.mediaObject, self.video) - #Phonon.createPath(self.mediaObject, self.audio) - #self.layout.insertWidget(0, self.video) + self.mediaObject = Phonon.MediaObject(self) + self.video = Phonon.VideoWidget() + self.video.setVisible(False) + self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) + Phonon.createPath(self.mediaObject, self.video) + Phonon.createPath(self.mediaObject, self.audio) + self.layout.insertWidget(0, self.video) self.display = QtGui.QLabel(self) self.display.setScaledContents(True) self.layout.insertWidget(0, self.display) @@ -116,16 +116,16 @@ class MainDisplay(DisplayWidget): QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'live_slide_show'), self.showDisplay) -# QtCore.QObject.connect(self.mediaObject, -# QtCore.SIGNAL(u'finished()'), self.onMediaFinish) -# QtCore.QObject.connect(Receiver.get_receiver(), -# QtCore.SIGNAL(u'media_start'), self.onMediaQueue) -# QtCore.QObject.connect(Receiver.get_receiver(), -# QtCore.SIGNAL(u'media_play'), self.onMediaPlay) -# QtCore.QObject.connect(Receiver.get_receiver(), -# QtCore.SIGNAL(u'media_pause'), self.onMediaPaws) -# QtCore.QObject.connect(Receiver.get_receiver(), -# QtCore.SIGNAL(u'media_stop'), self.onMediaStop) + QtCore.QObject.connect(self.mediaObject, + QtCore.SIGNAL(u'finished()'), self.onMediaFinish) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_start'), self.onMediaQueue) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_play'), self.onMediaPlay) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_pause'), self.onMediaPaws) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'media_stop'), self.onMediaStop) def setup(self, screenNumber): """ @@ -183,27 +183,25 @@ class MainDisplay(DisplayWidget): if not self.primary: self.setVisible(True) - def frameView(self, frame): + def frameView(self, frame, transition=False): """ Called from a slide controller to display a frame if the alert is in progress the alert is added on top ``frame`` Image frame to be rendered """ - self.frame = frame if self.timer_id != 0 : self.displayAlert() elif not self.displayBlank: -# self.setWindowOpacity(0.5) -# self.show() - self.display.setPixmap(QtGui.QPixmap.fromImage(frame)) + if transition: + self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) + else: + self.display.setPixmap(QtGui.QPixmap.fromImage(frame)) # QtCore.QTimer.singleShot(500, self.aa ) if not self.isVisible(): self.setVisible(True) self.showFullScreen() -# -# def aa(self): -# self.setWindowOpacity(1) + self.frame = frame def blankDisplay(self, blanked=True): if blanked: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 9d81c3cbf..5bb9a8765 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -26,7 +26,7 @@ import time import os from PyQt4 import QtCore, QtGui -#from PyQt4.phonon import Phonon +from PyQt4.phonon import Phonon from openlp.core.lib import OpenLPToolbar, Receiver, str_to_bool, PluginConfig @@ -197,11 +197,11 @@ class SlideController(QtGui.QWidget): self.Mediabar.addToolbarButton( u'Media Stop', u':/slides/media_playback_stop.png', self.trUtf8(u'Start playing media'), self.onMediaStop) - #self.volumeSlider = Phonon.VolumeSlider() - #self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) - #self.volumeSlider.setObjectName(u'volumeSlider') - #self.Mediabar.addToolbarWidget( - # u'Audio Volume', self.volumeSlider) + self.volumeSlider = Phonon.VolumeSlider() + self.volumeSlider.setGeometry(QtCore.QRect(90, 260, 221, 24)) + self.volumeSlider.setObjectName(u'volumeSlider') + self.Mediabar.addToolbarWidget( + u'Audio Volume', self.volumeSlider) self.ControllerLayout.addWidget(self.Mediabar) # Build the Song Toolbar if isLive: @@ -236,13 +236,13 @@ class SlideController(QtGui.QWidget): self.SlideLayout.setSpacing(0) self.SlideLayout.setMargin(0) self.SlideLayout.setObjectName(u'SlideLayout') - # self.mediaObject = Phonon.MediaObject(self) - #self.video = Phonon.VideoWidget() - #self.video.setVisible(False) - #self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) - #Phonon.createPath(self.mediaObject, self.video) - #Phonon.createPath(self.mediaObject, self.audio) - #self.SlideLayout.insertWidget(0, self.video) + self.mediaObject = Phonon.MediaObject(self) + self.video = Phonon.VideoWidget() + self.video.setVisible(False) + self.audio = Phonon.AudioOutput(Phonon.VideoCategory, self.mediaObject) + Phonon.createPath(self.mediaObject, self.video) + Phonon.createPath(self.mediaObject, self.audio) + self.SlideLayout.insertWidget(0, self.video) # Actual preview screen self.SlidePreview = QtGui.QLabel(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, @@ -517,10 +517,10 @@ class SlideController(QtGui.QWidget): else: before = time.time() frame = self.serviceItem.get_rendered_frame(row) - self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) + self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) log.log(15, u'Slide Rendering took %4s' % (time.time() - before)) if self.isLive: - self.parent.mainDisplay.frameView(frame) + self.parent.mainDisplay.frameView(frame, True) self.selectedRow = row def onSlideChange(self, row): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index db872184a..58e1ecf79 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -325,7 +325,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.verse_form.setVerse(tempText, True, verseId) self.verse_form.exec_() afterText, verse, subVerse = self.verse_form.getVerse() - data = u'%s:%s' %(verse , subVerse) + data = u'%s:%s' %(verse, subVerse) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) #number of lines has change From 2247d01d6fb3f0b88cdc4855b6f6f88ed21e8689 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 28 Nov 2009 07:50:12 +0000 Subject: [PATCH 08/14] Verse Tag editing - Add, Edit, Edit All and save work --- openlp/plugins/songs/forms/editsongform.py | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 58e1ecf79..21cf1fefc 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -226,7 +226,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verses = self.song.lyrics.split(u'\n\n') for count, verse in enumerate(verses): item = QtGui.QListWidgetItem(verse) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(count + 1)) + variant = u'Verse:%s' % count + 1 + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant)) self.VerseListWidget.addItem(item) # clear the results self.AuthorsListView.clear() @@ -315,7 +316,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def onVerseAddButtonClicked(self): self.verse_form.setVerse(u'') self.verse_form.exec_() - self.VerseListWidget.addItem(self.verse_form.getVerse()) + afterText, verse, subVerse = self.verse_form.getVerse() + data = u'%s:%s' %(verse, subVerse) + item = QtGui.QListWidgetItem(afterText) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) + item.setText(afterText) + self.VerseListWidget.addItem(item) def onVerseEditButtonClicked(self): item = self.VerseListWidget.currentItem() @@ -356,22 +362,18 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): verse_list = self.verse_form.getVerseAll() verse_list = unicode(verse_list.replace(u'\r\n', u'\n')) self.VerseListWidget.clear() - print self.findVerseSplit.split(verse_list) for row in self.findVerseSplit.split(verse_list): - print row -# parts = unicode(row).split(u']---\n') -# print len(parts) , parts -# verse = u'' -# if len(parts) > 1: -# item = QtGui.QListWidgetItem(parts[1]) -# if parts[0][0].lower() == u'v': -# verse = parts[0][1:] -# else: -# verse = parts[0] -# else: -# item = QtGui.QListWidgetItem(parts[0]) -# item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse)) -# self.VerseListWidget.addItem(item) + for match in row.split(u'---['): + for count, parts in enumerate(match.split(u']---\n')): + if len(parts) > 1: + if count == 0: + variant = parts + else: + if parts.endswith(u'\n'): + parts = parts.rstrip(u'\n') + item = QtGui.QListWidgetItem(parts) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant)) + self.VerseListWidget.addItem(item) self.VerseListWidget.repaint() def onVerseDeleteButtonClicked(self): From 1c60a29d686bed0afb4ed8aa8c53629ced846d49 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 28 Nov 2009 09:12:22 +0000 Subject: [PATCH 09/14] Basic Tranisitions --- openlp/core/lib/renderer.py | 22 +++++++++++++++++++++- openlp/core/ui/maindisplay.py | 14 +++++++++++++- openlp/core/ui/slidecontroller.py | 16 ++++++++-------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 69252ecde..d41fc988b 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -49,6 +49,7 @@ class Renderer(object): self._theme = None self._bg_image_filename = None self._frame = None + self._frameOp = None self.bg_frame = None self.bg_image = None @@ -134,6 +135,8 @@ class Renderer(object): frame_height) self._frame = QtGui.QImage(frame_width, frame_height, QtGui.QImage.Format_ARGB32_Premultiplied) + self._frameOp = QtGui.QImage(frame_width, frame_height, + QtGui.QImage.Format_ARGB32_Premultiplied) if self._bg_image_filename and not self.bg_image: self.scale_bg_image() if self.bg_frame is None: @@ -255,13 +258,14 @@ class Renderer(object): bbox1 = self._render_lines_unaligned(footer_lines, True) # reset the frame. first time do not worry about what you paint on. self._frame = QtGui.QImage(self.bg_frame) + self._frameOp = QtGui.QImage(self.bg_frame) x, y = self._correctAlignment(self._rect, bbox) bbox = self._render_lines_unaligned(lines, False, (x, y), True) if footer_lines: bbox = self._render_lines_unaligned(footer_lines, True, (self._rect_footer.left(), self._rect_footer.top()), True) log.debug(u'generate_frame_from_lines - Finish') - return {u'main':self._frame, u'trans':None} + return {u'main':self._frame, u'trans':self._frameOp} def _generate_background_frame(self): """ @@ -569,6 +573,22 @@ class Renderer(object): if draw: painter.drawText(x, y + metrics.ascent(), line) painter.end() + # Print 2nd image with 50% weight + painter = QtGui.QPainter() + painter.begin(self._frameOp) + painter.setRenderHint(QtGui.QPainter.Antialiasing); + painter.setOpacity(0.5) + painter.setFont(font) + if color is None: + if footer: + painter.setPen(QtGui.QColor(self._theme.font_footer_color)) + else: + painter.setPen(QtGui.QColor(self._theme.font_main_color)) + else: + painter.setPen(QtGui.QColor(color)) + if draw: + painter.drawText(x, y + metrics.ascent(), line) + painter.end() return (w, h) def snoop_Image(self, image, image2=None): diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 8e35ed896..20574ab2e 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -24,6 +24,7 @@ import logging import os +import time from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon @@ -110,6 +111,7 @@ class MainDisplay(DisplayWidget): self.timer_id = 0 self.firstTime = True self.mediaLoaded = False + self.hasTransition = False QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'alert_text'), self.displayAlert) QtCore.QObject.connect(Receiver.get_receiver(), @@ -127,6 +129,7 @@ class MainDisplay(DisplayWidget): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'media_stop'), self.onMediaStop) + def setup(self, screenNumber): """ Sets up the screen on a particular screen. @@ -194,10 +197,19 @@ class MainDisplay(DisplayWidget): self.displayAlert() elif not self.displayBlank: if transition: + if self.hasTransition: + delay = 0.1 + self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame[u'trans'])) + self.repaint() + time.sleep(delay) + self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'trans'])) + self.repaint() + time.sleep(delay) + self.hasTransition = True self.display.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) + self.repaint() else: self.display.setPixmap(QtGui.QPixmap.fromImage(frame)) -# QtCore.QTimer.singleShot(500, self.aa ) if not self.isVisible(): self.setVisible(True) self.showFullScreen() diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 5bb9a8765..3cd440c5b 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -352,14 +352,14 @@ class SlideController(QtGui.QWidget): self.Songbar.actions[action].setVisible(False) if item.verse_order: verses = item.verse_order.split(u' ') - for verse in verses: - if not verse or int(verse) > 12: - break - try: - self.Songbar.actions[verse].setVisible(True) - except: - #More than 20 verses hard luck - pass +# for verse in verses: +# if not verse or int(verse) > 12: +# break +# try: +# self.Songbar.actions[verse].setVisible(True) +# except: +# #More than 20 verses hard luck +# pass self.Songbar.setVisible(True) elif item.is_image(): #Not sensible to allow loops with 1 frame From d0a49ba3a1691f66c8b2ce5682f66a3bcb774357 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 28 Nov 2009 12:38:48 +0000 Subject: [PATCH 10/14] Song taagging into Slide Controller --- openlp/core/lib/serviceitem.py | 7 ++++--- openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/slidecontroller.py | 2 ++ openlp/plugins/songs/lib/mediaitem.py | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 27e16e95f..41b450490 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -104,7 +104,8 @@ class ServiceItem(object): for line in format: lines += line + u'\n' title = lines.split(u'\n')[0] - self._display_frames.append({u'title': title, u'text': lines}) + self._display_frames.append({u'title': title, \ + u'text': lines, u'verseTag': slide[u'verseTag'] }) log.log(15, u'Formatting took %4s' % (time.time() - before)) elif self.service_item_type == ServiceItemType.Image: for slide in self._raw_frames: @@ -147,7 +148,7 @@ class ServiceItem(object): self._raw_frames.append( {u'title': title, u'image': image}) - def add_from_text(self, title, raw_slide): + def add_from_text(self, title, raw_slide, verseTag=None): """ Add a text slide to the service item. @@ -160,7 +161,7 @@ class ServiceItem(object): self.service_item_type = ServiceItemType.Text title = title.split(u'\n')[0] self._raw_frames.append( - {u'title': title, u'raw_slide': raw_slide}) + {u'title': title, u'raw_slide': raw_slide, u'verseTag':verseTag}) def add_from_command(self, path, file_name, image): """ diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 20574ab2e..b7f5f31b6 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -198,7 +198,7 @@ class MainDisplay(DisplayWidget): elif not self.displayBlank: if transition: if self.hasTransition: - delay = 0.1 + delay = 0.01 self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame[u'trans'])) self.repaint() time.sleep(delay) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 3cd440c5b..89b7930f7 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -456,6 +456,8 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.setCellWidget(framenumber, 0, label) slide_height = width * self.parent.RenderManager.screen_ratio else: + variant = u'%s:%s' % (verse[0][u'type'], verse[0][u'label']) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(frame[u'text'])) item.setText(frame[u'text']) self.PreviewListWidget.setItem(framenumber, 0, item) if slide_height != 0: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 000f752af..4c2198d4b 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -295,7 +295,8 @@ class SongMediaItem(MediaManagerItem): verseList = songXML.get_verses() for verse in verseList: if verse[1]: - service_item.add_from_text(verse[1][:30], verse[1]) + verseTag = u'%s:%s' % (verse[0][u'type'], verse[0][u'label']) + service_item.add_from_text(verse[1][:30], verse[1], verseTag) else: verses = song.lyrics.split(u'\n\n') for slide in verses: From 829e4976e2d77515c612e3045efe791d4aec0271 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 29 Nov 2009 08:33:46 +0000 Subject: [PATCH 11/14] Slide Controller refactoring ready for Verse changes --- openlp/core/ui/slidecontroller.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 89b7930f7..167d8d653 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -89,6 +89,7 @@ class SlideController(QtGui.QWidget): self.selectedRow = 0 self.serviceItem = None self.Panel = QtGui.QWidget(parent.ControlSplitter) + self.slideList = {} # Layout for holding panel self.PanelLayout = QtGui.QVBoxLayout(self.Panel) self.PanelLayout.setSpacing(0) @@ -416,7 +417,6 @@ class SlideController(QtGui.QWidget): #If old item was a command tell it to stop if self.serviceItem and self.serviceItem.is_command(): self.onMediaStop() - self.enableToolBar(item) if item.is_command(): if self.isLive: Receiver.send_message(u'%s_start' % item.name.lower(), \ @@ -427,17 +427,18 @@ class SlideController(QtGui.QWidget): self.onMediaStart(item) self.displayServiceManagerItems(item, slideno) - def displayServiceManagerItems(self, serviceitem, slideno): + def displayServiceManagerItems(self, serviceItem, slideno): """ Loads a ServiceItem into the system from ServiceManager Display the slide number passed """ log.debug(u'displayServiceManagerItems Start') + self.slideList = {} width = self.parent.ControlSplitter.sizes()[self.split] #Set pointing cursor when we have somthing to point at self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor) before = time.time() - self.serviceItem = serviceitem + self.serviceItem = serviceItem self.PreviewListWidget.clear() self.PreviewListWidget.setRowCount(0) self.PreviewListWidget.setColumnWidth(0, width) @@ -446,8 +447,11 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.rowCount() + 1) item = QtGui.QTableWidgetItem() slide_height = 0 - #It is a Image - if not self.serviceItem.is_text(): + #It is a based Text Render + if self.serviceItem.is_text(): + self.slideList[frame[u'verseTag']] = framenumber + item.setText(frame[u'text']) + else: label = QtGui.QLabel() label.setMargin(4) pixmap = self.parent.RenderManager.resize_image(frame[u'image']) @@ -455,10 +459,6 @@ class SlideController(QtGui.QWidget): label.setPixmap(QtGui.QPixmap.fromImage(pixmap)) self.PreviewListWidget.setCellWidget(framenumber, 0, label) slide_height = width * self.parent.RenderManager.screen_ratio - else: - variant = u'%s:%s' % (verse[0][u'type'], verse[0][u'label']) - item.setData(QtCore.Qt.UserRole, QtCore.QVariant(frame[u'text'])) - item.setText(frame[u'text']) self.PreviewListWidget.setItem(framenumber, 0, item) if slide_height != 0: self.PreviewListWidget.setRowHeight(framenumber, slide_height) @@ -470,12 +470,14 @@ class SlideController(QtGui.QWidget): self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount()) else: self.PreviewListWidget.selectRow(slideno) + self.enableToolBar(serviceItem) self.onSlideSelected() self.PreviewListWidget.setFocus() log.log(15, u'Display Rendering took %4s' % (time.time() - before)) if self.isLive: self.serviceItem.request_audit() log.debug(u'displayServiceManagerItems End') + print self.slideList #Screen event methods def onSlideSelectedFirst(self): From ff8ab8f14f2b1586cc88db7db7b2114895e98bf6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 29 Nov 2009 14:06:41 +0000 Subject: [PATCH 12/14] Fix song editing validation --- openlp/plugins/songs/forms/editsongform.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 21cf1fefc..9ae9c4b38 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -400,6 +400,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.SongTabWidget.setCurrentIndex(2) self.AuthorsListView.setFocus() return False, self.trUtf8(u'You need to provide at least one author.') + for verse in unicode(self.VerseOrderEdit.text()): + if verse.isdigit() or u' BC'.find(verse) > -1: + pass + else: + self.SongTabWidget.setCurrentIndex(0) + self.VerseOrderEdit.setFocus() + return False, \ + self.trUtf8('Invalid verse entry - values must be Numberic, B or C') return True, u'' def onTitleEditItemLostFocus(self): From f46cd2c6cb4f94604f53df58f07920deecc79e67 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 29 Nov 2009 18:21:40 +0000 Subject: [PATCH 13/14] Song validation changes --- openlp/plugins/songs/forms/editsongform.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 9ae9c4b38..40e84fafd 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -407,7 +407,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.SongTabWidget.setCurrentIndex(0) self.VerseOrderEdit.setFocus() return False, \ - self.trUtf8('Invalid verse entry - values must be Numberic, B or C') + self.trUtf8('Invalid verse entry - values must be Numeric, B or C') return True, u'' def onTitleEditItemLostFocus(self): @@ -479,17 +479,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): sxml.add_lyrics_to_song() count = 1 text = u' ' - verse_order = u'' for i in range (0, self.VerseListWidget.count()): item = self.VerseListWidget.item(i) verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()) bits = verseId.split(u':') sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text())) text = text + unicode(self.VerseListWidget.item(i).text()) + u' ' - verse_order = verse_order + verseId + u' ' count += 1 - if self.song.verse_order is None: - self.song.verse_order = verse_order text = text.replace(u'\'', u'') text = text.replace(u',', u'') text = text.replace(u';', u'') From 77b0da2c41d814f05b30530338364ab3f03ef4f6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 29 Nov 2009 19:00:10 +0000 Subject: [PATCH 14/14] Tidy ups pre merge --- openlp/core/ui/slidecontroller.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 167d8d653..83b67e7a0 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -477,7 +477,6 @@ class SlideController(QtGui.QWidget): if self.isLive: self.serviceItem.request_audit() log.debug(u'displayServiceManagerItems End') - print self.slideList #Screen event methods def onSlideSelectedFirst(self):