From e3168163c24642018b43cccd207a2e04d7b20ea8 Mon Sep 17 00:00:00 2001 From: Christian Zeitner Date: Tue, 28 Oct 2025 13:50:20 +0100 Subject: [PATCH] Put loading functions in a separate Method and called it, when Add Dictionaries Window is closed. --- novelwriter/gui/mainmenu.py | 19 ++++++++++++------- novelwriter/guimain.py | 9 ++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 3509291e..59e1175f 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -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 diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index 20e86ad8..ea01c74e 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -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