← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/bug-787552 into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/bug-787552 into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
Related bugs:
  Bug #787552 in OpenLP: "Display tag description of protected tags are not translated"
  https://bugs.launchpad.net/openlp/+bug/787552

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/bug-787552/+merge/62531

Hello,

- Removed 'Default' button
- Translate the tag description (bug #787552).

Before: http://imageshack.us/m/402/7879/untranslated.png
After: http://imageshack.us/m/835/4747/afterwards.png

To archieve this I moved the "base_html_expands" out of core/lib/__init__ to the static method "reset_html_tags". When we prepare the display tags the app translator will be able to translate the strings (which he wouldn't if we had left "base_html_expands" as constant in core/lib/__init__.
-- 
https://code.launchpad.net/~googol-hush/openlp/bug-787552/+merge/62531
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-05-26 17:11:22 +0000
+++ openlp/core/lib/__init__.py	2011-05-26 18:12:33 +0000
@@ -36,58 +36,6 @@
 
 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'<span style="-webkit-text-fill-color:red">',
-    u'end tag': u'{/r}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Black', u'start tag': u'{b}',
-    u'start html': u'<span style="-webkit-text-fill-color:black">',
-    u'end tag': u'{/b}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}',
-    u'start html': u'<span style="-webkit-text-fill-color:blue">',
-    u'end tag': u'{/bl}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}',
-    u'start html': u'<span style="-webkit-text-fill-color:yellow">',
-    u'end tag': u'{/y}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Green', u'start tag': u'{g}',
-    u'start html': u'<span style="-webkit-text-fill-color:green">',
-    u'end tag': u'{/g}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}',
-    u'start html': u'<span style="-webkit-text-fill-color:#FFC0CB">',
-    u'end tag': u'{/pk}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Orange', u'start tag': u'{o}',
-    u'start html': u'<span style="-webkit-text-fill-color:#FFA500">',
-    u'end tag': u'{/o}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}',
-    u'start html': u'<span style="-webkit-text-fill-color:#800080">',
-    u'end tag': u'{/pp}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'White', u'start tag': u'{w}',
-    u'start html': u'<span style="-webkit-text-fill-color:white">',
-    u'end tag': u'{/w}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}',
-    u'start html': u'<sup>', u'end tag': u'{/su}', u'end html': u'</sup>',
-    u'protected': True})
-base_html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}',
-    u'start html': u'<sub>', u'end tag': u'{/sb}', u'end html': u'</sub>',
-    u'protected': True})
-base_html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}',
-    u'start html': u'<p>', u'end tag': u'{/p}', u'end html': u'</p>',
-    u'protected': True})
-base_html_expands.append({u'desc': u'Bold', u'start tag': u'{st}',
-    u'start html': u'<strong>', u'end tag': u'{/st}', u'end html': u'</strong>',
-    u'protected': True})
-base_html_expands.append({u'desc': u'Italics', u'start tag': u'{it}',
-    u'start html': u'<em>', u'end tag': u'{/it}', u'end html': u'</em>',
-    u'protected': True})
-base_html_expands.append({u'desc': u'Underline', u'start tag': u'{u}',
-    u'start html': u'<span style="text-decoration: underline;">',
-    u'end tag': u'{/u}', u'end html': u'</span>', u'protected': True})
-base_html_expands.append({u'desc': u'Break', u'start tag': u'{br}',
-    u'start html': u'<br>', 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):

=== modified file 'openlp/core/lib/displaytags.py'
--- openlp/core/lib/displaytags.py	2011-05-26 17:11:22 +0000
+++ openlp/core/lib/displaytags.py	2011-05-26 18:12:33 +0000
@@ -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 @@
         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'<span style="-webkit-text-fill-color:red">',
+            u'end tag': u'{/r}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc':  translate('OpenLP.DisplayTags', 'Black'),
+            u'start tag': u'{b}',
+            u'start html': u'<span style="-webkit-text-fill-color:black">',
+            u'end tag': u'{/b}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Blue'),
+            u'start tag': u'{bl}',
+            u'start html': u'<span style="-webkit-text-fill-color:blue">',
+            u'end tag': u'{/bl}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Yellow'),
+            u'start tag': u'{y}',
+            u'start html': u'<span style="-webkit-text-fill-color:yellow">',
+            u'end tag': u'{/y}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Green'),
+            u'start tag': u'{g}',
+            u'start html': u'<span style="-webkit-text-fill-color:green">',
+            u'end tag': u'{/g}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Pink'),
+            u'start tag': u'{pk}',
+            u'start html': u'<span style="-webkit-text-fill-color:#FFC0CB">',
+            u'end tag': u'{/pk}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Orange'),
+            u'start tag': u'{o}',
+            u'start html': u'<span style="-webkit-text-fill-color:#FFA500">',
+            u'end tag': u'{/o}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Purple'),
+            u'start tag': u'{pp}',
+            u'start html': u'<span style="-webkit-text-fill-color:#800080">',
+            u'end tag': u'{/pp}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'White'),
+            u'start tag': u'{w}',
+            u'start html': u'<span style="-webkit-text-fill-color:white">',
+            u'end tag': u'{/w}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({
+            u'desc': translate('OpenLP.DisplayTags', 'Superscript'),
+            u'start tag': u'{su}', u'start html': u'<sup>',
+            u'end tag': u'{/su}', u'end html': u'</sup>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Subscript'),
+            u'start tag': u'{sb}', u'start html': u'<sub>',
+            u'end tag': u'{/sb}', u'end html': u'</sub>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Paragraph'),
+            u'start tag': u'{p}', u'start html': u'<p>', u'end tag': u'{/p}',
+            u'end html': u'</p>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Bold'),
+            u'start tag': u'{st}', u'start html': u'<strong>',
+            u'end tag': u'{/st}', u'end html': u'</strong>',
+            u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Italics'),
+            u'start tag': u'{it}', u'start html': u'<em>', u'end tag': u'{/it}',
+            u'end html': u'</em>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Underline'),
+            u'start tag': u'{u}',
+            u'start html': u'<span style="text-decoration: underline;">',
+            u'end tag': u'{/u}', u'end html': u'</span>', u'protected': True})
+        base_tags.append({u'desc': translate('OpenLP.DisplayTags', 'Break'),
+            u'start tag': u'{br}', u'start html': u'<br>', u'end tag': u'',
+            u'end html': u'', u'protected': True})
+        DisplayTags.add_html_tags(base_tags)
 
     @staticmethod
-    def add_html_tag(tag):
-        """
-        Add a new tag to the list
-        """
-        DisplayTags.html_expands.append(tag)
+    def add_html_tags(tags):
+        """
+        Add a list of tags to the list
+        """
+        DisplayTags.html_expands.extend(tags)
 
     @staticmethod
     def remove_html_tag(tag_id):

=== modified file 'openlp/core/ui/displaytagdialog.py'
--- openlp/core/ui/displaytagdialog.py	2011-05-26 17:11:22 +0000
+++ openlp/core/ui/displaytagdialog.py	2011-05-26 18:12:33 +0000
@@ -69,9 +69,6 @@
         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 @@
         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'))

=== modified file 'openlp/core/ui/displaytagform.py'
--- openlp/core/ui/displaytagform.py	2011-05-26 17:11:22 +0000
+++ openlp/core/ui/displaytagform.py	2011-05-26 18:12:33 +0000
@@ -51,8 +51,6 @@
         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,
@@ -87,8 +85,7 @@
         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,22 +125,20 @@
                     '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'<Html_here>', u'end tag': u'{/n}',
-            u'end html': u'</and here>', 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', '<Html_here>'),
+            u'end tag': u'{/n}',
+            u'end html': translate('OpenLP.DisplayTagTab', '</and here>'),
+            u'protected': False
+        }
+        DisplayTags.add_html_tags([tag])
         self._resetTable()
         # Highlight new row
         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.


Follow ups