From 4f857f89216733c15bb74a0a127f145fe04975e7 Mon Sep 17 00:00:00 2001 From: Stevan Pettit Date: Wed, 25 May 2011 23:34:42 -0400 Subject: [PATCH 1/7] modified: openlp/plugins/custom/forms/editcustomform.py openlp/plugins/custom/lib/mediaitem.py openlp/plugins/songs/forms/editsongform.py openlp/plugins/songs/lib/mediaitem.py --- openlp/plugins/custom/forms/editcustomform.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 6 ++---- openlp/plugins/songs/lib/mediaitem.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 64147e874..e8b43d3ab 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -116,7 +116,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): log.debug(u'accept') if self.saveCustom(): Receiver.send_message(u'custom_set_autoselect_item', - self.customSlide.title) + self.customSlide.id) Receiver.send_message(u'custom_load_list') QtGui.QDialog.accept(self) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 64ddf2374..e3741ae84 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -147,7 +147,7 @@ class CustomMediaItem(MediaManagerItem): QtCore.Qt.UserRole, QtCore.QVariant(custom_slide.id)) self.listView.addItem(custom_name) # Auto-select the item if name has been set - if custom_slide.title == self.autoSelectItem: + if custom_slide.id == self.autoSelectItem: self.listView.setCurrentItem(custom_name) def onNewClick(self): diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 8411aa488..f66bc15ad 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -696,9 +696,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.clearCaches() if self._validate_song(): self.saveSong() - Receiver.send_message(u'songs_set_autoselect_item', - unicode(self.titleEdit.text())) + Receiver.send_message(u'songs_set_autoselect_item',self.song.id) Receiver.send_message(u'songs_load_list') + self.song = None QtGui.QDialog.accept(self) def saveSong(self, preview=False): @@ -756,8 +756,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.topics.append(self.manager.get_object(Topic, topicId)) clean_song(self.manager, self.song) self.manager.save_object(self.song) - if not preview: - self.song = None def _processLyrics(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 7ea1658fc..4b88d81c3 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -242,7 +242,7 @@ class SongMediaItem(MediaManagerItem): song_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(song.id)) self.listView.addItem(song_name) # Auto-select the item if name has been set - if song.title == self.autoSelectItem : + if song.id == self.autoSelectItem : self.listView.setCurrentItem(song_name) def displayResultsAuthor(self, searchresults): From bfd70025920082a59f64fcdd25b52c9259b4edda Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 08:39:03 +0200 Subject: [PATCH 2/7] r1571 From aae9724f349bdd6ab21b1888f25e2007c493ffc5 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 08:45:22 +0200 Subject: [PATCH 3/7] allow html tags to be translated Fixes: https://launchpad.net/bugs/787552 --- openlp/core/lib/__init__.py | 52 ---------------------- openlp/core/lib/displaytags.py | 74 +++++++++++++++++++++++++++++--- openlp/core/ui/displaytagform.py | 16 ++++--- 3 files changed, 78 insertions(+), 64 deletions(-) diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index e65271e03..d040244f7 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -36,58 +36,6 @@ from PyQt4 import QtCore, QtGui log = logging.getLogger(__name__) -base_html_expands = [] - -# Hex Color tags from http://www.w3schools.com/html/html_colornames.asp -base_html_expands.append({u'desc': u'Red', u'start tag': u'{r}', - u'start html': u'', - u'end tag': u'{/r}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Black', u'start tag': u'{b}', - u'start html': u'', - u'end tag': u'{/b}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}', - u'start html': u'', - u'end tag': u'{/bl}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}', - u'start html': u'', - u'end tag': u'{/y}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Green', u'start tag': u'{g}', - u'start html': u'', - u'end tag': u'{/g}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}', - u'start html': u'', - u'end tag': u'{/pk}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Orange', u'start tag': u'{o}', - u'start html': u'', - u'end tag': u'{/o}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}', - u'start html': u'', - u'end tag': u'{/pp}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'White', u'start tag': u'{w}', - u'start html': u'', - u'end tag': u'{/w}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}', - u'start html': u'', u'end tag': u'{/su}', u'end html': u'', - u'protected': True}) -base_html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}', - u'start html': u'', u'end tag': u'{/sb}', u'end html': u'', - u'protected': True}) -base_html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}', - u'start html': u'

', u'end tag': u'{/p}', u'end html': u'

', - u'protected': True}) -base_html_expands.append({u'desc': u'Bold', u'start tag': u'{st}', - u'start html': u'', u'end tag': u'{/st}', u'end html': u'', - u'protected': True}) -base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}', - u'start html': u'', u'end tag': u'{/it}', u'end html': u'', - u'protected': True}) -base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}', - u'start html': u'', - u'end tag': u'{/u}', u'end html': u'', u'protected': True}) -base_html_expands.append({u'desc': u'Break', u'start tag': u'{br}', - u'start html': u'
', u'end tag': u'', u'end html': u'', - u'protected': True}) - def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, translate=QtCore.QCoreApplication.translate): diff --git a/openlp/core/lib/displaytags.py b/openlp/core/lib/displaytags.py index 38112f661..3404455f7 100644 --- a/openlp/core/lib/displaytags.py +++ b/openlp/core/lib/displaytags.py @@ -28,7 +28,7 @@ Provide Html Tag management and Display Tag access class """ -from openlp.core.lib import base_html_expands +from openlp.core.lib import translate class DisplayTags(object): """ @@ -50,15 +50,77 @@ class DisplayTags(object): Resets the html_expands list. """ DisplayTags.html_expands = [] - for html in base_html_expands: - DisplayTags.html_expands.append(html) + base_tags = [] + # Append the base tags. + # Hex Color tags from http://www.w3schools.com/html/html_colornames.asp + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Red'), + u'start tag': u'{r}', + u'start html': u'', + u'end tag': u'{/r}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Black'), + u'start tag': u'{b}', + u'start html': u'', + u'end tag': u'{/b}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Blue'), + u'start tag': u'{bl}', + u'start html': u'', + u'end tag': u'{/bl}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Yellow'), + u'start tag': u'{y}', + u'start html': u'', + u'end tag': u'{/y}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Green'), + u'start tag': u'{g}', + u'start html': u'', + u'end tag': u'{/g}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Pink'), + u'start tag': u'{pk}', + u'start html': u'', + u'end tag': u'{/pk}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Orange'), + u'start tag': u'{o}', + u'start html': u'', + u'end tag': u'{/o}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Purple'), + u'start tag': u'{pp}', + u'start html': u'', + u'end tag': u'{/pp}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'White'), + u'start tag': u'{w}', + u'start html': u'', + u'end tag': u'{/w}', u'end html': u'', u'protected': True}) + base_tags.append({ + u'desc': translate('OpenLP.DisplayTags', 'Superscript'), + u'start tag': u'{su}', u'start html': u'', + u'end tag': u'{/su}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Subscript'), + u'start tag': u'{sb}', u'start html': u'', + u'end tag': u'{/sb}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Paragraph'), + u'start tag': u'{p}', u'start html': u'

', u'end tag': u'{/p}', + u'end html': u'

', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Bold'), + u'start tag': u'{st}', u'start html': u'', + u'end tag': u'{/st}', u'end html': u'', + u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Italics'), + u'start tag': u'{it}', u'start html': u'', u'end tag': u'{/it}', + u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Underline'), + u'start tag': u'{u}', + u'start html': u'', + u'end tag': u'{/u}', u'end html': u'', u'protected': True}) + base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Break'), + u'start tag': u'{br}', u'start html': u'
', u'end tag': u'', + u'end html': u'', u'protected': True}) + DisplayTags.add_html_tags(base_tags) @staticmethod - def add_html_tag(tag): + def add_html_tags(tags): """ - Add a new tag to the list + Add a list of tags to the list """ - DisplayTags.html_expands.append(tag) + DisplayTags.html_expands.extend(tags) @staticmethod def remove_html_tag(tag_id): diff --git a/openlp/core/ui/displaytagform.py b/openlp/core/ui/displaytagform.py index 213f6e2e5..fc872c86e 100644 --- a/openlp/core/ui/displaytagform.py +++ b/openlp/core/ui/displaytagform.py @@ -87,8 +87,7 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): if user_expands_string: user_tags = cPickle.loads(user_expands_string) # If we have some user ones added them as well - for t in user_tags: - DisplayTags.add_html_tag(t) + DisplayTags.add_html_tags(user_tags) def onRowSelected(self): """ @@ -128,10 +127,15 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): 'Tag "n" already defined.')) return # Add new tag to list - tag = {u'desc': u'New Item', u'start tag': u'{n}', - u'start html': u'', u'end tag': u'{/n}', - u'end html': u'', u'protected': False} - DisplayTags.add_html_tag(tag) + tag = { + u'desc': translate('OpenLP.DisplayTagTab', 'New Tag'), + u'start tag': u'{n}', + u'start html': translate('OpenLP.DisplayTagTab', ''), + u'end tag': u'{/n}', + u'end html': translate('OpenLP.DisplayTagTab', ''), + u'protected': False + } + DisplayTags.add_html_tags([tag]) self._resetTable() # Highlight new row self.tagTableWidget.selectRow(self.tagTableWidget.rowCount() - 1) From af961afa7883117031570bb8e18ce29282105811 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 20:00:25 +0200 Subject: [PATCH 4/7] removed the 'default' button --- openlp/core/ui/displaytagdialog.py | 5 ----- openlp/core/ui/displaytagform.py | 9 --------- 2 files changed, 14 deletions(-) diff --git a/openlp/core/ui/displaytagdialog.py b/openlp/core/ui/displaytagdialog.py index f501f03f6..a7701d8f3 100644 --- a/openlp/core/ui/displaytagdialog.py +++ b/openlp/core/ui/displaytagdialog.py @@ -69,9 +69,6 @@ class Ui_DisplayTagDialog(object): spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) - self.defaultPushButton = QtGui.QPushButton(self.widget) - self.defaultPushButton.setObjectName(u'defaultPushButton') - self.horizontalLayout.addWidget(self.defaultPushButton) self.deletePushButton = QtGui.QPushButton(self.widget) self.deletePushButton.setObjectName(u'deletePushButton') self.horizontalLayout.addWidget(self.deletePushButton) @@ -141,8 +138,6 @@ class Ui_DisplayTagDialog(object): self.endTagLabel.setText( translate('OpenLP.DisplayTagDialog', 'End tag')) self.deletePushButton.setText(UiStrings().Delete) - self.defaultPushButton.setText( - translate('OpenLP.DisplayTagDialog', 'Default')) self.newPushButton.setText(UiStrings().New) self.tagTableWidget.horizontalHeaderItem(0).setText( translate('OpenLP.DisplayTagDialog', 'Description')) diff --git a/openlp/core/ui/displaytagform.py b/openlp/core/ui/displaytagform.py index d0f27120f..6aaddf2b8 100644 --- a/openlp/core/ui/displaytagform.py +++ b/openlp/core/ui/displaytagform.py @@ -51,8 +51,6 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): self._loadDisplayTags() QtCore.QObject.connect(self.tagTableWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onRowSelected) - QtCore.QObject.connect(self.defaultPushButton, - QtCore.SIGNAL(u'pressed()'), self.onDefaultPushed) QtCore.QObject.connect(self.newPushButton, QtCore.SIGNAL(u'pressed()'), self.onNewPushed) QtCore.QObject.connect(self.savePushButton, @@ -141,13 +139,6 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): self.tagTableWidget.selectRow(self.tagTableWidget.rowCount() - 1) self.onRowSelected() - def onDefaultPushed(self): - """ - Remove all Custom Tags and reset to base set only. - """ - DisplayTags.reset_html_tags() - self._resetTable() - def onDeletePushed(self): """ Delete selected custom tag. From d62462718ecf1a84d921b55349376a5c2106ae37 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 20:48:20 +0200 Subject: [PATCH 5/7] r1576 From 6aca4600b7b345f82de99bd210b14edbafa0c287 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 20:52:05 +0200 Subject: [PATCH 6/7] fixed bug 788770 Fixes: https://launchpad.net/bugs/788770 --- openlp/core/lib/serviceitem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 37723321c..cf682abc6 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -177,10 +177,11 @@ class ServiceItem(object): .format_slide(slide[u'raw_slide'], line_break, self) for page in formatted: page = page.replace(u'
', u'{br}') + html = expand_tags(cgi.escape(page.rstrip())) self._display_frames.append({ u'title': clean_tags(page), u'text': clean_tags(page.rstrip()), - u'html': expand_tags(cgi.escape(page.rstrip())), + u'html': html.replace(u' ', u' '), u'verseTag': slide[u'verseTag'] }) elif self.service_item_type == ServiceItemType.Image or \ From 39537f9ef711125d1b8ae6f5ed0d7c0d21612f0d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 26 May 2011 22:17:52 +0200 Subject: [PATCH 7/7] fixed bug 788770 Fixes: https://launchpad.net/bugs/788770 --- openlp/plugins/bibles/lib/mediaitem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b245f7241..41059f942 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -775,6 +775,7 @@ class BibleMediaItem(MediaManagerItem): # We have to be 'Continuous'. else: bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) + bible_text = bible_text.strip(u' ') if not old_item: start_item = bitem elif self.checkTitle(bitem, old_item):