← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/next into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/next into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)

For more details, see:
https://code.launchpad.net/~trb143/openlp/next/+merge/45641

This is big but lets get it in soon.
Changes:
- Search for songs by theme on exact match NOT like
- Add ability to create your own displaytabs and manage them by settings.
- Clean up Theme Manager and make more code common.

May be some other stuff I have forgotten.

Fixed up review comments
-- 
https://code.launchpad.net/~trb143/openlp/next/+merge/45641
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp.pyw'
--- openlp.pyw	2011-01-06 20:48:22 +0000
+++ openlp.pyw	2011-01-09 17:22:53 +0000
@@ -34,7 +34,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import Receiver
+from openlp.core.lib import Receiver, check_directory_exists
 from openlp.core.resources import qInitResources
 from openlp.core.ui.mainwindow import MainWindow
 from openlp.core.ui.exceptionform import ExceptionForm
@@ -150,16 +150,16 @@
             log.info(u'Openlp version %s' % app_version[u'version'])
         return app_version
 
-    def notify(self, obj, evt):
-        #TODO needed for presentation exceptions
-        return QtGui.QApplication.notify(self, obj, evt)
+#    def notify(self, obj, evt):
+#        #TODO needed for presentation exceptions
+#        return QtGui.QApplication.notify(self, obj, evt)
 
     def run(self):
         """
         Run the OpenLP application.
         """
         app_version = self._get_version()
-        #provide a listener for widgets to reqest a screen update.
+        # provide a listener for widgets to reqest a screen update.
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'openlp_process_events'), self.processEvents)
         QtCore.QObject.connect(Receiver.get_receiver(),
@@ -216,7 +216,7 @@
 
     def setNormalCursor(self):
         """
-        Sets the Normal Cursor forthe Application
+        Sets the Normal Cursor for the Application
         """
         self.restoreOverrideCursor()
 
@@ -243,8 +243,7 @@
         help='Set the Qt4 style (passed directly to Qt4).')
     # Set up logging
     log_path = AppLocation.get_directory(AppLocation.CacheDir)
-    if not os.path.exists(log_path):
-        os.makedirs(log_path)
+    check_directory_exists(log_path)
     filename = os.path.join(log_path, u'openlp.log')
     logfile = logging.FileHandler(filename, u'w')
     logfile.setFormatter(logging.Formatter(
@@ -281,4 +280,4 @@
     """
     Instantiate and run the application.
     """
-    main()
+    main()
\ No newline at end of file

=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-01-08 20:26:56 +0000
+++ openlp/core/lib/__init__.py	2011-01-09 17:22:53 +0000
@@ -35,52 +35,51 @@
 
 log = logging.getLogger(__name__)
 
-# TODO make external and configurable in alpha 4 via a settings dialog
-html_expands = []
+base_html_expands = []
 
-html_expands.append({u'desc': u'Red', u'start tag': u'{r}',
+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': False})
-html_expands.append({u'desc': u'Black', u'start tag': u'{b}',
+    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': False})
-html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}',
+    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': False})
-html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}',
+    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': False})
-html_expands.append({u'desc': u'Green', u'start tag': u'{g}',
+    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': False})
-html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}',
+    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:#CC33CC">',
-    u'end tag': u'{/pk}', u'end html': u'</span>', u'protected': False})
-html_expands.append({u'desc': u'Orange', u'start tag': u'{o}',
+    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:#CC0033">',
-    u'end tag': u'{/o}', u'end html': u'</span>', u'protected': False})
-html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}',
+    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:#9900FF">',
-    u'end tag': u'{/pp}', u'end html': u'</span>', u'protected': False})
-html_expands.append({u'desc': u'White', u'start tag': u'{w}',
+    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': False})
-html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}',
+    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})
-html_expands.append({u'desc': u'Subscript', u'start tag': u'{sb}',
+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})
-html_expands.append({u'desc': u'Paragraph', u'start tag': u'{p}',
+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})
-html_expands.append({u'desc': u'Bold', u'start tag': u'{st}',
+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})
-html_expands.append({u'desc': u'Italics', u'start tag': u'{it}',
+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})
-html_expands.append({u'desc': u'Underline', u'start tag': u'{u}',
+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})
 
@@ -294,7 +293,7 @@
     Remove Tags from text for display
     """
     text = text.replace(u'<br>', u'\n')
-    for tag in html_expands:
+    for tag in DisplayTags.get_html_tags():
         text = text.replace(tag[u'start tag'], u'')
         text = text.replace(tag[u'end tag'], u'')
     return text
@@ -303,13 +302,25 @@
     """
     Expand tags HTML for display
     """
-    for tag in html_expands:
+    for tag in DisplayTags.get_html_tags():
         text = text.replace(tag[u'start tag'], tag[u'start html'])
         text = text.replace(tag[u'end tag'], tag[u'end html'])
     return text
 
+def check_directory_exists(dir):
+    """
+    Check a theme directory exists and if not create it
+
+    ``dir``
+        Theme directory to make sure exists
+    """
+    log.debug(u'check_directory_exists')
+    if not os.path.exists(dir):
+        os.makedirs(dir)
+
 from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
     BackgroundType, HorizontalType, VerticalType
+from displaytags import DisplayTags
 from spelltextedit import SpellTextEdit
 from eventreceiver import Receiver
 from imagemanager import ImageManager

=== added file 'openlp/core/lib/displaytags.py'
--- openlp/core/lib/displaytags.py	1970-01-01 00:00:00 +0000
+++ openlp/core/lib/displaytags.py	2011-01-09 17:22:53 +0000
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2011 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael      #
+# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian      #
+# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble,    #
+# Carsten Tinggaard, Frode Woldsund                                           #
+# --------------------------------------------------------------------------- #
+# 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                          #
+###############################################################################
+"""
+Provide Html Tag management and Display Tag access class
+"""
+
+from openlp.core.lib import base_html_expands
+
+class DisplayTags(object):
+    """
+    Static Class to HTML Tags to be access around the code the list is managed
+    by the Options Tab.
+    """
+    html_expands = []
+
+    @staticmethod
+    def get_html_tags():
+        """
+        Provide access to the html_expands list.
+        """
+        return DisplayTags.html_expands
+
+    @staticmethod
+    def reset_html_tags():
+        """
+        Resets the html_expands list.
+        """
+        DisplayTags.html_expands = []
+        for html in base_html_expands:
+            DisplayTags.html_expands.append(html)
+
+    @staticmethod
+    def add_html_tag(tag):
+        """
+        Add a new tag to the list
+        """
+        DisplayTags.html_expands.append(tag)
+
+    @staticmethod
+    def remove_html_tag(id):
+        """
+        Removes amd individual html_expands list.
+        """
+        DisplayTags.html_expands.pop(id)

=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py	2010-12-26 11:04:47 +0000
+++ openlp/core/lib/plugin.py	2011-01-09 17:22:53 +0000
@@ -175,6 +175,10 @@
         self.status = new_status
         QtCore.QSettings().setValue(
             self.settingsSection + u'/status', QtCore.QVariant(self.status))
+        if new_status == PluginStatus.Active:
+            self.initialise()
+        elif new_status == PluginStatus.Inactive:
+            self.finalise()
 
     def isActive(self):
         """
@@ -314,4 +318,4 @@
         """
         Called to define all translatable texts of the plugin
         """
-        pass
\ No newline at end of file
+        pass

=== modified file 'openlp/core/lib/settingstab.py'
--- openlp/core/lib/settingstab.py	2011-01-03 11:25:30 +0000
+++ openlp/core/lib/settingstab.py	2011-01-09 17:22:53 +0000
@@ -114,6 +114,12 @@
         """
         pass
 
+    def cancel(self):
+        """
+        Reset any settings
+        """
+        pass
+
     def postSetUp(self, postUpdate=False):
         """
         Changes which need to be made after setup of application

=== modified file 'openlp/core/lib/spelltextedit.py'
--- openlp/core/lib/spelltextedit.py	2010-12-26 11:04:47 +0000
+++ openlp/core/lib/spelltextedit.py	2011-01-09 17:22:53 +0000
@@ -36,7 +36,7 @@
 # http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check
 
 from PyQt4 import QtCore, QtGui
-from openlp.core.lib import html_expands, translate
+from openlp.core.lib import translate, DisplayTags
 
 class SpellTextEdit(QtGui.QPlainTextEdit):
     """
@@ -88,7 +88,7 @@
                     popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
         tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
             'Formatting Tags'))
-        for html in html_expands:
+        for html in DisplayTags.get_html_tags():
             action = SpellAction( html[u'desc'], tagMenu)
             action.correct.connect(self.htmlTag)
             tagMenu.addAction(action)
@@ -110,7 +110,7 @@
         """
         Replaces the selected text with word.
         """
-        for html in html_expands:
+        for html in DisplayTags.get_html_tags():
             if tag == html[u'desc']:
                 cursor = self.textCursor()
                 if self.textCursor().hasSelection():
@@ -158,4 +158,4 @@
     def __init__(self, *args):
         QtGui.QAction.__init__(self, *args)
         self.triggered.connect(lambda x: self.correct.emit(
-            unicode(self.text())))
\ No newline at end of file
+            unicode(self.text())))

=== modified file 'openlp/core/lib/theme.py'
--- openlp/core/lib/theme.py	2010-12-26 11:04:47 +0000
+++ openlp/core/lib/theme.py	2011-01-09 17:22:53 +0000
@@ -598,4 +598,4 @@
             self.font_footer_shadow_size)
         self.add_display(self.display_horizontal_align,
             self.display_vertical_align,
-            self.display_slide_transition)
\ No newline at end of file
+            self.display_slide_transition)

=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py	2011-01-05 09:37:11 +0000
+++ openlp/core/ui/__init__.py	2011-01-09 17:22:53 +0000
@@ -59,6 +59,7 @@
 from generaltab import GeneralTab
 from themestab import ThemesTab
 from advancedtab import AdvancedTab
+from displaytagtab import DisplayTagTab
 from aboutform import AboutForm
 from pluginform import PluginForm
 from settingsform import SettingsForm

=== added file 'openlp/core/ui/displaytagtab.py'
--- openlp/core/ui/displaytagtab.py	1970-01-01 00:00:00 +0000
+++ openlp/core/ui/displaytagtab.py	2011-01-09 17:22:53 +0000
@@ -0,0 +1,350 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2011 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael      #
+# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian      #
+# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble,    #
+# Carsten Tinggaard, Frode Woldsund                                           #
+# --------------------------------------------------------------------------- #
+# 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                          #
+###############################################################################
+'''
+The :mod:`DisplayTagTab` provides an Tag Edit facility.  The Base set are
+protected and included each time loaded.  Custom tags can be defined and saved.
+The Custom Tag arrays are saved in a pickle so QSettings works on them.  Base
+Tags cannot be changed.
+
+'''
+import cPickle
+from PyQt4 import QtCore, QtGui
+
+from openlp.core.lib import SettingsTab, translate, DisplayTags
+
+class DisplayTagTab(SettingsTab):
+    '''
+    The :class:`DisplayTagTab` manages the settings tab .
+    '''
+    def __init__(self):
+        '''
+        Initialise the settings tab
+        '''
+        SettingsTab.__init__(self, u'Display Tags')
+
+    def resizeEvent(self, event=None):
+        pass
+
+    def preLoad(self):
+        """
+        Initialise values before the Load takes place
+        """
+        # Create initial copy from master
+        DisplayTags.reset_html_tags()
+        user_expands = QtCore.QSettings().value(u'displayTags/html_tags',
+            QtCore.QVariant(u'')).toString()
+        # cPickle only accepts str not unicode strings
+        user_expands_string = str(unicode(user_expands).encode(u'utf8'))
+        if user_expands_string:
+            user_tags = cPickle.loads(user_expand_string)
+            # If we have some user ones added them as well
+            for t in user_tags:
+                DisplayTags.add_html_tag(t)
+        self.selected = -1
+
+    def setupUi(self):
+        '''
+        Configure the UI elements for the tab.
+        '''
+        self.setObjectName(u'DisplayTagTab')
+        self.tabTitleVisible = \
+            translate(u'OpenLP.DisplayTagTab', 'Display Tags')
+        self.displayTagEdit = QtGui.QWidget(self)
+        self.editGroupBox = QtGui.QGroupBox(self.displayTagEdit)
+        self.editGroupBox.setGeometry(QtCore.QRect(10, 220, 650, 181))
+        self.editGroupBox.setObjectName(u'editGroupBox')
+        self.updatePushButton = QtGui.QPushButton(self.editGroupBox)
+        self.updatePushButton.setGeometry(QtCore.QRect(550, 140, 71, 26))
+        self.updatePushButton.setObjectName(u'updatePushButton')
+        self.layoutWidget = QtGui.QWidget(self.editGroupBox)
+        self.layoutWidget.setGeometry(QtCore.QRect(5, 20, 571, 114))
+        self.layoutWidget.setObjectName(u'layoutWidget')
+        self.formLayout = QtGui.QFormLayout(self.layoutWidget)
+        self.formLayout.setObjectName(u'formLayout')
+        self.descriptionLabel = QtGui.QLabel(self.layoutWidget)
+        self.descriptionLabel.setAlignment(QtCore.Qt.AlignCenter)
+        self.descriptionLabel.setObjectName(u'descriptionLabel')
+        self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
+            self.descriptionLabel)
+        self.descriptionLineEdit = QtGui.QLineEdit(self.layoutWidget)
+        self.descriptionLineEdit.setObjectName(u'descriptionLineEdit')
+        self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
+            self.descriptionLineEdit)
+        self.tagLabel = QtGui.QLabel(self.layoutWidget)
+        self.tagLabel.setAlignment(QtCore.Qt.AlignCenter)
+        self.tagLabel.setObjectName(u'tagLabel')
+        self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.tagLabel)
+        self.tagLineEdit = QtGui.QLineEdit(self.layoutWidget)
+        self.tagLineEdit.setMaximumSize(QtCore.QSize(50, 16777215))
+        self.tagLineEdit.setMaxLength(5)
+        self.tagLineEdit.setObjectName(u'tagLineEdit')
+        self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole,
+            self.tagLineEdit)
+        self.startTagLabel = QtGui.QLabel(self.layoutWidget)
+        self.startTagLabel.setAlignment(QtCore.Qt.AlignCenter)
+        self.startTagLabel.setObjectName(u'startTagLabel')
+        self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
+            self.startTagLabel)
+        self.startTagLineEdit = QtGui.QLineEdit(self.layoutWidget)
+        self.startTagLineEdit.setObjectName(u'startTagLineEdit')
+        self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
+            self.startTagLineEdit)
+        self.endTagLabel = QtGui.QLabel(self.layoutWidget)
+        self.endTagLabel.setAlignment(QtCore.Qt.AlignCenter)
+        self.endTagLabel.setObjectName(u'endTagLabel')
+        self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole,
+            self.endTagLabel)
+        self.endTagLineEdit = QtGui.QLineEdit(self.layoutWidget)
+        self.endTagLineEdit.setObjectName(u'endTagLineEdit')
+        self.formLayout.setWidget(3, QtGui.QFormLayout.FieldRole,
+            self.endTagLineEdit)
+        self.defaultPushButton = QtGui.QPushButton(self.displayTagEdit)
+        self.defaultPushButton.setGeometry(QtCore.QRect(430, 188, 71, 26))
+        self.defaultPushButton.setObjectName(u'updatePushButton')
+        self.deletePushButton = QtGui.QPushButton(self.displayTagEdit)
+        self.deletePushButton.setGeometry(QtCore.QRect(510, 188, 71, 26))
+        self.deletePushButton.setObjectName(u'deletePushButton')
+        self.newPushButton = QtGui.QPushButton(self.displayTagEdit)
+        self.newPushButton.setGeometry(QtCore.QRect(600, 188, 71, 26))
+        self.newPushButton.setObjectName(u'newPushButton')
+        self.tagTableWidget = QtGui.QTableWidget(self.displayTagEdit)
+        self.tagTableWidget.setGeometry(QtCore.QRect(10, 10, 650, 171))
+        self.tagTableWidget.setHorizontalScrollBarPolicy(
+            QtCore.Qt.ScrollBarAlwaysOff)
+        self.tagTableWidget.setEditTriggers(
+            QtGui.QAbstractItemView.NoEditTriggers)
+        self.tagTableWidget.setAlternatingRowColors(True)
+        self.tagTableWidget.setSelectionMode(
+            QtGui.QAbstractItemView.SingleSelection)
+        self.tagTableWidget.setSelectionBehavior(
+            QtGui.QAbstractItemView.SelectRows)
+        self.tagTableWidget.setCornerButtonEnabled(False)
+        self.tagTableWidget.setObjectName(u'tagTableWidget')
+        self.tagTableWidget.setColumnCount(4)
+        self.tagTableWidget.setRowCount(0)
+        item = QtGui.QTableWidgetItem()
+        self.tagTableWidget.setHorizontalHeaderItem(0, item)
+        item = QtGui.QTableWidgetItem()
+        self.tagTableWidget.setHorizontalHeaderItem(1, item)
+        item = QtGui.QTableWidgetItem()
+        self.tagTableWidget.setHorizontalHeaderItem(2, item)
+        item = QtGui.QTableWidgetItem()
+        self.tagTableWidget.setHorizontalHeaderItem(3, item)
+        self.editGroupBox.setTitle(
+            translate('OpenLP.DisplayTagTab', 'Edit Selection'))
+        self.updatePushButton.setText(
+            translate('OpenLP.DisplayTagTab', 'Update'))
+        self.descriptionLabel.setText(
+            translate('OpenLP.DisplayTagTab', 'Description'))
+        self.tagLabel.setText(translate('OpenLP.DisplayTagTab', 'Tag'))
+        self.startTagLabel.setText(
+            translate('OpenLP.DisplayTagTab', 'Start tag'))
+        self.endTagLabel.setText(translate('OpenLP.DisplayTagTab', 'End tag'))
+        self.deletePushButton.setText(
+            translate('OpenLP.DisplayTagTab', 'Delete'))
+        self.defaultPushButton.setText(
+            translate('OpenLP.DisplayTagTab', 'Default'))
+        self.newPushButton.setText(translate('OpenLP.DisplayTagTab', 'New'))
+        self.tagTableWidget.horizontalHeaderItem(0)\
+            .setText(translate('OpenLP.DisplayTagTab', 'Description'))
+        self.tagTableWidget.horizontalHeaderItem(1)\
+            .setText(translate('OpenLP.DisplayTagTab', 'Tag id'))
+        self.tagTableWidget.horizontalHeaderItem(2)\
+            .setText(translate('OpenLP.DisplayTagTab', 'Start Html'))
+        self.tagTableWidget.horizontalHeaderItem(3)\
+            .setText(translate('OpenLP.DisplayTagTab', 'End Html'))
+        QtCore.QMetaObject.connectSlotsByName(self.displayTagEdit)
+        self.tagTableWidget.setColumnWidth(0, 120)
+        self.tagTableWidget.setColumnWidth(1, 40)
+        self.tagTableWidget.setColumnWidth(2, 240)
+        self.tagTableWidget.setColumnWidth(3, 200)
+        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.updatePushButton,
+            QtCore.SIGNAL(u'pressed()'), self.onUpdatePushed)
+        QtCore.QObject.connect(self.deletePushButton,
+            QtCore.SIGNAL(u'pressed()'), self.onDeletePushed)
+
+    def load(self):
+        """
+        Load Display and set field state.
+        """
+        self.newPushButton.setEnabled(True)
+        self.updatePushButton.setEnabled(False)
+        self.deletePushButton.setEnabled(False)
+        for linenumber, html in enumerate(DisplayTags.get_html_tags()):
+            self.tagTableWidget.setRowCount(
+                self.tagTableWidget.rowCount() + 1)
+            self.tagTableWidget.setItem(linenumber, 0,
+                QtGui.QTableWidgetItem(html[u'desc']))
+            self.tagTableWidget.setItem(linenumber, 1,
+                QtGui.QTableWidgetItem(self._strip(html[u'start tag'])))
+            self.tagTableWidget.setItem(linenumber, 2,
+                QtGui.QTableWidgetItem(html[u'start html']))
+            self.tagTableWidget.setItem(linenumber, 3,
+                QtGui.QTableWidgetItem(html[u'end html']))
+            self.tagTableWidget.resizeRowsToContents()
+        self.descriptionLineEdit.setText(u'')
+        self.tagLineEdit.setText(u'')
+        self.startTagLineEdit.setText(u'')
+        self.endTagLineEdit.setText(u'')
+        self.descriptionLineEdit.setEnabled(False)
+        self.tagLineEdit.setEnabled(False)
+        self.startTagLineEdit.setEnabled(False)
+        self.endTagLineEdit.setEnabled(False)
+
+    def save(self):
+        """
+        Save Custom tags in a pickle .
+        """
+        temp = []
+        for tag in DisplayTags.get_html_tags():
+            if not tag[u'protected']:
+                temp.append(tag)
+        if temp:
+            ctemp = cPickle.dumps(temp)
+            QtCore.QSettings().setValue(u'displayTags/html_tags',
+                QtCore.QVariant(ctemp))
+        else:
+            QtCore.QSettings().setValue(u'displayTags/html_tags',
+                QtCore.QVariant(u''))
+
+    def cancel(self):
+        """
+        Reset Custom tags from Settings.
+        """
+        self.preLoad()
+        self._resetTable()
+
+    def onRowSelected(self):
+        """
+        Table Row selected so display items and set field state.
+        """
+        row = self.tagTableWidget.currentRow()
+        html = DisplayTags.get_html_tags()[row]
+        self.selected = row
+        self.descriptionLineEdit.setText(html[u'desc'])
+        self.tagLineEdit.setText(self._strip(html[u'start tag']))
+        self.startTagLineEdit.setText(html[u'start html'])
+        self.endTagLineEdit.setText(html[u'end html'])
+        if html[u'protected']:
+            self.descriptionLineEdit.setEnabled(False)
+            self.tagLineEdit.setEnabled(False)
+            self.startTagLineEdit.setEnabled(False)
+            self.endTagLineEdit.setEnabled(False)
+            self.updatePushButton.setEnabled(False)
+            self.deletePushButton.setEnabled(False)
+        else:
+            self.descriptionLineEdit.setEnabled(True)
+            self.tagLineEdit.setEnabled(True)
+            self.startTagLineEdit.setEnabled(True)
+            self.endTagLineEdit.setEnabled(True)
+            self.updatePushButton.setEnabled(True)
+            self.deletePushButton.setEnabled(True)
+
+    def onNewPushed(self):
+        """
+        Add a new tag to list only if it is not a duplicate.
+        """
+        for html in DisplayTags.get_html_tags():
+            if self._strip(html[u'start tag']) == u'n':
+                QtGui.QMessageBox.critical(self,
+                    translate('OpenLP.DisplayTagTab', 'Update Error'),
+                    translate('OpenLP.DisplayTagTab',
+                    'Tag "n" already defined.'),
+                    QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
+                    QtGui.QMessageBox.Ok)
+                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)
+        self._resetTable()
+        # Highlight new row
+        self.tagTableWidget.selectRow(self.tagTableWidget.rowCount() - 1)
+
+    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.
+        """
+        if self.selected != -1:
+            DisplayTags.remove_html_tag(self.selected)
+            self.selected = -1
+        self._resetTable()
+
+    def onUpdatePushed(self):
+        """
+        Update Custom Tag details if not duplicate.
+        """
+        html_expands = DisplayTags.get_html_tags()
+        if self.selected != -1:
+            html = html_expands[self.selected]
+            tag = unicode(self.tagLineEdit.text())
+            for linenumber, html1 in enumerate(html_expands):
+                if self._strip(html1[u'start tag']) == tag and \
+                    linenumber != self.selected:
+                    QtGui.QMessageBox.critical(self,
+                        translate('OpenLP.DisplayTagTab', 'Update Error'),
+                        unicode(translate('OpenLP.DisplayTagTab',
+                        'Tag %s already defined.')) % tag,
+                        QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
+                        QtGui.QMessageBox.Ok)
+                    return
+            html[u'desc'] = unicode(self.descriptionLineEdit.text())
+            html[u'start html'] = unicode(self.startTagLineEdit.text())
+            html[u'end html'] = unicode(self.endTagLineEdit.text())
+            html[u'start tag'] = u'{%s}' % tag
+            html[u'end tag'] = u'{/%s}' % tag
+            self.selected = -1
+        self._resetTable()
+
+    def _resetTable(self):
+        """
+        Reset List for loading.
+        """
+        self.tagTableWidget.clearContents()
+        self.tagTableWidget.setRowCount(0)
+        self.load()
+
+    def _strip(self, tag):
+        """
+        Remove tag wrappers for editing.
+        """
+        tag = tag.replace(u'{', u'')
+        tag = tag.replace(u'}', u'')
+        return tag

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2011-01-04 09:19:53 +0000
+++ openlp/core/ui/maindisplay.py	2011-01-09 17:22:53 +0000
@@ -32,7 +32,8 @@
 from PyQt4.phonon import Phonon
 
 from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
-    translate
+    build_icon, translate
+
 from openlp.core.ui import HideMode
 
 log = logging.getLogger(__name__)
@@ -102,6 +103,8 @@
         self.isLive = live
         self.alertTab = None
         self.hideMode = None
+        mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
+        self.setWindowIcon(mainIcon)
         self.retranslateUi()
         self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
         self.setWindowFlags(QtCore.Qt.FramelessWindowHint |

=== modified file 'openlp/core/ui/pluginform.py'
--- openlp/core/ui/pluginform.py	2011-01-01 13:22:12 +0000
+++ openlp/core/ui/pluginform.py	2011-01-09 17:22:53 +0000
@@ -126,10 +126,8 @@
             return
         if status == 0:
             self.activePlugin.toggleStatus(PluginStatus.Active)
-            self.activePlugin.initialise()
         else:
             self.activePlugin.toggleStatus(PluginStatus.Inactive)
-            self.activePlugin.finalise()
         status_text = unicode(
             translate('OpenLP.PluginForm', '%s (Inactive)'))
         if self.activePlugin.status == PluginStatus.Active:

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-01-08 02:44:12 +0000
+++ openlp/core/ui/servicemanager.py	2011-01-09 17:22:53 +0000
@@ -250,7 +250,7 @@
             self.parent.serviceSettingsSection + u'/service theme',
             QtCore.QVariant(u'')).toString())
         self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
-        #build the drag and drop context menu
+        # build the drag and drop context menu
         self.dndMenu = QtGui.QMenu()
         self.newAction = self.dndMenu.addAction(
             translate('OpenLP.ServiceManager', '&Add New Item'))

=== modified file 'openlp/core/ui/settingsdialog.py'
--- openlp/core/ui/settingsdialog.py	2011-01-03 11:25:30 +0000
+++ openlp/core/ui/settingsdialog.py	2011-01-09 17:22:53 +0000
@@ -31,7 +31,7 @@
 class Ui_SettingsDialog(object):
     def setupUi(self, settingsDialog):
         settingsDialog.setObjectName(u'settingsDialog')
-        settingsDialog.resize(700, 300)
+        settingsDialog.resize(700, 500)
         settingsDialog.setWindowIcon(
             build_icon(u':/system/system_settings.png'))
         self.settingsLayout = QtGui.QVBoxLayout(settingsDialog)

=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py	2011-01-06 20:34:46 +0000
+++ openlp/core/ui/settingsform.py	2011-01-09 17:22:53 +0000
@@ -31,7 +31,7 @@
 from PyQt4 import QtGui
 
 from openlp.core.lib import Receiver
-from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
+from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab, DisplayTagTab
 from settingsdialog import Ui_SettingsDialog
 
 log = logging.getLogger(__name__)
@@ -55,6 +55,9 @@
         # Advanced tab
         self.advancedTab = AdvancedTab()
         self.addTab(u'Advanced', self.advancedTab)
+        # Edit Display Tags tab
+        self.displayTagTab = DisplayTagTab()
+        self.addTab(u'Display Tags', self.displayTagTab)
 
     def addTab(self, name, tab):
         """
@@ -68,9 +71,9 @@
         Add a tab to the form at a specific location
         """
         log.debug(u'Inserting %s tab' % tab.tabTitle)
-        # 14 : There are 3 tables currently and locations starts at -10
+        # 15 : There are 4 tables currently and locations starts at -10
         self.settingsTabWidget.insertTab(
-            location + 14, tab, tab.tabTitleVisible)
+            location + 15, tab, tab.tabTitleVisible)
 
     def removeTab(self, tab):
         """
@@ -93,6 +96,14 @@
         Receiver.send_message(u'config_updated')
         return QtGui.QDialog.accept(self)
 
+    def reject(self):
+        """
+        Process the form saving the settings
+        """
+        for tabIndex in range(0, self.settingsTabWidget.count()):
+            self.settingsTabWidget.widget(tabIndex).cancel()
+        return QtGui.QDialog.reject(self)
+
     def postSetUp(self):
         """
         Run any post-setup code for the tabs on the form

=== modified file 'openlp/core/ui/themeform.py'
--- openlp/core/ui/themeform.py	2011-01-05 16:55:54 +0000
+++ openlp/core/ui/themeform.py	2011-01-09 17:22:53 +0000
@@ -291,9 +291,10 @@
         self.updateThemeAllowed = True
         self.themeNameLabel.setVisible(not edit)
         self.themeNameEdit.setVisible(not edit)
+        self.edit = edit
         if edit:
             self.setWindowTitle(unicode(translate('OpenLP.ThemeWizard',
-                'Edit Theme %s')) % self.theme.theme_name)
+                'Edit Theme - %s')) % self.theme.theme_name)
             self.next()
         else:
             self.setWindowTitle(translate('OpenLP.ThemeWizard', 'New Theme'))
@@ -581,7 +582,6 @@
                 (QtGui.QMessageBox.Ok),
                 QtGui.QMessageBox.Ok)
             return
-        self.accepted = True
         saveFrom = None
         saveTo = None
         if self.theme.background_type == \
@@ -590,8 +590,12 @@
                 os.path.split(unicode(self.theme.background_filename))[1]
             saveTo = os.path.join(self.path, self.theme.theme_name, filename)
             saveFrom = self.theme.background_filename
-        if self.thememanager.saveTheme(self.theme, saveFrom, saveTo):
-            return QtGui.QDialog.accept(self)
+        if not self.edit:
+            if not self.thememanager.checkIfThemeExists(self.theme.theme_name):
+                return
+        self.accepted = True
+        self.thememanager.saveTheme(self.theme, saveFrom, saveTo)
+        return QtGui.QDialog.accept(self)
 
     def _colorButton(self, field):
         """

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2011-01-02 22:24:14 +0000
+++ openlp/core/ui/thememanager.py	2011-01-09 17:22:53 +0000
@@ -36,7 +36,7 @@
 from openlp.core.theme import Theme
 from openlp.core.lib import OpenLPToolbar, ThemeXML, get_text_file_string, \
     build_icon, Receiver, SettingsManager, translate, check_item_selected, \
-    BackgroundType, BackgroundGradientType
+    BackgroundType, BackgroundGradientType, check_directory_exists
 from openlp.core.utils import AppLocation, get_filesystem_encoding
 
 log = logging.getLogger(__name__)
@@ -119,27 +119,38 @@
         self.exportAction = self.menu.addAction(
             translate('OpenLP.ThemeManager', '&Export Theme'))
         self.exportAction.setIcon(build_icon(u':/general/general_export.png'))
-        #Signals
+        # Signals
         QtCore.QObject.connect(self.themeListWidget,
             QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
             self.changeGlobalFromScreen)
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'theme_update_global'), self.changeGlobalFromTab)
-        #Variables
+        QtCore.QObject.connect(Receiver.get_receiver(),
+            QtCore.SIGNAL(u'config_updated'), self.configUpdated)
+        # Variables
         self.themelist = []
         self.path = AppLocation.get_section_data_path(self.settingsSection)
-        self.checkThemesExists(self.path)
+        check_directory_exists(self.path)
         self.thumbPath = os.path.join(self.path, u'thumbnails')
-        self.checkThemesExists(self.thumbPath)
+        check_directory_exists(self.thumbPath)
         self.themeForm.path = self.path
         self.oldBackgroundImage = None
-        self.editingDefault = False
         # Last little bits of setting up
+        self.configUpdated()
+
+    def configUpdated(self, firstTime=False):
+        """
+        Triggered when Config dialog is updated.
+        """
         self.global_theme = unicode(QtCore.QSettings().value(
             self.settingsSection + u'/global theme',
             QtCore.QVariant(u'')).toString())
 
     def contextMenu(self, point):
+        """
+        Build the Right Click Context menu and set state depending on
+        the type of theme.
+        """
         item = self.themeListWidget.itemAt(point)
         if item is None:
             return
@@ -220,7 +231,6 @@
         editing form for the user to make their customisations.
         """
         theme = ThemeXML()
-        self.saveThemeName = u''
         self.themeForm.theme = theme
         self.themeForm.exec_()
 
@@ -236,12 +246,15 @@
             item = self.themeListWidget.currentItem()
             oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
             self.fileRenameForm.fileNameEdit.setText(oldThemeName)
-            self.saveThemeName = oldThemeName
             if self.fileRenameForm.exec_():
-                newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
-                oldThemeData = self.getThemeData(oldThemeName)
-                self.deleteTheme(oldThemeName)
-                self.cloneThemeData(oldThemeData, newThemeName)
+                newThemeName =  unicode(self.fileRenameForm.fileNameEdit.text())
+                if self.checkIfThemeExists(newThemeName):
+                    oldThemeData = self.getThemeData(oldThemeName)
+                    self.deleteTheme(oldThemeName)
+                    self.cloneThemeData(oldThemeData, newThemeName)
+                    for plugin in self.parent.pluginManager.plugins:
+                        if plugin.usesTheme(oldThemeName):
+                            plugin.renameTheme(oldThemeName, newThemeName)
 
     def onCopyTheme(self):
         """
@@ -250,12 +263,12 @@
         item = self.themeListWidget.currentItem()
         oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
         self.fileRenameForm.fileNameEdit.setText(oldThemeName)
-        self.saveThemeName = u''
         if self.fileRenameForm.exec_(True):
-            newThemeName = unicode(self.fileRenameForm.fileNameEdit.text())
-            themeData = self.getThemeData(oldThemeName)
-            self.cloneThemeData(themeData, newThemeName)
-            self.loadThemes()
+            newThemeName =  unicode(self.fileRenameForm.fileNameEdit.text())
+            if self.checkIfThemeExists(newThemeName):
+                themeData = self.getThemeData(oldThemeName)
+                self.cloneThemeData(themeData, newThemeName)
+                self.loadThemes()
 
     def cloneThemeData(self, themeData, newThemeName):
         """
@@ -281,14 +294,10 @@
             'You must select a theme to edit.')):
             item = self.themeListWidget.currentItem()
             themeName = unicode(item.text())
-            if themeName != unicode(item.data(QtCore.Qt.UserRole).toString()):
-                self.editingDefault = True
             theme = self.getThemeData(
                 unicode(item.data(QtCore.Qt.UserRole).toString()))
             if theme.background_type == u'image':
                 self.oldBackgroundImage = theme.background_filename
-            self.saveThemeName = unicode(
-                item.data(QtCore.Qt.UserRole).toString())
             self.themeForm.theme = theme
             self.themeForm.exec_(True)
 
@@ -449,20 +458,9 @@
             unicode(themeName) + u'.xml')
         xml = get_text_file_string(xmlFile)
         if not xml:
-            return self.baseTheme()
+            return self._baseTheme()
         else:
-            return self.createThemeFromXml(xml, self.path)
-
-    def checkThemesExists(self, dir):
-        """
-        Check a theme directory exists and if not create it
-
-        ``dir``
-            Theme directory to make sure exists
-        """
-        log.debug(u'check themes')
-        if not os.path.exists(dir):
-            os.mkdir(dir)
+            return self._createThemeFromXml(xml, self.path)
 
     def unzipTheme(self, filename, dir):
         """
@@ -494,8 +492,7 @@
                 theme_dir = None
                 if osfile.endswith(os.path.sep):
                     theme_dir = os.path.join(dir, osfile)
-                    if not os.path.exists(theme_dir):
-                        os.mkdir(os.path.join(dir, osfile))
+                    check_directory_exists(theme_dir)
                 else:
                     fullpath = os.path.join(dir, osfile)
                     names = osfile.split(os.path.sep)
@@ -505,8 +502,7 @@
                             themename = names[0]
                         if theme_dir is None:
                             theme_dir = os.path.join(dir, names[0])
-                            if not os.path.exists(theme_dir):
-                                os.mkdir(os.path.join(dir, names[0]))
+                            check_directory_exists(theme_dir)
                         if os.path.splitext(ucsfile)[1].lower() in [u'.xml']:
                             xml_data = zip.read(file)
                             try:
@@ -522,19 +518,22 @@
                             outfile = open(fullpath, u'wb')
                             outfile.write(zip.read(file))
             if filexml:
-                theme = self.createThemeFromXml(filexml, self.path)
+                theme = self._createThemeFromXml(filexml, self.path)
                 self.generateAndSaveImage(dir, themename, theme)
             else:
-                QtGui.QMessageBox.critical(self,
-                    translate('OpenLP.ThemeManager', 'Error'),
-                    translate('OpenLP.ThemeManager',
-                        'File is not a valid theme.'))
+                Receiver.send_message(u'openlp_error_message', {
+                    u'title': translate('OpenLP.ThemeManager',
+                    'Validation Error'),
+                    u'message':translate('OpenLP.ThemeManager',
+                    'File is not a valid theme.')})
                 log.exception(u'Theme file does not contain XML data %s' %
                     filename)
         except (IOError, NameError):
-            QtGui.QMessageBox.critical(self,
-                translate('OpenLP.ThemeManager', 'Error'),
-                translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
+            Receiver.send_message(u'openlp_error_message', {
+                u'title': translate('OpenLP.ThemeManager',
+                'Validation Error'),
+                u'message':translate('OpenLP.ThemeManager',
+                'File is not a valid theme.')})
             log.exception(u'Importing theme from zip failed %s' % filename)
         finally:
             if zip:
@@ -556,65 +555,24 @@
         if tree.find(u'BackgroundType') is None:
             return xml_data
         else:
-            return self.migrateVersion122(xml_data)
-
-    def migrateVersion122(self, xml_data):
-        """
-        Convert the xml data from version 1 format to the current format.
-
-        New fields are loaded with defaults to provide a complete, working
-        theme containing all compatible customisations from the old theme.
-
-        ``xml_data``
-            Version 1 theme to convert
-        """
-        theme = Theme(xml_data)
-        newtheme = ThemeXML()
-        newtheme.theme_name = theme.Name
-        if theme.BackgroundType == 0:
-            newtheme.background_type = \
-                BackgroundType.to_string(BackgroundType.Solid)
-            newtheme.background_color = \
-                unicode(theme.BackgroundParameter1.name())
-        elif theme.BackgroundType == 1:
-            newtheme.background_type = \
-                BackgroundType.to_string(BackgroundType.Gradient)
-            newtheme.background_direction = \
-                BackgroundGradientType. \
-                to_string(BackgroundGradientType.Horizontal)
-            if theme.BackgroundParameter3.name() == 1:
-                newtheme.background_direction = \
-                    BackgroundGradientType. \
-                    to_string(BackgroundGradientType.Horizontal)
-            newtheme.background_start_color = \
-                unicode(theme.BackgroundParameter1.name())
-            newtheme.background_end_color = \
-                unicode(theme.BackgroundParameter2.name())
-        else:
-            newtheme.background_type = \
-                BackgroundType.to_string(BackgroundType.Image)
-            newtheme.background_filename = unicode(theme.BackgroundParameter1)
-        newtheme.font_main_name = theme.FontName
-        newtheme.font_main_color = unicode(theme.FontColor.name())
-        newtheme.font_main_size = theme.FontProportion * 3
-        newtheme.font_footer_name = theme.FontName
-        newtheme.font_footer_color = unicode(theme.FontColor.name())
-        newtheme.font_main_shadow = False
-        if theme.Shadow == 1:
-            newtheme.font_main_shadow = True
-            newtheme.font_main_shadow_color = unicode(theme.ShadowColor.name())
-        if theme.Outline == 1:
-            newtheme.font_main_outline = True
-            newtheme.font_main_outline_color = \
-                unicode(theme.OutlineColor.name())
-        vAlignCorrection = 0
-        if theme.VerticalAlign == 2:
-            vAlignCorrection = 1
-        elif theme.VerticalAlign == 1:
-            vAlignCorrection = 2
-        newtheme.display_horizontal_align = theme.HorizontalAlign
-        newtheme.display_vertical_align = vAlignCorrection
-        return newtheme.extract_xml()
+            return self._migrateVersion122(xml_data)
+
+    def checkIfThemeExists(self, themeName):
+        """
+        Check if theme already exists and displays error message
+
+        ``themeName``
+            Name of the Theme to test
+        """
+        theme_dir = os.path.join(self.path, themeName)
+        if os.path.exists(theme_dir):
+            Receiver.send_message(u'openlp_error_message', {
+                u'title': translate('OpenLP.ThemeManager',
+                'Validation Error'),
+                u'message':translate('OpenLP.ThemeManager',
+                'A theme with this name already exists.')})
+            return False
+        return True
 
     def saveTheme(self, theme, imageFrom, imageTo):
         """
@@ -625,82 +583,34 @@
         theme_pretty_xml = theme.extract_formatted_xml()
         log.debug(u'saveTheme %s %s', name, theme_pretty_xml)
         theme_dir = os.path.join(self.path, name)
-        if not os.path.exists(theme_dir):
-            os.mkdir(os.path.join(self.path, name))
+        check_directory_exists(theme_dir)
         theme_file = os.path.join(theme_dir, name + u'.xml')
-        log.debug(theme_file)
-        editedServiceTheme = False
-        result = QtGui.QMessageBox.Yes
-        if self.saveThemeName != name:
-            if os.path.exists(theme_file):
-                result = QtGui.QMessageBox.question(self,
-                    translate('OpenLP.ThemeManager', 'Theme Exists'),
-                    translate('OpenLP.ThemeManager',
-                        'A theme with this name already '
-                        'exists. Would you like to overwrite it?'),
-                    (QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
-                    QtGui.QMessageBox.No)
-            if self.saveThemeName != u'':
-                for plugin in self.parent.pluginManager.plugins:
-                    if plugin.usesTheme(self.saveThemeName):
-                        plugin.renameTheme(self.saveThemeName, name)
-                if unicode(self.serviceComboBox.currentText()) == name:
-                    editedServiceTheme = True
-        if result == QtGui.QMessageBox.Yes:
-            # Save the theme, overwriting the existing theme if necessary.
-            if imageTo and self.oldBackgroundImage and \
-                imageTo != self.oldBackgroundImage:
-                try:
-                    os.remove(self.oldBackgroundImage)
-                except OSError:
-                    log.exception(u'Unable to remove old theme background')
-            outfile = None
-            try:
-                outfile = open(theme_file, u'w')
-                outfile.write(theme_pretty_xml)
+        if imageTo and self.oldBackgroundImage and \
+            imageTo != self.oldBackgroundImage:
+            try:
+                os.remove(self.oldBackgroundImage)
+            except OSError:
+                log.exception(u'Unable to remove old theme background')
+        outfile = None
+        try:
+            outfile = open(theme_file, u'w')
+            outfile.write(theme_pretty_xml)
+        except IOError:
+            log.exception(u'Saving theme to file failed')
+        finally:
+            if outfile:
+                outfile.close()
+        if imageFrom and imageFrom != imageTo:
+            try:
+                encoding = get_filesystem_encoding()
+                shutil.copyfile(
+                    unicode(imageFrom).encode(encoding),
+                    unicode(imageTo).encode(encoding))
             except IOError:
-                log.exception(u'Saving theme to file failed')
-            finally:
-                if outfile:
-                    outfile.close()
-            if imageFrom and imageFrom != imageTo:
-                try:
-                    encoding = get_filesystem_encoding()
-                    shutil.copyfile(
-                        unicode(imageFrom).encode(encoding),
-                        unicode(imageTo).encode(encoding))
-                except IOError:
-                    log.exception(u'Failed to save theme image')
-            self.generateAndSaveImage(self.path, name, theme)
-            self.loadThemes()
-            # Check if we need to set a new service theme
-            if editedServiceTheme:
-                newThemeIndex = self.serviceComboBox.findText(name)
-                if newThemeIndex != -1:
-                    self.serviceComboBox.setCurrentIndex(newThemeIndex)
-            if self.editingDefault:
-                if self.saveThemeName != name:
-                    newThemeItem = self.themeListWidget.findItems(name,
-                        QtCore.Qt.MatchExactly)[0]
-                    newThemeIndex = self.themeListWidget.indexFromItem(
-                        newThemeItem).row()
-                    self.global_theme = unicode(
-                        self.themeListWidget.item(newThemeIndex).text())
-                    newName = unicode(translate('OpenLP.ThemeManager',
-                        '%s (default)')) % self.global_theme
-                    self.themeListWidget.item(newThemeIndex).setText(newName)
-                    QtCore.QSettings().setValue(
-                        self.settingsSection + u'/global theme',
-                        QtCore.QVariant(self.global_theme))
-                    Receiver.send_message(u'theme_update_global',
-                        self.global_theme)
-                self.editingDefault = False
-                self.pushThemes()
-            return True
-        else:
-            # Don't close the dialog - allow the user to change the name of
-            # the theme or to cancel the theme dialog completely.
-            return False
+                log.exception(u'Failed to save theme image')
+        self.generateAndSaveImage(self.path, name, theme)
+        self.loadThemes()
+        self.pushThemes()
 
     def generateAndSaveImage(self, dir, name, theme):
         log.debug(u'generateAndSaveImage %s %s', dir, name)
@@ -740,7 +650,7 @@
         image = os.path.join(self.path, theme + u'.png')
         return image
 
-    def baseTheme(self):
+    def _baseTheme(self):
         """
         Provide a base theme with sensible defaults
         """
@@ -748,7 +658,7 @@
         newtheme = ThemeXML()
         return newtheme
 
-    def createThemeFromXml(self, themeXml, path):
+    def _createThemeFromXml(self, themeXml, path):
         """
         Return a theme object using information parsed from XML
 
@@ -786,20 +696,73 @@
                     translate('OpenLP.ThemeManager',
                         'You are unable to delete the default theme.'))
                 return False
-            else:
-                if testPlugin:
-                    for plugin in self.parent.pluginManager.plugins:
-                        if plugin.usesTheme(theme):
-                            QtGui.QMessageBox.critical(self,
-                                translate('OpenLP.ThemeManager', 'Error'),
-                                unicode(translate('OpenLP.ThemeManager',
-                                    'Theme %s is used in the %s plugin.')) % \
-                                    (theme, plugin.name))
-                            return False
-                if unicode(self.serviceComboBox.currentText()) == theme:
-                    QtGui.QMessageBox.critical(self,
-                        translate('OpenLP.ThemeManager', 'Error'),
-                        unicode(translate('OpenLP.ThemeManager',
-                        'Theme %s is used by the service manager.')) % theme)
-                    return False
+            # check for use in the system else where.
+            if testPlugin:
+                for plugin in self.parent.pluginManager.plugins:
+                    if plugin.usesTheme(theme):
+                        Receiver.send_message(u'openlp_error_message', {
+                            u'title': translate('OpenLP.ThemeManager',
+                            'Validation Error'),
+                            u'message': unicode(translate('OpenLP.ThemeManager',
+                            'Theme %s is used in the %s plugin.')) % \
+                            (theme, plugin.name)})
+                        return False
         return True
+
+    def _migrateVersion122(self, xml_data):
+        """
+        Convert the xml data from version 1 format to the current format.
+
+        New fields are loaded with defaults to provide a complete, working
+        theme containing all compatible customisations from the old theme.
+
+        ``xml_data``
+            Version 1 theme to convert
+        """
+        theme = Theme(xml_data)
+        newtheme = ThemeXML()
+        newtheme.theme_name = theme.Name
+        if theme.BackgroundType == 0:
+            newtheme.background_type = \
+                BackgroundType.to_string(BackgroundType.Solid)
+            newtheme.background_color = \
+                unicode(theme.BackgroundParameter1.name())
+        elif theme.BackgroundType == 1:
+            newtheme.background_type = \
+                BackgroundType.to_string(BackgroundType.Gradient)
+            newtheme.background_direction = \
+                BackgroundGradientType. \
+                to_string(BackgroundGradientType.Horizontal)
+            if theme.BackgroundParameter3.name() == 1:
+                newtheme.background_direction = \
+                    BackgroundGradientType. \
+                    to_string(BackgroundGradientType.Horizontal)
+            newtheme.background_start_color = \
+                unicode(theme.BackgroundParameter1.name())
+            newtheme.background_end_color = \
+                unicode(theme.BackgroundParameter2.name())
+        else:
+            newtheme.background_type = \
+                BackgroundType.to_string(BackgroundType.Image)
+            newtheme.background_filename = unicode(theme.BackgroundParameter1)
+        newtheme.font_main_name = theme.FontName
+        newtheme.font_main_color = unicode(theme.FontColor.name())
+        newtheme.font_main_size = theme.FontProportion * 3
+        newtheme.font_footer_name = theme.FontName
+        newtheme.font_footer_color = unicode(theme.FontColor.name())
+        newtheme.font_main_shadow = False
+        if theme.Shadow == 1:
+            newtheme.font_main_shadow = True
+            newtheme.font_main_shadow_color = unicode(theme.ShadowColor.name())
+        if theme.Outline == 1:
+            newtheme.font_main_outline = True
+            newtheme.font_main_outline_color = \
+                unicode(theme.OutlineColor.name())
+        vAlignCorrection = 0
+        if theme.VerticalAlign == 2:
+            vAlignCorrection = 1
+        elif theme.VerticalAlign == 1:
+            vAlignCorrection = 2
+        newtheme.display_horizontal_align = theme.HorizontalAlign
+        newtheme.display_vertical_align = vAlignCorrection
+        return newtheme.extract_xml()
\ No newline at end of file

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2011-01-06 23:47:28 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2011-01-09 17:22:53 +0000
@@ -30,7 +30,8 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
-    ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver
+    ItemCapabilities, SettingsManager, translate, check_item_selected, \
+    Receiver, check_directory_exists
 from openlp.core.utils import AppLocation, get_images_filter
 
 log = logging.getLogger(__name__)
@@ -87,8 +88,7 @@
         self.servicePath = os.path.join(
             AppLocation.get_section_data_path(self.settingsSection),
             u'thumbnails')
-        if not os.path.exists(self.servicePath):
-            os.mkdir(self.servicePath)
+        check_directory_exists(self.servicePath)
         self.loadList(SettingsManager.load_list(
             self.settingsSection, self.settingsSection))
 
@@ -216,4 +216,4 @@
                     'the image file "%s" no longer exists.')) % filename})
 
     def onPreviewClick(self):
-        MediaManagerItem.onPreviewClick(self)
+        MediaManagerItem.onPreviewClick(self)
\ No newline at end of file

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-01-05 16:50:28 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-01-09 17:22:53 +0000
@@ -153,7 +153,11 @@
             (3, u':/songs/song_search_lyrics.png',
                 translate('SongsPlugin.MediaItem', 'Lyrics')),
             (4, u':/songs/song_search_author.png',
-                translate('SongsPlugin.MediaItem', 'Authors'))])
+                translate('SongsPlugin.MediaItem', 'Authors')),
+            (5, u':/slides/slide_theme.png',
+                translate('SongsPlugin.MediaItem', 'Themes'))
+        ])
+
         self.configUpdated()
 
     def onSearchTextButtonClick(self):
@@ -187,6 +191,12 @@
                 Author.display_name.like(u'%' + search_keywords + u'%'),
                 Author.display_name.asc())
             self.displayResultsAuthor(search_results)
+        elif search_type == 5:
+            log.debug(u'Theme Search')
+            search_results = self.parent.manager.get_all_objects(Song,
+                Song.theme_name == search_keywords,
+                Song.search_lyrics.asc())
+            self.displayResultsSong(search_results)
 
     def onSongListLoad(self):
         """

=== added file 'resources/forms/displaytabeditdialog.ui'
--- resources/forms/displaytabeditdialog.ui	1970-01-01 00:00:00 +0000
+++ resources/forms/displaytabeditdialog.ui	2011-01-09 17:22:53 +0000
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>displayTagEdit</class>
+ <widget class="QWidget" name="displayTagEdit">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>717</width>
+    <height>554</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QGroupBox" name="editGroupBox">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>320</y>
+     <width>691</width>
+     <height>181</height>
+    </rect>
+   </property>
+   <property name="title">
+    <string>Edit Selection</string>
+   </property>
+   <widget class="QPushButton" name="updatePushButton">
+    <property name="geometry">
+     <rect>
+      <x>600</x>
+      <y>140</y>
+      <width>73</width>
+      <height>26</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Update</string>
+    </property>
+   </widget>
+   <widget class="QWidget" name="layoutWidget">
+    <property name="geometry">
+     <rect>
+      <x>20</x>
+      <y>50</y>
+      <width>571</width>
+      <height>114</height>
+     </rect>
+    </property>
+    <layout class="QFormLayout" name="formLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="descriptionLabel">
+       <property name="text">
+        <string>Description</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="QLineEdit" name="descriptionLineEdit"/>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="tagLabel">
+       <property name="text">
+        <string>Tag</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="QLineEdit" name="tagLineEdit">
+       <property name="maximumSize">
+        <size>
+         <width>50</width>
+         <height>16777215</height>
+        </size>
+       </property>
+       <property name="maxLength">
+        <number>5</number>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="startTagLabel">
+       <property name="text">
+        <string>Start tag</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="QLineEdit" name="startTagLineEdit"/>
+     </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="endTagLabel">
+       <property name="text">
+        <string>End tag</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QLineEdit" name="endTagLineEdit"/>
+     </item>
+    </layout>
+   </widget>
+  </widget>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>540</x>
+     <y>510</y>
+     <width>162</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="deletePushButton">
+   <property name="geometry">
+    <rect>
+     <x>530</x>
+     <y>280</y>
+     <width>71</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Delete</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="addPushButton">
+   <property name="geometry">
+    <rect>
+     <x>610</x>
+     <y>280</y>
+     <width>71</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Add</string>
+   </property>
+  </widget>
+  <widget class="QTableWidget" name="tagTableWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>10</y>
+     <width>691</width>
+     <height>271</height>
+    </rect>
+   </property>
+   <property name="horizontalScrollBarPolicy">
+    <enum>Qt::ScrollBarAlwaysOff</enum>
+   </property>
+   <property name="editTriggers">
+    <set>QAbstractItemView::NoEditTriggers</set>
+   </property>
+   <property name="alternatingRowColors">
+    <bool>true</bool>
+   </property>
+   <property name="selectionMode">
+    <enum>QAbstractItemView::SingleSelection</enum>
+   </property>
+   <property name="selectionBehavior">
+    <enum>QAbstractItemView::SelectRows</enum>
+   </property>
+   <property name="cornerButtonEnabled">
+    <bool>false</bool>
+   </property>
+   <column>
+    <property name="text">
+     <string>Description</string>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>Key</string>
+    </property>
+    <property name="textAlignment">
+     <set>AlignHCenter|AlignVCenter|AlignCenter</set>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>Start Tag</string>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>End Tag</string>
+    </property>
+   </column>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>


Follow ups