From b19c106b45003cd3cbff7bf2ea9cf950f3f7dae7 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 19 Jun 2020 22:46:22 +0200 Subject: [PATCH 1/2] CHange the order of preference for the view document action --- nw/guimain.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/nw/guimain.py b/nw/guimain.py index a82d5a99..cd479c9e 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -518,20 +518,30 @@ class GuiMain(QMainWindow): """Load a document for viewing in the view panel. """ if tHandle is None: - tHandle = self.treeView.getSelectedHandle() - if tHandle is None: - logger.debug("No document selected, trying editor document") - tHandle = self.docEditor.theHandle - if tHandle is None: - logger.debug("No document selected, trying last viewed") - tHandle = self.theProject.lastViewed - if tHandle is None: - logger.debug("No document selected, giving up") - return False + logger.debug("Viewing document, but no handle provided") + + if self.docEditor.hasFocus(): + logger.verbose("Trying editor document") + tHandle = self.docEditor.theHandle + + if tHandle is not None: + self.saveDocument() + else: + logger.verbose("Trying selected document") + tHandle = self.treeView.getSelectedHandle() + + if tHandle is None: + logger.verbose("Trying last viewed document") + tHandle = self.theProject.lastViewed + + if tHandle is None: + logger.verbose("No document to view, giving up") + return False # Make sure main tab is in Editor view self.tabWidget.setCurrentWidget(self.splitDocs) + logger.debug("Viewing document with handle %s" % tHandle) if self.docViewer.loadText(tHandle): if not self.splitView.isVisible(): bPos = self.splitMain.sizes() From 747ff63a9247db4bb4c2c6d497f104f8da83de0c Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Fri, 19 Jun 2020 23:01:22 +0200 Subject: [PATCH 2/2] Also save first if pressing the relaod button from the doc viewer header bar --- nw/gui/docviewer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index b280aa01..93887fdf 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -529,6 +529,8 @@ class GuiDocViewHeader(QWidget): def _refreshDocument(self): """Reload the content of the document. """ + if self.docViewer.theHandle == self.theParent.docEditor.theHandle: + self.theParent.saveDocument() self.docViewer.reloadText() return