diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index 3d0446e1..ab6c5ada 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -314,17 +314,41 @@ class GuiDocEditor(QTextEdit): ## def setDictionaries(self): + """Set the spell checker dictionary language, and update the + status bar to show the one actually loaded by the spell checker + class. + """ self.theDict.setLanguage(self.mainConf.spellLanguage, self.theProject.projDict) self.theParent.statusBar.setLanguage(self.theDict.spellLanguage) return True def setSpellCheck(self, theMode): + """This is the master spell check setting function, and this one + should call all other setSpellCheck functions in other classes. + If the spell check mode is not defined, then toggle the current + status saved in the class. + """ + + if theMode is None: + theMode = not self.spellCheck + + if self.theDict.spellLanguage is None: + theMode = False + self.spellCheck = theMode + self.theParent.mainMenu.setSpellCheck(theMode) + self.theProject.setSpellCheck(theMode) self.hLight.setSpellCheck(theMode) self.hLight.rehighlight() + + logger.verbose("Spell check is set to %s" % str(theMode)) + return True def updateSpellCheck(self): + """Rerun the highlighter to update spell checking status of the + currently loaded text. + """ if self.spellCheck: self.hLight.rehighlight() return True diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 4205c8ad..23feab0b 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -91,6 +91,10 @@ class GuiMainMenu(QMenuBar): return + def setSpellCheck(self, theMode): + self.aSpellCheck.setChecked(theMode) + return + def updateSpellCheck(self): if self.theParent.hasProject: self.aSpellCheck.setChecked(self.theProject.spellCheck) @@ -106,12 +110,7 @@ class GuiMainMenu(QMenuBar): return def _toggleSpellCheck(self): - if self.theParent.hasProject: - self.theProject.setSpellCheck(self.aSpellCheck.isChecked()) - self.theParent.docEditor.setSpellCheck(self.aSpellCheck.isChecked()) - logger.verbose("Spell check is set to %s" % str(self.theProject.spellCheck)) - else: - self.aSpellCheck.setChecked(False) + self.theParent.docEditor.setSpellCheck(None) return True def _toggleViewComments(self):