forked from openlp/openlp
r1464
This commit is contained in:
commit
b8db8807fd
@ -274,8 +274,8 @@ def check_directory_exists(dir):
|
||||
|
||||
from listwidgetwithdnd import ListWidgetWithDnD
|
||||
from displaytags import DisplayTags
|
||||
from spelltextedit import SpellTextEdit
|
||||
from eventreceiver import Receiver
|
||||
from spelltextedit import SpellTextEdit
|
||||
from imagemanager import ImageManager
|
||||
from settingsmanager import SettingsManager
|
||||
from plugin import PluginStatus, StringContent, Plugin
|
||||
|
@ -36,7 +36,9 @@ 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 translate, DisplayTags
|
||||
from openlp.core.lib.ui import checkable_action
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -80,6 +82,19 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
|
||||
if not cursor.hasSelection():
|
||||
cursor.select(QtGui.QTextCursor.WordUnderCursor)
|
||||
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
|
||||
# suggestions if it is.
|
||||
if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
|
||||
@ -93,19 +108,30 @@ 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()) != 0:
|
||||
popupMenu.insertSeparator(popupMenu.actions()[0])
|
||||
if len(spell_menu.actions()):
|
||||
popupMenu.insertMenu(popupMenu.actions()[0], spell_menu)
|
||||
tagMenu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',
|
||||
'Formatting 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)
|
||||
tagMenu.addAction(action)
|
||||
popupMenu.insertSeparator(popupMenu.actions()[0])
|
||||
popupMenu.insertMenu(popupMenu.actions()[0], tagMenu)
|
||||
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):
|
||||
"""
|
||||
Replaces the selected text with word.
|
||||
|
@ -87,7 +87,6 @@ class UiStrings(object):
|
||||
OpenService = translate('OpenLP.Ui', 'Open Service')
|
||||
Preview = translate('OpenLP.Ui', 'Preview')
|
||||
PreviewPanel = translate('OpenLP.Ui', 'Preview Panel')
|
||||
PreviewToolbar = translate('OpenLP.Ui', 'Preview Toolbar')
|
||||
PrintServiceOrder = translate('OpenLP.Ui', 'Print Service Order')
|
||||
ReplaceBG = translate('OpenLP.Ui', 'Replace Background')
|
||||
ReplaceLiveBG = translate('OpenLP.Ui', 'Replace Live Background')
|
||||
@ -427,4 +426,4 @@ def find_and_set_in_combo_box(combo_box, value_to_find):
|
||||
if index == -1:
|
||||
# Not Found.
|
||||
index = 0
|
||||
combo_box.setCurrentIndex(index)
|
||||
combo_box.setCurrentIndex(index)
|
||||
|
@ -222,6 +222,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog):
|
||||
unicode(datetime.timedelta(seconds=tme)), title)
|
||||
# Add the custom service notes:
|
||||
if self.footerTextEdit.toPlainText():
|
||||
div = self._addChildToParent(u'div', parent=html_data.body)
|
||||
self._addChildToParent(u'span', translate('OpenLP.ServiceManager',
|
||||
u'Custom Service Notes:'), div, u'class', u'customNotesTitle')
|
||||
self._addChildToParent(
|
||||
|
@ -368,10 +368,8 @@ class SlideController(QtGui.QWidget):
|
||||
self.previousItem.setObjectName(u'previousItemPreview')
|
||||
self.nextItem.setObjectName(u'nextItemPreview')
|
||||
action_list = ActionList.get_instance()
|
||||
action_list.add_category(
|
||||
UiStrings.PreviewToolbar, CategoryOrder.standardToolbar)
|
||||
action_list.add_action(self.previousItem, UiStrings.PreviewToolbar)
|
||||
action_list.add_action(self.nextItem, UiStrings.PreviewToolbar)
|
||||
action_list.add_action(self.previousItem)
|
||||
action_list.add_action(self.nextItem)
|
||||
|
||||
def setLiveHotkeys(self, parent=None):
|
||||
self.previousItem.setObjectName(u'previousItemLive')
|
||||
@ -379,8 +377,8 @@ class SlideController(QtGui.QWidget):
|
||||
action_list = ActionList.get_instance()
|
||||
action_list.add_category(
|
||||
UiStrings.LiveToolbar, CategoryOrder.standardToolbar)
|
||||
action_list.add_action(self.previousItem, UiStrings.LiveToolbar)
|
||||
action_list.add_action(self.nextItem, UiStrings.LiveToolbar)
|
||||
action_list.add_action(self.previousItem)
|
||||
action_list.add_action(self.nextItem)
|
||||
self.previousService = shortcut_action(parent, u'previousService',
|
||||
[QtCore.Qt.Key_Left], self.servicePrevious, UiStrings.LiveToolbar)
|
||||
self.previousService.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
|
||||
|
@ -177,10 +177,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
Returns the version name of the Bible.
|
||||
"""
|
||||
version_name = self.get_object(BibleMeta, u'Version')
|
||||
if version_name:
|
||||
self.name = version_name.value
|
||||
else:
|
||||
self.name = None
|
||||
self.name = version_name.value if version_name else None
|
||||
return self.name
|
||||
|
||||
def clean_filename(self, old_filename):
|
||||
@ -256,10 +253,10 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
# Text list has book and chapter as first two elements of the array.
|
||||
for verse_number, verse_text in textlist.iteritems():
|
||||
verse = Verse.populate(
|
||||
book_id = book_id,
|
||||
chapter = chapter,
|
||||
verse = verse_number,
|
||||
text = verse_text
|
||||
book_id=book_id,
|
||||
chapter=chapter,
|
||||
verse=verse_number,
|
||||
text=verse_text
|
||||
)
|
||||
self.session.add(verse)
|
||||
self.session.commit()
|
||||
@ -383,15 +380,13 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
log.debug(u'BibleDB.verse_search("%s")', text)
|
||||
verses = self.session.query(Verse)
|
||||
if text.find(u',') > -1:
|
||||
or_clause = []
|
||||
keywords = [u'%%%s%%' % keyword.strip()
|
||||
for keyword in text.split(u',')]
|
||||
for keyword in keywords:
|
||||
or_clause.append(Verse.text.like(keyword))
|
||||
keywords = \
|
||||
[u'%%%s%%' % keyword.strip() for keyword in text.split(u',')]
|
||||
or_clause = [Verse.text.like(keyword) for keyword in keywords]
|
||||
verses = verses.filter(or_(*or_clause))
|
||||
else:
|
||||
keywords = [u'%%%s%%' % keyword.strip()
|
||||
for keyword in text.split(u' ')]
|
||||
keywords = \
|
||||
[u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')]
|
||||
for keyword in keywords:
|
||||
verses = verses.filter(Verse.text.like(keyword))
|
||||
verses = verses.all()
|
||||
|
Loading…
Reference in New Issue
Block a user