Fixed a recursion issue, and added more comments

This commit is contained in:
Veronica K. B. Olsen
2019-11-15 22:36:44 +01:00
parent ec0f4880fa
commit ed0c4c6e49
+10 -8
View File
@@ -68,7 +68,6 @@ class GuiMainMenu(QMenuBar):
def updateMenu(self):
self.updateRecentProjects()
self.updateSpellCheck()
return
def updateRecentProjects(self):
@@ -92,15 +91,13 @@ class GuiMainMenu(QMenuBar):
return
def setSpellCheck(self, theMode):
"""Set the spell check check box to theMode. This is controlled
by the document editor class, which holds the master spell check
flag.
"""
self.aSpellCheck.setChecked(theMode)
return
def updateSpellCheck(self):
if self.theParent.hasProject:
self.aSpellCheck.setChecked(self.theProject.spellCheck)
logger.verbose("Spell check is set to %s" % str(self.theProject.spellCheck))
return
##
# Menu Action
##
@@ -110,6 +107,10 @@ class GuiMainMenu(QMenuBar):
return
def _toggleSpellCheck(self):
"""Toggle spell checking. The active status of the spell check
flag is handled by the document editor class, so we make no
decision, just pass a None to the function and let it decide.
"""
self.theParent.docEditor.setSpellCheck(None)
return True
@@ -608,7 +609,8 @@ class GuiMainMenu(QMenuBar):
self.aSpellCheck.setStatusTip("Toggle check spelling")
self.aSpellCheck.setCheckable(True)
self.aSpellCheck.setChecked(self.theProject.spellCheck)
self.aSpellCheck.toggled.connect(self._toggleSpellCheck)
# Here we must used triggered, not toggled, to avoid recursion
self.aSpellCheck.triggered.connect(self._toggleSpellCheck)
self.aSpellCheck.setShortcut("Ctrl+F7")
self.toolsMenu.addAction(self.aSpellCheck)