From 77c6caaceececdc35f8cd2128f2b75049721ac60 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Oct 2019 13:56:21 +0200 Subject: [PATCH 1/3] When closing a project, it should ask for backup even if the project is saved. --- nw/gui/winmain.py | 2 +- nw/project/project.py | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 4bc40daa..f9f8a632 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -225,7 +225,7 @@ class GuiMain(QMainWindow): if self.docEditor.docChanged: self.saveDocument() - if self.theProject.projChanged: + if self.theProject.projAltered: saveOK = self.saveProject() doBackup = False if self.theProject.doBackup and self.mainConf.backupOnClose: diff --git a/nw/project/project.py b/nw/project/project.py index c41d4115..7aea4790 100644 --- a/nw/project/project.py +++ b/nw/project/project.py @@ -34,22 +34,23 @@ class NWProject(): # Internal self.theParent = theParent self.mainConf = self.theParent.mainConf - self.projChanged = None - self.projOpened = None + self.projOpened = None # The time stamp of when the project file was opened + self.projChanged = None # The project has unsaved changes + self.projAltered = None # The project has been altered this session (used to trigger backup) # Debug self.handleSeed = None # Class Settings - self.projTree = None - self.treeOrder = None - self.treeRoots = None - self.trashRoot = None - self.projPath = None - self.projMeta = None - self.projCache = None - self.projDict = None - self.projFile = None + self.projTree = None # Holds all the items of the project + self.treeOrder = None # The order of the tree items on the tree view + self.treeRoots = None # The root items of the tree + self.trashRoot = None # The handle of the trash root folder + self.projPath = None # The full path to where the currently open project is saved + self.projMeta = None # The full path to the project's meta data folder + self.projCache = None # The full path to the project's cache folder + self.projDict = None # The spell check dictionary + self.projFile = None # The file name of the project main xml file # Project Meta self.projName = None @@ -140,8 +141,9 @@ class NWProject(): def clearProject(self): - self.projChanged = None self.projOpened = None + self.projChanged = None + self.projAltered = False # Project Settings self.projTree = {} @@ -267,6 +269,7 @@ class NWProject(): self._scanProjectFolder() self.setProjectChanged(False) self.projOpened = time() + self.projAltered = False return True @@ -458,6 +461,9 @@ class NWProject(): def setProjectChanged(self, bValue): self.projChanged = bValue self.theParent.setProjectStatus(self.projChanged) + if bValue: + # If we've changed the project at all, this should be True + self.projAltered = True return self.projChanged ## From fe12e997357fbee12ef95a3b9955634f37e4e2f4 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Oct 2019 14:23:27 +0200 Subject: [PATCH 2/3] Fixed a bug where unicode characters were not included in the spell check regex --- nw/gui/dochighlight.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py index f4c8e1f2..39efb3b6 100644 --- a/nw/gui/dochighlight.py +++ b/nw/gui/dochighlight.py @@ -185,6 +185,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): # Build a QRegExp for each pattern and for the spell checker self.rules = [(QRegularExpression(a),b) for (a,b) in self.hRules] self.spellRx = QRegularExpression(r"\b[^\s]+\b") + self.spellRx.setPatternOptions(QRegularExpression.UseUnicodePropertiesOption) return True From 79116f8977244ed2f55e832ec9fa566ea7eac27f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Oct 2019 14:28:51 +0200 Subject: [PATCH 3/3] Make sure the open document is saved before applying changes from the config dialog --- nw/gui/configeditor.py | 2 +- nw/gui/winmain.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nw/gui/configeditor.py b/nw/gui/configeditor.py index 5010e500..30f600fb 100644 --- a/nw/gui/configeditor.py +++ b/nw/gui/configeditor.py @@ -259,7 +259,7 @@ class GuiConfigEditGeneral(QWidget): self.mainConf.backupOnClose = backupOnClose self.mainConf.askBeforeBackup = askBeforeBackup - self.mainConf.confChanged = True + self.mainConf.confChanged = True return validEntries, needsRestart diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index f9f8a632..52ea0914 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -502,6 +502,7 @@ class GuiMain(QMainWindow): logger.debug("Applying new preferences") self.initMain() self.theTheme.updateTheme() + self.saveDocument() self.docEditor.initEditor() self.docViewer.initViewer() return True