Add a method in the shared object to ensure document editor is saved

This commit is contained in:
Veronica Berglyd Olsen
2024-06-11 21:59:58 +02:00
parent a11a013d16
commit 73515c96d8
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -204,6 +204,19 @@ class SharedData(QObject):
self._resetIdleTimer()
return
def ensureEditorSaved(self, tHandle: str | None) -> None:
"""Ensure that the editor content is saved. Optionally, only if
it is a specific handle.
"""
docEditor = self.mainGui.docEditor
if (
self.hasProject and docEditor.docHandle
and (tHandle is None or tHandle == docEditor.docHandle)
):
logger.debug("Saving editor document before action")
docEditor.saveText()
return
def updateSpellCheckLanguage(self, reload: bool = False) -> None:
"""Update the active spell check language from settings."""
from novelwriter import CONFIG