Cleaned up initialisation and config settings for spell checking

This commit is contained in:
Veronica K. B. Olsen
2019-11-06 11:45:17 +01:00
parent 9a8b97abd6
commit f5af3fb293
4 changed files with 53 additions and 38 deletions
+13 -6
View File
@@ -26,7 +26,7 @@ from PyQt5.QtGui import (
from nw.project import NWDoc
from nw.gui.tools import GuiDocHighlighter, WordCounter
from nw.tools import NWSpellCheck
from nw.tools import NWSpellCheck, NWSpellSimple
from nw.constants import nwFiles, nwUnicode, nwDocAction, nwAlert
logger = logging.getLogger(__name__)
@@ -64,11 +64,7 @@ class GuiDocEditor(QTextEdit):
self.qDocument = self.document()
self.qDocument.setDocumentMargin(self.mainConf.textMargin)
self.qDocument.contentsChange.connect(self._docChange)
if self.mainConf.spellTool == "enchant":
from nw.tools.spellenchant import NWSpellEnchant
self.theDict = NWSpellEnchant()
else:
self.theDict = NWSpellCheck()
self._setupSpellChecking()
self.hLight = GuiDocHighlighter(self.qDocument, self.theParent)
self.hLight.setDict(self.theDict)
@@ -727,4 +723,15 @@ class GuiDocEditor(QTextEdit):
self._findNext()
return
def _setupSpellChecking(self):
"""Create the spell checking object based on the spellTool
setting in config.
"""
if self.mainConf.spellTool == "enchant":
from nw.tools.spellenchant import NWSpellEnchant
self.theDict = NWSpellEnchant()
else:
self.theDict = NWSpellSimple()
return
# END Class GuiDocEditor