Let the document editor handle the status of spell checking, and let it set all other classes from there
This commit is contained in:
@@ -314,17 +314,41 @@ class GuiDocEditor(QTextEdit):
|
|||||||
##
|
##
|
||||||
|
|
||||||
def setDictionaries(self):
|
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.theDict.setLanguage(self.mainConf.spellLanguage, self.theProject.projDict)
|
||||||
self.theParent.statusBar.setLanguage(self.theDict.spellLanguage)
|
self.theParent.statusBar.setLanguage(self.theDict.spellLanguage)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setSpellCheck(self, theMode):
|
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.spellCheck = theMode
|
||||||
|
self.theParent.mainMenu.setSpellCheck(theMode)
|
||||||
|
self.theProject.setSpellCheck(theMode)
|
||||||
self.hLight.setSpellCheck(theMode)
|
self.hLight.setSpellCheck(theMode)
|
||||||
self.hLight.rehighlight()
|
self.hLight.rehighlight()
|
||||||
|
|
||||||
|
logger.verbose("Spell check is set to %s" % str(theMode))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def updateSpellCheck(self):
|
def updateSpellCheck(self):
|
||||||
|
"""Rerun the highlighter to update spell checking status of the
|
||||||
|
currently loaded text.
|
||||||
|
"""
|
||||||
if self.spellCheck:
|
if self.spellCheck:
|
||||||
self.hLight.rehighlight()
|
self.hLight.rehighlight()
|
||||||
return True
|
return True
|
||||||
|
|||||||
+5
-6
@@ -91,6 +91,10 @@ class GuiMainMenu(QMenuBar):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def setSpellCheck(self, theMode):
|
||||||
|
self.aSpellCheck.setChecked(theMode)
|
||||||
|
return
|
||||||
|
|
||||||
def updateSpellCheck(self):
|
def updateSpellCheck(self):
|
||||||
if self.theParent.hasProject:
|
if self.theParent.hasProject:
|
||||||
self.aSpellCheck.setChecked(self.theProject.spellCheck)
|
self.aSpellCheck.setChecked(self.theProject.spellCheck)
|
||||||
@@ -106,12 +110,7 @@ class GuiMainMenu(QMenuBar):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _toggleSpellCheck(self):
|
def _toggleSpellCheck(self):
|
||||||
if self.theParent.hasProject:
|
self.theParent.docEditor.setSpellCheck(None)
|
||||||
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)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _toggleViewComments(self):
|
def _toggleViewComments(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user