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.dochighlight import GuiDocHighlighter
from nw.gui.wordcounter import WordCounter from nw.gui.wordcounter import WordCounter
from nw.tools.spellcheck import NWSpellCheck from nw.tools.spellcheck import NWSpellCheck
from nw.constants import nwFiles
from nw.enum import nwDocAction, nwAlert from nw.enum import nwDocAction, nwAlert
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -39,7 +40,6 @@ class GuiDocEditor(QTextEdit):
self.theParent = theParent self.theParent = theParent
self.theProject = theProject self.theProject = theProject
self.docChanged = False self.docChanged = False
self.pwlFile = None
self.spellCheck = False self.spellCheck = False
self.theDocument = NWDoc(self.theProject, self.theParent) self.theDocument = NWDoc(self.theProject, self.theParent)
self.theHandle = None self.theHandle = None
@@ -64,8 +64,7 @@ class GuiDocEditor(QTextEdit):
else: else:
self.theDict = NWSpellCheck() 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) self.hLight.setDict(self.theDict)
# Context Menu # Context Menu
@@ -123,6 +122,9 @@ class GuiDocEditor(QTextEdit):
main editor preferences. main editor preferences.
""" """
# Reload dictionaries
self.setDictionaries()
# Set Font # Set Font
if self.mainConf.textFont is not None: if self.mainConf.textFont is not None:
self.setFontFamily(self.mainConf.textFont) self.setFontFamily(self.mainConf.textFont)
@@ -218,10 +220,8 @@ class GuiDocEditor(QTextEdit):
# Spell Checking # Spell Checking
## ##
def setPwl(self, pwlFile): def setDictionaries(self):
if pwlFile is not None: self.theDict.setLanguage(self.mainConf.spellLanguage, self.theProject.projDict)
self.pwlFile = pwlFile
self.theDict.setLanguage(self.mainConf.spellLanguage, pwlFile)
return True return True
def setSpellCheck(self, theMode): def setSpellCheck(self, theMode):
+1 -1
View File
@@ -245,7 +245,7 @@ class GuiMain(QMainWindow):
# Update GUI # Update GUI
self._setWindowTitle(self.theProject.projName) self._setWindowTitle(self.theProject.projName)
self.rebuildTree() self.rebuildTree()
self.docEditor.setPwl(path.join(self.theProject.projMeta, nwFiles.PROJ_DICT)) self.docEditor.setDictionaries()
self.docEditor.setSpellCheck(self.theProject.spellCheck) self.docEditor.setSpellCheck(self.theProject.spellCheck)
self.statusBar.setRefTime(self.theProject.projOpened) self.statusBar.setRefTime(self.theProject.projOpened)
self.mainMenu.updateMenu() self.mainMenu.updateMenu()
+3
View File
@@ -48,6 +48,7 @@ class NWProject():
self.projPath = None self.projPath = None
self.projMeta = None self.projMeta = None
self.projCache = None self.projCache = None
self.projDict = None
self.projFile = None self.projFile = None
# Project Meta # Project Meta
@@ -149,6 +150,7 @@ class NWProject():
self.projPath = None self.projPath = None
self.projMeta = None self.projMeta = None
self.projCache = None self.projCache = None
self.projDict = None
self.projFile = nwFiles.PROJ_FILE self.projFile = nwFiles.PROJ_FILE
self.projName = "" self.projName = ""
self.bookTitle = "" self.bookTitle = ""
@@ -186,6 +188,7 @@ class NWProject():
self.projMeta = path.join(self.projPath,"meta") self.projMeta = path.join(self.projPath,"meta")
self.projCache = path.join(self.projPath,"cache") 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.projMeta): return
if not self._checkFolder(self.projCache): return if not self._checkFolder(self.projCache): return