Fixed the loading of dictionaries

This commit is contained in:
Veronica K. B. Olsen
2019-06-12 20:33:06 +02:00
parent 09aa19ff48
commit 46bd7a8871
3 changed files with 11 additions and 8 deletions
+7 -7
View File
@@ -23,6 +23,7 @@ from nw.project.document import NWDoc
from nw.gui.dochighlight import GuiDocHighlighter
from nw.gui.wordcounter import WordCounter
from nw.tools.spellcheck import NWSpellCheck
from nw.constants import nwFiles
from nw.enum import nwDocAction, nwAlert
logger = logging.getLogger(__name__)
@@ -39,7 +40,6 @@ class GuiDocEditor(QTextEdit):
self.theParent = theParent
self.theProject = theProject
self.docChanged = False
self.pwlFile = None
self.spellCheck = False
self.theDocument = NWDoc(self.theProject, self.theParent)
self.theHandle = None
@@ -64,8 +64,7 @@ class GuiDocEditor(QTextEdit):
else:
self.theDict = NWSpellCheck()
self.theDict.setLanguage(self.mainConf.spellLanguage)
self.hLight = GuiDocHighlighter(self.theQDoc, self.theParent)
self.hLight = GuiDocHighlighter(self.theQDoc, self.theParent)
self.hLight.setDict(self.theDict)
# Context Menu
@@ -123,6 +122,9 @@ class GuiDocEditor(QTextEdit):
main editor preferences.
"""
# Reload dictionaries
self.setDictionaries()
# Set Font
if self.mainConf.textFont is not None:
self.setFontFamily(self.mainConf.textFont)
@@ -218,10 +220,8 @@ class GuiDocEditor(QTextEdit):
# Spell Checking
##
def setPwl(self, pwlFile):
if pwlFile is not None:
self.pwlFile = pwlFile
self.theDict.setLanguage(self.mainConf.spellLanguage, pwlFile)
def setDictionaries(self):
self.theDict.setLanguage(self.mainConf.spellLanguage, self.theProject.projDict)
return True
def setSpellCheck(self, theMode):
+1 -1
View File
@@ -245,7 +245,7 @@ class GuiMain(QMainWindow):
# Update GUI
self._setWindowTitle(self.theProject.projName)
self.rebuildTree()
self.docEditor.setPwl(path.join(self.theProject.projMeta, nwFiles.PROJ_DICT))
self.docEditor.setDictionaries()
self.docEditor.setSpellCheck(self.theProject.spellCheck)
self.statusBar.setRefTime(self.theProject.projOpened)
self.mainMenu.updateMenu()
+3
View File
@@ -48,6 +48,7 @@ class NWProject():
self.projPath = None
self.projMeta = None
self.projCache = None
self.projDict = None
self.projFile = None
# Project Meta
@@ -149,6 +150,7 @@ class NWProject():
self.projPath = None
self.projMeta = None
self.projCache = None
self.projDict = None
self.projFile = nwFiles.PROJ_FILE
self.projName = ""
self.bookTitle = ""
@@ -186,6 +188,7 @@ class NWProject():
self.projMeta = path.join(self.projPath,"meta")
self.projCache = path.join(self.projPath,"cache")
self.projDict = path.join(self.projMeta, nwFiles.PROJ_DICT)
if not self._checkFolder(self.projMeta): return
if not self._checkFolder(self.projCache): return