diff --git a/openlp.pyw b/openlp.pyw
index 17743903f..8998e89b9 100755
--- a/openlp.pyw
+++ b/openlp.pyw
@@ -159,7 +159,7 @@ class OpenLP(QtGui.QApplication):
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)
self.setOrganizationName(u'OpenLP')
diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py
index 956b6c787..620afe1b6 100644
--- a/openlp/core/lib/__init__.py
+++ b/openlp/core/lib/__init__.py
@@ -35,52 +35,51 @@ from PyQt4 import QtCore, QtGui
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'',
- u'end tag': u'{/r}', u'end html': u'', u'protected': False})
-html_expands.append({u'desc': u'Black', u'start tag': u'{b}',
+ 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': False})
-html_expands.append({u'desc': u'Blue', u'start tag': u'{bl}',
+ 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': False})
-html_expands.append({u'desc': u'Yellow', u'start tag': u'{y}',
+ 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': False})
-html_expands.append({u'desc': u'Green', u'start tag': u'{g}',
+ 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': False})
-html_expands.append({u'desc': u'Pink', u'start tag': u'{pk}',
+ 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': False})
-html_expands.append({u'desc': u'Orange', u'start tag': u'{o}',
+ 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': False})
-html_expands.append({u'desc': u'Purple', u'start tag': u'{pp}',
+ 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': False})
-html_expands.append({u'desc': u'White', u'start tag': u'{w}',
+ 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': False})
-html_expands.append({u'desc': u'Superscript', u'start tag': u'{su}',
+ 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})
-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'', u'end tag': u'{/sb}', u'end html': u'',
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'
', u'end tag': u'{/p}', u'end html': u'
',
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'', u'end tag': u'{/st}', u'end html': u'',
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'', u'end tag': u'{/it}', u'end html': u'',
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'',
u'end tag': u'{/u}', u'end html': u'', u'protected': True})
@@ -292,7 +291,7 @@ def clean_tags(text):
Remove Tags from text for display
"""
text = text.replace(u'
', u'\n')
- for tag in html_expands:
+ for tag in DisplayTags.get_html_tags().html_expands:
text = text.replace(tag[u'start tag'], u'')
text = text.replace(tag[u'end tag'], u'')
return text
@@ -301,13 +300,14 @@ def expand_tags(text):
"""
Expand tags HTML for display
"""
- for tag in html_expands:
+ for tag in DisplayTags.get_html_tags().html_expands:
text = text.replace(tag[u'start tag'], tag[u'start html'])
text = text.replace(tag[u'end tag'], tag[u'end html'])
return text
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
diff --git a/openlp/core/lib/displaytags.py b/openlp/core/lib/displaytags.py
new file mode 100644
index 000000000..2a47e2e09
--- /dev/null
+++ b/openlp/core/lib/displaytags.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman #
+# Portions copyright (c) 2008-2010 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 HtmlTags(object):
+ """
+ """
+ def __init__(self):
+ self.html_expands = []
+ self.eyeCatcher = "eyeCatcher"
+ self.reset_list()
+
+ def reset_list(self):
+ """
+ """
+ self.html_expands = []
+ for html in base_html_expands:
+ self.html_expands.append(html)
+
+ def add_tag(self, html):
+ """
+ """
+ self.html_expands.append(html)
+
+
+class DisplayTags(object):
+ """
+ Static Class to HTML Tags to be access around the code the list is managed
+ by the Options Tab.
+ """
+ html_tags = HtmlTags()
+
+ @staticmethod
+ def get_html_tags():
+ """
+ Provide access to the HtmlTags object.
+ """
+ return DisplayTags.html_tags
+
diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py
index f73b58735..405cd531e 100644
--- a/openlp/core/lib/plugin.py
+++ b/openlp/core/lib/plugin.py
@@ -175,6 +175,10 @@ class Plugin(QtCore.QObject):
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):
"""
diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py
index 048751006..beb252387 100644
--- a/openlp/core/lib/settingstab.py
+++ b/openlp/core/lib/settingstab.py
@@ -87,6 +87,12 @@ class SettingsTab(QtGui.QWidget):
"""
pass
+ def cancel(self):
+ """
+ Reset any settings
+ """
+ pass
+
def postSetUp(self, postUpdate=False):
"""
Changes which need to be made after setup of application
diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py
index 76271b6a7..4aa1d37a4 100644
--- a/openlp/core/lib/spelltextedit.py
+++ b/openlp/core/lib/spelltextedit.py
@@ -36,7 +36,7 @@ except ImportError:
# 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 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
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().html_expands:
action = SpellAction( html[u'desc'], tagMenu)
action.correct.connect(self.htmlTag)
tagMenu.addAction(action)
@@ -110,7 +110,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
"""
Replaces the selected text with word.
"""
- for html in html_expands:
+ for html in DisplayTags.get_html_tags().html_expands:
if tag == html[u'desc']:
cursor = self.textCursor()
if self.textCursor().hasSelection():
diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py
index 377999553..7c5991a54 100644
--- a/openlp/core/ui/__init__.py
+++ b/openlp/core/ui/__init__.py
@@ -48,6 +48,7 @@ from splashscreen import SplashScreen
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
diff --git a/openlp/core/ui/displaytagtab.py b/openlp/core/ui/displaytagtab.py
new file mode 100644
index 000000000..56c9fd911
--- /dev/null
+++ b/openlp/core/ui/displaytagtab.py
@@ -0,0 +1,344 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman #
+# Portions copyright (c) 2008-2010 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 preLoad(self):
+ """
+ Initialise values before the Load takes place
+ """
+ # Create initial copy from master
+ print DisplayTags.get_html_tags().eyeCatcher
+ DisplayTags.get_html_tags().reset_list()
+ user_expands = QtCore.QSettings().value(u'displayTags/html_tags',
+ QtCore.QVariant(u'')).toString()
+ # cPickle only accepts str not unicode strings
+ user_tags = cPickle.loads(str(user_expands))
+ # If we have some user ones added them as well
+ for t in user_tags:
+ DisplayTags.get_html_tags().add_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, 691, 181))
+ self.editGroupBox.setObjectName(u'editGroupBox')
+ self.updatePushButton = QtGui.QPushButton(self.editGroupBox)
+ self.updatePushButton.setGeometry(QtCore.QRect(600, 140, 71, 26))
+ self.updatePushButton.setObjectName(u'updatePushButton')
+ self.layoutWidget = QtGui.QWidget(self.editGroupBox)
+ self.layoutWidget.setGeometry(QtCore.QRect(20, 50, 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(450, 188, 71, 26))
+ self.defaultPushButton.setObjectName(u'updatePushButton')
+ self.deletePushButton = QtGui.QPushButton(self.displayTagEdit)
+ self.deletePushButton.setGeometry(QtCore.QRect(530, 188, 71, 26))
+ self.deletePushButton.setObjectName(u'deletePushButton')
+ self.newPushButton = QtGui.QPushButton(self.displayTagEdit)
+ self.newPushButton.setGeometry(QtCore.QRect(610, 188, 71, 26))
+ self.newPushButton.setObjectName(u'newPushButton')
+ self.tagTableWidget = QtGui.QTableWidget(self.displayTagEdit)
+ self.tagTableWidget.setGeometry(QtCore.QRect(10, 10, 691, 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, 280)
+ 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().html_expands):
+ 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().html_expands:
+ 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().html_expands[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().html_expands:
+ 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
+ DisplayTags.get_html_tags().html_expands.append(
+ {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})
+ self._resetTable()
+
+ def onDefaultPushed(self):
+ """
+ Remove all Custom Tags and reset to base set only.
+ """
+ DisplayTags.get_html_tags().reset_list()
+ self._resetTable()
+
+ def onDeletePushed(self):
+ """
+ Delete selected custom tag.
+ """
+ if self.selected != -1:
+ DisplayTags.get_html_tags().html_expands.pop(self.selected)
+ self.selected = -1
+ self._resetTable()
+
+ def onUpdatePushed(self):
+ """
+ Update Custom Tag details if not duplicate.
+ """
+ html_expands = DisplayTags.get_html_tags().html_expands
+ 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
diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py
index 69eb9305d..aa3445fbb 100644
--- a/openlp/core/ui/maindisplay.py
+++ b/openlp/core/ui/maindisplay.py
@@ -31,7 +31,8 @@ import os
from PyQt4 import QtCore, QtGui, QtWebKit
from PyQt4.phonon import Phonon
-from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte
+from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
+ build_icon
from openlp.core.ui import HideMode
log = logging.getLogger(__name__)
@@ -102,6 +103,8 @@ class MainDisplay(DisplayWidget):
self.isLive = live
self.alertTab = None
self.hideMode = None
+ mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
+ self.setWindowIcon(mainIcon)
self.setWindowTitle(u'OpenLP Display')
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
self.setWindowFlags(QtCore.Qt.FramelessWindowHint |
diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py
index 3d3a814a0..2189b38be 100644
--- a/openlp/core/ui/pluginform.py
+++ b/openlp/core/ui/pluginform.py
@@ -125,10 +125,8 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
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:
diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py
index d1cf19622..15a8056c2 100644
--- a/openlp/core/ui/settingsform.py
+++ b/openlp/core/ui/settingsform.py
@@ -31,7 +31,7 @@ import logging
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 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
# Advanced tab
self.advancedTab = AdvancedTab()
self.addTab(u'Advanced', self.advancedTab)
+ # Edit Tags tab
+ displayTagTab = DisplayTagTab()
+ self.addTab(u'Display Tags', displayTagTab)
def addTab(self, name, tab):
"""
@@ -68,9 +71,9 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
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 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
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
diff --git a/resources/forms/displaytabeditdialog.ui b/resources/forms/displaytabeditdialog.ui
new file mode 100644
index 000000000..3c748594f
--- /dev/null
+++ b/resources/forms/displaytabeditdialog.ui
@@ -0,0 +1,209 @@
+
+
+ displayTagEdit
+
+
+
+ 0
+ 0
+ 717
+ 554
+
+
+
+ Form
+
+
+
+
+ 10
+ 320
+ 691
+ 181
+
+
+
+ Edit Selection
+
+
+
+
+ 600
+ 140
+ 73
+ 26
+
+
+
+ Update
+
+
+
+
+
+ 20
+ 50
+ 571
+ 114
+
+
+
+ -
+
+
+ Description
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ -
+
+
+ Tag
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+ 50
+ 16777215
+
+
+
+ 5
+
+
+
+ -
+
+
+ Start tag
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ -
+
+
+ End tag
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+
+
+
+
+
+
+ 540
+ 510
+ 162
+ 26
+
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+ 530
+ 280
+ 71
+ 26
+
+
+
+ Delete
+
+
+
+
+
+ 610
+ 280
+ 71
+ 26
+
+
+
+ Add
+
+
+
+
+
+ 10
+ 10
+ 691
+ 271
+
+
+
+ Qt::ScrollBarAlwaysOff
+
+
+ QAbstractItemView::NoEditTriggers
+
+
+ true
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+ false
+
+
+
+ Description
+
+
+
+
+ Key
+
+
+ AlignHCenter|AlignVCenter|AlignCenter
+
+
+
+
+ Start Tag
+
+
+
+
+ End Tag
+
+
+
+
+
+
+