This commit is contained in:
Tim Bentley 2011-04-14 19:31:09 +01:00
commit 0468a39dd2
3 changed files with 31 additions and 4 deletions

View File

@ -274,8 +274,8 @@ def check_directory_exists(dir):
from listwidgetwithdnd import ListWidgetWithDnD from listwidgetwithdnd import ListWidgetWithDnD
from displaytags import DisplayTags from displaytags import DisplayTags
from spelltextedit import SpellTextEdit
from eventreceiver import Receiver from eventreceiver import Receiver
from spelltextedit import SpellTextEdit
from imagemanager import ImageManager from imagemanager import ImageManager
from settingsmanager import SettingsManager from settingsmanager import SettingsManager
from plugin import PluginStatus, StringContent, Plugin from plugin import PluginStatus, StringContent, Plugin

View File

@ -36,7 +36,9 @@ except ImportError:
# http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check # http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, DisplayTags from openlp.core.lib import translate, DisplayTags
from openlp.core.lib.ui import checkable_action
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -80,6 +82,19 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
if not cursor.hasSelection(): if not cursor.hasSelection():
cursor.select(QtGui.QTextCursor.WordUnderCursor) cursor.select(QtGui.QTextCursor.WordUnderCursor)
self.setTextCursor(cursor) self.setTextCursor(cursor)
# Add menu with available languages.
if ENCHANT_AVAILABLE:
lang_menu = QtGui.QMenu(
translate('OpenLP.SpellTextEdit', 'Language:'))
for lang in enchant.list_languages():
action = checkable_action(
lang_menu, lang, lang == self.dictionary.tag)
action.setText(lang)
lang_menu.addAction(action)
popupMenu.insertSeparator(popupMenu.actions()[0])
popupMenu.insertMenu(popupMenu.actions()[0], lang_menu)
QtCore.QObject.connect(lang_menu,
QtCore.SIGNAL(u'triggered(QAction*)'), self.setLanguage)
# Check if the selected word is misspelled and offer spelling # Check if the selected word is misspelled and offer spelling
# suggestions if it is. # suggestions if it is.
if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
@ -93,19 +108,30 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
spell_menu.addAction(action) spell_menu.addAction(action)
# Only add the spelling suggests to the menu if there are # Only add the spelling suggests to the menu if there are
# suggestions. # suggestions.
if len(spell_menu.actions()) != 0: if len(spell_menu.actions()):
popupMenu.insertSeparator(popupMenu.actions()[0])
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu) popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
'Formatting Tags')) 'Formatting Tags'))
for html in DisplayTags.get_html_tags(): for html in DisplayTags.get_html_tags():
action = SpellAction( html[u'desc'], tagMenu) action = SpellAction(html[u'desc'], tagMenu)
action.correct.connect(self.htmlTag) action.correct.connect(self.htmlTag)
tagMenu.addAction(action) tagMenu.addAction(action)
popupMenu.insertSeparator(popupMenu.actions()[0]) popupMenu.insertSeparator(popupMenu.actions()[0])
popupMenu.insertMenu(popupMenu.actions()[0], tagMenu) popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
popupMenu.exec_(event.globalPos()) popupMenu.exec_(event.globalPos())
def setLanguage(self, action):
"""
Changes the language for this spelltextedit.
``action``
The action.
"""
self.dictionary = enchant.Dict(action.text())
self.highlighter.spellingDictionary = self.dictionary
self.highlighter.highlightBlock(self.toPlainText())
self.highlighter.rehighlight()
def correctWord(self, word): def correctWord(self, word):
""" """
Replaces the selected text with word. Replaces the selected text with word.

View File

@ -222,6 +222,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
unicode(datetime.timedelta(seconds=tme)), title) unicode(datetime.timedelta(seconds=tme)), title)
# Add the custom service notes: # Add the custom service notes:
if self.footerTextEdit.toPlainText(): if self.footerTextEdit.toPlainText():
div = self._addChildToParent(u'div', parent=html_data.body)
self._addChildToParent(u'span', translate('OpenLP.ServiceManager', self._addChildToParent(u'span', translate('OpenLP.ServiceManager',
u'Custom Service Notes:'), div, u'class', u'customNotesTitle') u'Custom Service Notes:'), div, u'class', u'customNotesTitle')
self._addChildToParent( self._addChildToParent(