From c485851df3534b63faede2ef3fce0a9c751ac706 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 26 May 2019 15:55:10 +0200 Subject: [PATCH] Added closing of document feature --- nw/gui/mainmenu.py | 2 +- nw/gui/winmain.py | 13 ++++++++++--- sample/sampleNovel/data_6/36b6aa9b697b_main.nwd | 2 +- sample/sampleNovel/meta/sessionInfo.log | 5 +++++ sample/sampleNovel/nwProject.nwx | 12 ++++++------ 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 04233cca..981933ee 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -257,7 +257,7 @@ class GuiMainMenu(QMenuBar): menuItem = QAction(QIcon.fromTheme("document-revert"), "Close Document", self) menuItem.setStatusTip("Close Current Document") menuItem.setShortcut("Ctrl+W") - menuItem.triggered.connect(self.theParent.closeDocument) + menuItem.triggered.connect(self.theParent.closeDocEditor) self.docuMenu.addAction(menuItem) # Document > Separator diff --git a/nw/gui/winmain.py b/nw/gui/winmain.py index 585b9853..07ea1b84 100644 --- a/nw/gui/winmain.py +++ b/nw/gui/winmain.py @@ -258,8 +258,11 @@ class GuiMain(QMainWindow): if not self.closeProject(): return False - # Do the stuff - self.theProject.openProject(projFile) + # Try to open the project + if not self.theProject.openProject(projFile): + return False + + # Update GUI self._setWindowTitle(self.theProject.projName) self.rebuildTree() self.docEditor.setPwl(path.join(self.theProject.projMeta, nwFiles.PROJ_DICT)) @@ -301,7 +304,6 @@ class GuiMain(QMainWindow): self.saveDocument() self.theDocument.clearDocument() self.docEditor.clearEditor() - self.theProject.setLastEdited(None) return True def openDocument(self, tHandle): @@ -478,6 +480,11 @@ class GuiMain(QMainWindow): self.docViewer.setFocus() return + def closeDocEditor(self): + self.closeDocument() + self.theProject.setLastEdited(None) + return + def closeDocViewer(self): self.docViewer.clearViewer() self.theProject.setLastViewed(None) diff --git a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd index 99650f20..eb71a80b 100644 --- a/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd +++ b/sample/sampleNovel/data_6/36b6aa9b697b_main.nwd @@ -13,7 +13,7 @@ Some text here would look good as well, and maybe some "dialogue"? So, this is some __text__ that we’ve been adding to this document. It is utterly meaningless text, _but_ since this is just dummy text, that doesn’t really matter. The text is perfectly happy to live in this document regardless. -This paragraph is also meaningless. At least a bit. It’s also very short. But we could make it less meaningless if we wanted to … but we won’t. +This paragraph is also meaningless. At least a bit. It’s also very short. But we could make it less meaningless if we wanted to … but we won’t, will we. This one is a bit longer. “It also has some dialogue in it” she said, before she moved on to check if the spellchecker worked. It did. “Cool,” she concluded. diff --git a/sample/sampleNovel/meta/sessionInfo.log b/sample/sampleNovel/meta/sessionInfo.log index 035ac8c3..79d3266e 100644 --- a/sample/sampleNovel/meta/sessionInfo.log +++ b/sample/sampleNovel/meta/sessionInfo.log @@ -8,3 +8,8 @@ Start: 2019-05-26 14:50:18 End: 2019-05-26 14:50:21 Words: 0 Start: 2019-05-26 14:50:29 End: 2019-05-26 14:50:47 Words: 3 Start: 2019-05-26 15:10:52 End: 2019-05-26 15:11:09 Words: 0 Start: 2019-05-26 15:28:56 End: 2019-05-26 15:29:08 Words: 0 +Start: 2019-05-26 15:37:34 End: 2019-05-26 15:37:43 Words: -538 +Start: 2019-05-26 15:37:47 End: 2019-05-26 15:38:07 Words: 538 +Start: 2019-05-26 15:38:11 End: 2019-05-26 15:43:07 Words: 2 +Start: 2019-05-26 15:49:18 End: 2019-05-26 15:49:47 Words: 0 +Start: 2019-05-26 15:52:39 End: 2019-05-26 15:52:56 Words: 0 diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 5b583ada..448da65a 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -8,9 +8,9 @@ True - None + 636b6aa9b697b None - 538 + 540 New Notes @@ -73,10 +73,10 @@ Notes False SCENE - 647 - 119 + 656 + 121 5 - 565 + 573 New File