Remove border and handle missing enchant

This commit is contained in:
Tim Bentley 2010-08-23 05:58:32 +01:00
parent a4e58c3349
commit 37d1ab68b4
2 changed files with 11 additions and 5 deletions

View File

@ -31,7 +31,11 @@ The :mod:`ui` module provides the core user interface for OpenLP
import re import re
import sys import sys
import enchant try:
import enchant
enchant_available = True
except ImportError:
enchant_available = False
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import html_expands, translate, context_menu_action from openlp.core.lib import html_expands, translate, context_menu_action
@ -41,9 +45,10 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
def __init__(self, *args): def __init__(self, *args):
QtGui.QPlainTextEdit.__init__(self, *args) QtGui.QPlainTextEdit.__init__(self, *args)
# Default dictionary based on the current locale. # Default dictionary based on the current locale.
self.dict = enchant.Dict() if enchant_available:
self.highlighter = Highlighter(self.document()) self.dict = enchant.Dict()
self.highlighter.setDict(self.dict) self.highlighter = Highlighter(self.document())
self.highlighter.setDict(self.dict)
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button() == QtCore.Qt.RightButton: if event.button() == QtCore.Qt.RightButton:
@ -63,7 +68,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit):
# 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 self.textCursor().hasSelection(): if enchant_available and self.textCursor().hasSelection():
text = unicode(self.textCursor().selectedText()) text = unicode(self.textCursor().selectedText())
if not self.dict.check(text): if not self.dict.check(text):
spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit',

View File

@ -55,6 +55,7 @@ class DisplayWidget(QtGui.QGraphicsView):
QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop', QtCore.Qt.Key_Enter: 'slidecontroller_live_next_noloop',
QtCore.Qt.Key_0: 'servicemanager_next_item', QtCore.Qt.Key_0: 'servicemanager_next_item',
QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'} QtCore.Qt.Key_Backspace: 'slidecontroller_live_previous_noloop'}
self.setStyleSheet(u'border: none;')
def keyPressEvent(self, event): def keyPressEvent(self, event):
# Key events only needed for live # Key events only needed for live