From 46bd7a887139b126ba2f888fc33c4c60a677c2c1 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Wed, 12 Jun 2019 20:33:06 +0200 Subject: [PATCH] Fixed the loading of dictionaries --- nw/gui/doceditor.py | 14 +++++++------- nw/gui/winmain.py | 2 +- nw/project/project.py | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 1100c419..35a66562 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -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): diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 0900cf11..11592a97 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -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() diff --git a/nw/project/project.py b/nw/project/project.py index d4035aa2..8cc6bf9b 100644 --- a/nw/project/project.py +++ b/nw/project/project.py @@ -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