forked from openlp/openlp
- added spellchecker to service notes dialog (bug #825979); - escape texts in various places (bug #825983)
bzr-revno: 1710 Fixes: https://launchpad.net/bugs/825979, https://launchpad.net/bugs/825983
This commit is contained in:
commit
d46eecd96d
@ -48,9 +48,10 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
"""
|
||||
Spell checking widget based on QPlanTextEdit.
|
||||
"""
|
||||
def __init__(self, *args):
|
||||
def __init__(self, parent=None, formattingTagsAllowed=True):
|
||||
global ENCHANT_AVAILABLE
|
||||
QtGui.QPlainTextEdit.__init__(self, *args)
|
||||
QtGui.QPlainTextEdit.__init__(self, parent)
|
||||
self.formattingTagsAllowed = formattingTagsAllowed
|
||||
# Default dictionary based on the current locale.
|
||||
if ENCHANT_AVAILABLE:
|
||||
try:
|
||||
@ -110,16 +111,17 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
spell_menu.addAction(action)
|
||||
# Only add the spelling suggests to the menu if there are
|
||||
# suggestions.
|
||||
if len(spell_menu.actions()):
|
||||
if spell_menu.actions():
|
||||
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
|
||||
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
|
||||
'Formatting Tags'))
|
||||
for html in FormattingTags.get_html_tags():
|
||||
action = SpellAction(html[u'desc'], tagMenu)
|
||||
action.correct.connect(self.htmlTag)
|
||||
tagMenu.addAction(action)
|
||||
popupMenu.insertSeparator(popupMenu.actions()[0])
|
||||
popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
|
||||
if self.formattingTagsAllowed:
|
||||
for html in FormattingTags.get_html_tags():
|
||||
action = SpellAction(html[u'desc'], tagMenu)
|
||||
action.correct.connect(self.htmlTag)
|
||||
tagMenu.addAction(action)
|
||||
popupMenu.insertSeparator(popupMenu.actions()[0])
|
||||
popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
|
||||
popupMenu.exec_(event.globalPos())
|
||||
|
||||
def setLanguage(self, action):
|
||||
|
@ -108,7 +108,7 @@ class Ui_PrintServiceDialog(object):
|
||||
self.footerLabel = QtGui.QLabel(self.optionsWidget)
|
||||
self.footerLabel.setObjectName(u'footerLabel')
|
||||
self.optionsLayout.addWidget(self.footerLabel)
|
||||
self.footerTextEdit = SpellTextEdit(self.optionsWidget)
|
||||
self.footerTextEdit = SpellTextEdit(self.optionsWidget, False)
|
||||
self.footerTextEdit.setObjectName(u'footerTextEdit')
|
||||
self.optionsLayout.addWidget(self.footerTextEdit)
|
||||
self.optionsGroupBox = QtGui.QGroupBox()
|
||||
|
@ -24,6 +24,7 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
import cgi
|
||||
import datetime
|
||||
import os
|
||||
|
||||
@ -183,7 +184,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
self._addElement(u'style', custom_css, html_data.head,
|
||||
attribute=(u'type', u'text/css'))
|
||||
self._addElement(u'body', parent=html_data)
|
||||
self._addElement(u'h1', unicode(self.titleLineEdit.text()),
|
||||
self._addElement(u'h1', cgi.escape(unicode(self.titleLineEdit.text())),
|
||||
html_data.body, classId=u'serviceTitle')
|
||||
for index, item in enumerate(self.serviceManager.serviceItems):
|
||||
self._addPreviewItem(html_data.body, item[u'service_item'], index)
|
||||
@ -193,8 +194,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
classId=u'customNotes')
|
||||
self._addElement(u'span', translate('OpenLP.ServiceManager',
|
||||
'Custom Service Notes: '), div, classId=u'customNotesTitle')
|
||||
self._addElement(u'span', self.footerTextEdit.toPlainText(), div,
|
||||
classId=u'customNotesText')
|
||||
self._addElement(u'span',
|
||||
cgi.escape(self.footerTextEdit.toPlainText()),
|
||||
div, classId=u'customNotesText')
|
||||
self.document.setHtml(html.tostring(html_data))
|
||||
self.previewWidget.updatePreview()
|
||||
|
||||
@ -204,8 +206,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
item_title = self._addElement(u'h2', parent=div, classId=u'itemTitle')
|
||||
self._addElement(u'img', parent=item_title,
|
||||
attribute=(u'src', item.icon))
|
||||
self._addElement(u'span', u' ' + item.get_display_title(),
|
||||
item_title)
|
||||
self._addElement(u'span',
|
||||
u' ' + cgi.escape(item.get_display_title()), item_title)
|
||||
if self.slideTextCheckBox.isChecked():
|
||||
# Add the text of the service item.
|
||||
if item.is_text():
|
||||
@ -230,8 +232,9 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
foot_text = item.foot_text
|
||||
foot_text = foot_text.partition(u'<br>')[2]
|
||||
if foot_text:
|
||||
foot = self._addElement(u'div', foot_text, parent=div,
|
||||
classId=u'itemFooter')
|
||||
foot_text = cgi.escape(foot_text.replace(u'<br>', u'\n'))
|
||||
self._addElement(u'div', foot_text.replace(u'\n', u'<br>'),
|
||||
parent=div, classId=u'itemFooter')
|
||||
# Add service items' notes.
|
||||
if self.notesCheckBox.isChecked():
|
||||
if item.notes:
|
||||
@ -239,8 +242,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
self._addElement(u'span',
|
||||
translate('OpenLP.ServiceManager', 'Notes: '), p,
|
||||
classId=u'itemNotesTitle')
|
||||
notes = self._addElement(u'span',
|
||||
item.notes.replace(u'\n', u'<br>'), p,
|
||||
self._addElement(u'span',
|
||||
cgi.escape(unicode(item.notes)).replace(u'\n', u'<br>'), p,
|
||||
classId=u'itemNotesText')
|
||||
# Add play length of media files.
|
||||
if item.is_media() and self.metaDataCheckBox.isChecked():
|
||||
|
@ -24,6 +24,7 @@
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
import cgi
|
||||
import cPickle
|
||||
import logging
|
||||
import os
|
||||
@ -719,6 +720,9 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.setModified()
|
||||
|
||||
def onStartTimeForm(self):
|
||||
"""
|
||||
Opens a dialog to type in service item notes.
|
||||
"""
|
||||
item = self.findServiceItem()[0]
|
||||
self.startTimeForm.item = self.serviceItems[item]
|
||||
if self.startTimeForm.exec_():
|
||||
@ -957,7 +961,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
if serviceitem.notes:
|
||||
tips.append(u'<strong>%s: </strong> %s' %
|
||||
(unicode(translate('OpenLP.ServiceManager', 'Notes')),
|
||||
unicode(serviceitem.notes)))
|
||||
cgi.escape(unicode(serviceitem.notes))))
|
||||
if item[u'service_item'] \
|
||||
.is_capable(ItemCapabilities.AllowsVariableStartTime):
|
||||
tips.append(item[u'service_item'].get_media_time())
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib import translate, SpellTextEdit
|
||||
from openlp.core.lib.ui import create_accept_reject_button_box
|
||||
|
||||
class ServiceNoteForm(QtGui.QDialog):
|
||||
@ -52,7 +52,7 @@ class ServiceNoteForm(QtGui.QDialog):
|
||||
self.dialogLayout.setContentsMargins(8, 8, 8, 8)
|
||||
self.dialogLayout.setSpacing(8)
|
||||
self.dialogLayout.setObjectName(u'verticalLayout')
|
||||
self.textEdit = QtGui.QTextEdit(self)
|
||||
self.textEdit = SpellTextEdit(self, False)
|
||||
self.textEdit.setObjectName(u'textEdit')
|
||||
self.dialogLayout.addWidget(self.textEdit)
|
||||
self.dialogLayout.addWidget(create_accept_reject_button_box(self))
|
||||
|
Loading…
Reference in New Issue
Block a user