Add Html Tags to context menu

This commit is contained in:
Tim Bentley 2010-08-22 08:39:23 +01:00
parent f705b69e20
commit ed4801b48a
2 changed files with 20 additions and 4 deletions

View File

@ -314,7 +314,6 @@ def build_html(item, screen, alert):
build_lyrics(item),
u'true' if theme and theme.display_slideTransition else u'false',
image)
print html
return html
def build_lyrics(item):

View File

@ -34,16 +34,17 @@ import sys
import enchant
from PyQt4 import QtCore, QtGui
from openlp.core.lib import html_expands, translate, context_menu_action
class SpellTextEdit(QtGui.QPlainTextEdit):
class BaseSpellTextEdit(QtGui.QPlainTextEdit):
def __init__(self, *args):
QtGui.QPlainTextEdit.__init__(self, *args)
# Default dictionary based on the current locale.
self.dict = enchant.Dict()
self.highlighter = Highlighter(self.document())
self.highlighter.setDict(self.dict)
print html_expands
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.RightButton:
@ -66,7 +67,8 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
if self.textCursor().hasSelection():
text = unicode(self.textCursor().selectedText())
if not self.dict.check(text):
spell_menu = QtGui.QMenu(u'Spelling Suggestions')
spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
'Spelling Suggestions'))
for word in self.dict.suggest(text):
action = SpellAction(word, spell_menu)
action.correct.connect(self.correctWord)
@ -76,6 +78,14 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
if len(spell_menu.actions()) != 0:
popup_menu.insertSeparator(popup_menu.actions()[0])
popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
tag_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
'Formatting Tags'))
for html in html_expands:
action = context_menu_action(self, None, html[u'desc'],
self.onHtmlAction)
tag_menu.addAction(action)
popup_menu.insertSeparator(popup_menu.actions()[0])
popup_menu.insertMenu(popup_menu.actions()[0], tag_menu)
popup_menu.exec_(event.globalPos())
@ -130,6 +140,13 @@ class SpellAction(QtGui.QAction):
self.triggered.connect(lambda x: self.correct.emit(
unicode(self.text())))
class SpellTextEdit(BaseSpellTextEdit):
def __init__(self, *args):
BaseSpellTextEdit.__init__(self, *args)
def onHtmlAction(self):
print "hello "
class HideMode(object):
"""
This is basically an enumeration class which specifies the mode of a Bible.