Put loading functions in a separate Method and called it, when Add Dictionaries Window is closed.

This commit is contained in:
2025-10-28 13:50:20 +01:00
parent 2f7b04534d
commit e3168163c2
2 changed files with 20 additions and 8 deletions
+12 -7
View File
@@ -944,13 +944,7 @@ class GuiMainMenu(QMenuBar):
self.mainGui.addAction(self.aSpellCheck)
self.mSelectLanguage = qtAddMenu(self.toolsMenu, self.tr("Spell Check Language"))
languages = SHARED.spelling.listDictionaries()
languages.insert(0, ("None", self.tr("Default")))
for tag, language in languages:
aSpell = QAction(self.mSelectLanguage)
aSpell.setText(language)
aSpell.triggered.connect(qtLambda(self._changeSpelling, tag))
self.mSelectLanguage.addAction(aSpell)
self.updateSpellCheckLanguages()
# Tools > Re-Run Spell Check
self.aReRunSpell = qtAddAction(self.toolsMenu, self.tr("Re-Run Spell Check"))
@@ -999,6 +993,17 @@ class GuiMainMenu(QMenuBar):
self.aPreferences.triggered.connect(self.mainGui.showPreferencesDialog)
self.mainGui.addAction(self.aPreferences)
def updateSpellCheckLanguages(self) -> None:
"""Update the list of available spell check languages."""
self.mSelectLanguage.clear()
languages = SHARED.spelling.listDictionaries()
languages.insert(0, ("None", self.tr("Default")))
for tag, language in languages:
aSpell = QAction(self.mSelectLanguage)
aSpell.setText(language)
aSpell.triggered.connect(qtLambda(self._changeSpelling, tag))
self.mSelectLanguage.addAction(aSpell)
def _buildHelpMenu(self) -> None:
"""Assemble the Help menu."""
# Help
+8 -1
View File
@@ -824,12 +824,19 @@ class GuiMain(QMainWindow):
@pyqtSlot()
def showDictionariesDialog(self) -> None:
"""Show the download dictionaries dialog."""
"""Show the download dictionaries dialog and update language list when closed."""
dialog = GuiDictionaries(self)
dialog.activateDialog()
if not dialog.initDialog():
dialog.close()
SHARED.error(self.tr("Could not initialise the dialog."))
return
# Update the spell check languages menu when the dialog is closed
def onDialogFinished():
self.mainMenu.updateSpellCheckLanguages()
dialog.finished.connect(onDialogFinished)
##
# Main Window Actions