Clean up signals and passing variables

This commit is contained in:
Veronica Berglyd Olsen
2024-03-17 15:02:42 +01:00
parent add499af89
commit b156eee209
7 changed files with 132 additions and 127 deletions
+22 -24
View File
@@ -259,7 +259,7 @@ class GuiDocEditor(QPlainTextEdit):
self._doReplace = False
self.setDocumentChanged(False)
self.docHeader.setTitleFromHandle(self._docHandle)
self.docHeader.clearHeader()
self.docFooter.setHandle(self._docHandle)
self.docToolBar.setVisible(False)
@@ -363,7 +363,7 @@ class GuiDocEditor(QPlainTextEdit):
# which makes it read only.
if self._docHandle:
self._qDocument.syntaxHighlighter.rehighlight()
self.docHeader.setTitleFromHandle(self._docHandle)
self.docHeader.setHandle(self._docHandle)
else:
self.clearEditor()
@@ -408,8 +408,8 @@ class GuiDocEditor(QPlainTextEdit):
elif isinstance(tLine, int):
self.setCursorLine(tLine)
self.docHeader.setTitleFromHandle(self._docHandle)
self.docFooter.setHandle(self._docHandle)
self.docHeader.setHandle(tHandle)
self.docFooter.setHandle(tHandle)
# This is a hack to fix invisible cursor on an empty document
if self._qDocument.characterCount() <= 1:
@@ -991,8 +991,8 @@ class GuiDocEditor(QPlainTextEdit):
"""Called when an item label is changed to check if the document
title bar needs updating,
"""
if tHandle == self._docHandle:
self.docHeader.setTitleFromHandle(self._docHandle)
if tHandle and tHandle == self._docHandle:
self.docHeader.setHandle(tHandle)
self.docFooter.updateInfo()
self.updateDocMargins()
return
@@ -2909,6 +2909,20 @@ class GuiDocEditHeader(QWidget):
# Methods
##
def clearHeader(self) -> None:
"""Clear the header."""
self._docHandle = None
self._docOutline = {}
self.itemTitle.setText("")
self.outlineMenu.clear()
self.tbButton.setVisible(False)
self.searchButton.setVisible(False)
self.outlineButton.setVisible(False)
self.closeButton.setVisible(False)
self.minmaxButton.setVisible(False)
return
def setOutline(self, data: dict[int, str]) -> None:
"""Set the document outline dataset."""
if data != self._docOutline:
@@ -2962,21 +2976,11 @@ class GuiDocEditHeader(QWidget):
return
def setTitleFromHandle(self, tHandle: str | None) -> None:
def setHandle(self, tHandle: str) -> None:
"""Set the document title from the handle, or alternatively, set
the whole document path within the project.
"""
self._docHandle = tHandle
if tHandle is None:
self.itemTitle.setText("")
self.tbButton.setVisible(False)
self.searchButton.setVisible(False)
self.outlineButton.setVisible(False)
self.closeButton.setVisible(False)
self.minmaxButton.setVisible(False)
self.outlineMenu.clear()
self._docOutline = {}
return
if CONFIG.showFullPath:
self.itemTitle.setText(f" {nwUnicode.U_RSAQUO} ".join(reversed(
@@ -3011,14 +3015,8 @@ class GuiDocEditHeader(QWidget):
@pyqtSlot()
def _closeDocument(self) -> None:
"""Trigger the close editor on the main window."""
self.clearHeader()
self.closeDocumentRequest.emit()
self.tbButton.setVisible(False)
self.searchButton.setVisible(False)
self.outlineButton.setVisible(False)
self.closeButton.setVisible(False)
self.minmaxButton.setVisible(False)
self.outlineMenu.clear()
self._docOutline = {}
return
@pyqtSlot(int)
+41 -46
View File
@@ -29,7 +29,6 @@ from __future__ import annotations
import logging
from enum import Enum
from typing import TYPE_CHECKING
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QPoint, QSize, Qt, QUrl
from PyQt5.QtGui import (
@@ -48,9 +47,6 @@ from novelwriter.constants import nwUnicode
from novelwriter.core.tohtml import ToHtml
from novelwriter.extensions.eventfilters import WheelEventFilter
if TYPE_CHECKING: # pragma: no cover
from novelwriter.guimain import GuiMain
logger = logging.getLogger(__name__)
@@ -58,17 +54,16 @@ class GuiDocViewer(QTextBrowser):
documentLoaded = pyqtSignal(str)
loadDocumentTagRequest = pyqtSignal(str, Enum)
closeDocumentRequest = pyqtSignal()
reloadDocumentRequest = pyqtSignal()
togglePanelVisibility = pyqtSignal()
requestProjectItemSelected = pyqtSignal(str, bool)
def __init__(self, mainGui: GuiMain) -> None:
super().__init__(parent=mainGui)
def __init__(self, parent: QWidget) -> None:
super().__init__(parent=parent)
logger.debug("Create: GuiDocViewer")
# Class Variables
self.mainGui = mainGui
# Internal Variables
self._docHandle = None
@@ -128,7 +123,7 @@ class GuiDocViewer(QTextBrowser):
self.clear()
self.setSearchPaths([""])
self._docHandle = None
self.docHeader.setTitleFromHandle(self._docHandle)
self.docHeader.clearHeader()
return
def updateTheme(self) -> None:
@@ -184,8 +179,7 @@ class GuiDocViewer(QTextBrowser):
self.setTabStopDistance(CONFIG.getTabWidth())
# If we have a document open, we should reload it in case the font changed
if self._docHandle is not None:
self.reloadText()
self.reloadText()
return
@@ -239,7 +233,7 @@ class GuiDocViewer(QTextBrowser):
self._docHandle = tHandle
SHARED.project.data.setLastHandle(tHandle, "viewer")
self.docHeader.setTitleFromHandle(self._docHandle)
self.docHeader.setHandle(tHandle)
self.docHeader.setOutline({
sTitle: hItem.title
for sTitle, hItem in SHARED.project.index.iterItemHeadings(tHandle)
@@ -337,8 +331,8 @@ class GuiDocViewer(QTextBrowser):
@pyqtSlot(str)
def updateDocInfo(self, tHandle: str) -> None:
"""Update the header title bar if needed."""
if tHandle == self._docHandle:
self.docHeader.setTitleFromHandle(self._docHandle)
if tHandle and tHandle == self._docHandle:
self.docHeader.setHandle(tHandle)
self.updateDocMargins()
return
@@ -631,7 +625,6 @@ class GuiDocViewHeader(QWidget):
logger.debug("Create: GuiDocViewHeader")
self.docViewer = docViewer
self.mainGui = docViewer.mainGui
# Internal Variables
self._docHandle = None
@@ -646,18 +639,18 @@ class GuiDocViewHeader(QWidget):
self.setAutoFillBackground(True)
# Title Label
self.docTitle = QLabel()
self.docTitle.setText("")
self.docTitle.setIndent(0)
self.docTitle.setMargin(0)
self.docTitle.setContentsMargins(0, 0, 0, 0)
self.docTitle.setAutoFillBackground(True)
self.docTitle.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop)
self.docTitle.setFixedHeight(fPx)
self.itemTitle = QLabel()
self.itemTitle.setText("")
self.itemTitle.setIndent(0)
self.itemTitle.setMargin(0)
self.itemTitle.setContentsMargins(0, 0, 0, 0)
self.itemTitle.setAutoFillBackground(True)
self.itemTitle.setAlignment(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignTop)
self.itemTitle.setFixedHeight(fPx)
lblFont = self.docTitle.font()
lblFont = self.itemTitle.font()
lblFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
self.docTitle.setFont(lblFont)
self.itemTitle.setFont(lblFont)
# Other Widgets
self.outlineMenu = QMenu(self)
@@ -715,7 +708,7 @@ class GuiDocViewHeader(QWidget):
self.outerBox.addWidget(self.backButton, 0)
self.outerBox.addWidget(self.forwardButton, 0)
self.outerBox.addWidget(self.outlineButton, 0)
self.outerBox.addWidget(self.docTitle, 1)
self.outerBox.addWidget(self.itemTitle, 1)
self.outerBox.addSpacing(fPx + hSp)
self.outerBox.addWidget(self.refreshButton, 0)
self.outerBox.addWidget(self.closeButton, 0)
@@ -739,6 +732,20 @@ class GuiDocViewHeader(QWidget):
# Methods
##
def clearHeader(self) -> None:
"""Clear the header."""
self._docHandle = None
self._docOutline = {}
self.itemTitle.setText("")
self.outlineMenu.clear()
self.backButton.setVisible(False)
self.forwardButton.setVisible(False)
self.outlineButton.setVisible(False)
self.closeButton.setVisible(False)
self.refreshButton.setVisible(False)
return
def setOutline(self, data: dict[int, str]) -> None:
"""Set the document outline dataset."""
if data != self._docOutline:
@@ -785,31 +792,21 @@ class GuiDocViewHeader(QWidget):
palette.setColor(QPalette.ColorRole.WindowText, SHARED.theme.colText)
palette.setColor(QPalette.ColorRole.Text, SHARED.theme.colText)
self.setPalette(palette)
self.docTitle.setPalette(palette)
self.itemTitle.setPalette(palette)
return
def setTitleFromHandle(self, tHandle: str | None) -> None:
def setHandle(self, tHandle: str) -> None:
"""Sets the document title from the handle, or alternatively,
set the whole document path.
"""
self._docHandle = tHandle
if tHandle is None:
self.docTitle.setText("")
self.backButton.setVisible(False)
self.forwardButton.setVisible(False)
self.outlineButton.setVisible(False)
self.closeButton.setVisible(False)
self.refreshButton.setVisible(False)
self.outlineMenu.clear()
self._docOutline = {}
return
if CONFIG.showFullPath:
self.docTitle.setText(f" {nwUnicode.U_RSAQUO} ".join(reversed(
self.itemTitle.setText(f" {nwUnicode.U_RSAQUO} ".join(reversed(
[name for name in SHARED.project.tree.getItemPath(tHandle, asName=True)]
)))
else:
self.docTitle.setText(i.itemName if (i := SHARED.project.tree[tHandle]) else "")
self.itemTitle.setText(i.itemName if (i := SHARED.project.tree[tHandle]) else "")
self.backButton.setVisible(True)
self.forwardButton.setVisible(True)
@@ -832,15 +829,14 @@ class GuiDocViewHeader(QWidget):
@pyqtSlot()
def _closeDocument(self) -> None:
"""Trigger the close editor/viewer on the main window."""
self.mainGui.closeDocViewer()
self.clearHeader()
self.docViewer.closeDocumentRequest.emit()
return
@pyqtSlot()
def _refreshDocument(self) -> None:
"""Reload the content of the document."""
if self.docViewer.docHandle == self.mainGui.docEditor.docHandle:
self.mainGui.saveDocument()
self.docViewer.reloadText()
self.docViewer.reloadDocumentRequest.emit()
return
##
@@ -871,7 +867,6 @@ class GuiDocViewFooter(QWidget):
logger.debug("Create: GuiDocViewFooter")
self.docViewer = docViewer
self.mainGui = docViewer.mainGui
# Internal Variables
self._docHandle = None
+3 -3
View File
@@ -196,12 +196,12 @@ class GuiMainMenu(QMenuBar):
# Document > Open
self.aOpenDoc = self.docuMenu.addAction(self.tr("Open Document"))
self.aOpenDoc.setShortcut("Ctrl+O")
self.aOpenDoc.triggered.connect(lambda: self.mainGui.openSelectedItem())
self.aOpenDoc.triggered.connect(self.mainGui.openSelectedItem)
# Document > Save
self.aSaveDoc = self.docuMenu.addAction(self.tr("Save Document"))
self.aSaveDoc.setShortcut("Ctrl+S")
self.aSaveDoc.triggered.connect(lambda: self.mainGui.saveDocument())
self.aSaveDoc.triggered.connect(self.mainGui.saveDocument)
# Document > Close
self.aCloseDoc = self.docuMenu.addAction(self.tr("Close Document"))
@@ -219,7 +219,7 @@ class GuiMainMenu(QMenuBar):
# Document > Close Preview
self.aCloseView = self.docuMenu.addAction(self.tr("Close Document View"))
self.aCloseView.setShortcut("Ctrl+Shift+R")
self.aCloseView.triggered.connect(lambda: self.mainGui.closeDocViewer())
self.aCloseView.triggered.connect(self.mainGui.closeDocViewer)
# Document > Separator
self.docuMenu.addSeparator()
+49 -36
View File
@@ -278,6 +278,8 @@ class GuiMain(QMainWindow):
self.docViewer.documentLoaded.connect(self.docViewerPanel.updateHandle)
self.docViewer.loadDocumentTagRequest.connect(self._followTag)
self.docViewer.closeDocumentRequest.connect(self.closeDocViewer)
self.docViewer.reloadDocumentRequest.connect(self._reloadViewer)
self.docViewer.togglePanelVisibility.connect(self._toggleViewerPanelVisibility)
self.docViewer.requestProjectItemSelected.connect(self.projView.setSelectedHandle)
@@ -401,7 +403,7 @@ class GuiMain(QMainWindow):
if saveOK:
self.closeDocument()
self.docViewer.clearNavHistory()
self.closeDocViewer(byUser=False)
self.closeViewerPanel(byUser=False)
self.docViewerPanel.closeProjectTasks()
self.outlineView.closeProjectTasks()
@@ -604,13 +606,12 @@ class GuiMain(QMainWindow):
return False
def saveDocument(self) -> bool:
@pyqtSlot()
def saveDocument(self) -> None:
"""Save the current documents."""
if not SHARED.hasProject:
logger.error("No project open")
return False
self.docEditor.saveText()
return True
if SHARED.hasProject:
self.docEditor.saveText()
return
def viewDocument(self, tHandle: str | None = None, sTitle: str | None = None) -> bool:
"""Load a document for viewing in the view panel."""
@@ -640,7 +641,8 @@ class GuiMain(QMainWindow):
self._changeView(nwView.EDITOR)
logger.debug("Viewing document with handle '%s'", tHandle)
if self.docViewer.loadText(tHandle):
updateHistory = tHandle != self.docViewer.docHandle
if self.docViewer.loadText(tHandle, updateHistory=updateHistory):
if not self.splitView.isVisible():
cursorVisible = self.docEditor.cursorIsVisible()
bPos = self.splitMain.sizes()
@@ -713,37 +715,32 @@ class GuiMain(QMainWindow):
# Tree Item Actions
##
def openSelectedItem(self) -> bool:
@pyqtSlot()
def openSelectedItem(self) -> None:
"""Open the selected item from the tree that is currently
active. It is not checked that the item is actually a document.
That should be handled by the openDocument function.
"""
if not SHARED.hasProject:
logger.error("No project open")
return False
tHandle = None
sTitle = None
tLine = None
if self.projView.treeHasFocus():
tHandle = self.projView.getSelectedHandle()
elif self.novelView.treeHasFocus():
tHandle, sTitle = self.novelView.getSelectedHandle()
elif self.outlineView.treeHasFocus():
tHandle, sTitle = self.outlineView.getSelectedHandle()
else:
logger.warning("No item selected")
return False
if tHandle is not None and sTitle is not None:
hItem = SHARED.project.index.getItemHeading(tHandle, sTitle)
if hItem is not None:
tLine = hItem.line
if tHandle is not None:
self.openDocument(tHandle, tLine=tLine, changeFocus=False, doScroll=False)
return True
if SHARED.hasProject:
tHandle = None
sTitle = None
tLine = None
if self.projView.treeHasFocus():
tHandle = self.projView.getSelectedHandle()
elif self.novelView.treeHasFocus():
tHandle, sTitle = self.novelView.getSelectedHandle()
elif self.outlineView.treeHasFocus():
tHandle, sTitle = self.outlineView.getSelectedHandle()
else:
logger.warning("No item selected")
return False
if tHandle is not None and sTitle is not None:
hItem = SHARED.project.index.getItemHeading(tHandle, sTitle)
if hItem is not None:
tLine = hItem.line
if tHandle is not None:
self.openDocument(tHandle, tLine=tLine, changeFocus=False, doScroll=False)
return
def editItemLabel(self, tHandle: str | None = None) -> bool:
"""Open the edit item dialog."""
@@ -943,7 +940,7 @@ class GuiMain(QMainWindow):
return True
def closeDocViewer(self, byUser: bool = True) -> bool:
def closeViewerPanel(self, byUser: bool = True) -> bool:
"""Close the document view panel."""
self.docViewer.clearViewer()
if byUser:
@@ -991,6 +988,13 @@ class GuiMain(QMainWindow):
SHARED.project.data.setLastHandle(None, "editor")
return
@pyqtSlot()
def closeDocViewer(self) -> None:
"""Close the document viewer."""
self.closeViewerPanel()
SHARED.project.data.setLastHandle(None, "viewer")
return
@pyqtSlot()
def toggleFocusMode(self) -> None:
"""Handle toggle focus mode. The Main GUI Focus Mode hides tree,
@@ -1154,6 +1158,15 @@ class GuiMain(QMainWindow):
self.viewDocument(tHandle=tHandle, sTitle=sTitle)
return
@pyqtSlot()
def _reloadViewer(self) -> None:
"""Reload the document in the viewer."""
if self.docEditor.docChanged and self.docEditor.docHandle == self.docViewer.docHandle:
# If the two panels have the same document, save any changes in the editor
self.saveDocument()
self.docViewer.reloadText()
return
@pyqtSlot(nwView)
def _changeView(self, view: nwView) -> None:
"""Handle the requested change of view from the GuiViewBar."""
+6 -6
View File
@@ -47,7 +47,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert nwGUI.openDocument(C.hSceneDoc)
nwGUI.docEditor.setPlainText("### Lorem Ipsum\n\n%s" % ipsumText[0])
assert nwGUI.saveDocument()
nwGUI.saveDocument()
# Check Defaults
qDoc = nwGUI.docEditor.document()
@@ -122,7 +122,7 @@ def testGuiEditor_LoadText(qtbot, nwGUI, projPath, ipsumText, mockRnd):
longText = "### Lorem Ipsum\n\n%s" % "\n\n".join(ipsumText*20)
nwGUI.docEditor.replaceText(longText)
assert nwGUI.saveDocument() is True
nwGUI.saveDocument()
assert nwGUI.closeDocument() is True
# Invalid handle
@@ -138,7 +138,7 @@ def testGuiEditor_LoadText(qtbot, nwGUI, projPath, ipsumText, mockRnd):
# Load empty document
nwGUI.docEditor.replaceText("")
assert nwGUI.saveDocument() is True
nwGUI.saveDocument()
assert nwGUI.docEditor.loadText(C.hSceneDoc) is True
assert nwGUI.docEditor.toPlainText() == ""
@@ -1484,7 +1484,7 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
cHandle = SHARED.project.newFile("Jane Doe", C.hCharRoot)
assert nwGUI.openDocument(cHandle) is True
nwGUI.docEditor.replaceText(text)
assert nwGUI.saveDocument() is True
nwGUI.saveDocument()
assert nwGUI.projView.projTree.revealNewTreeItem(cHandle)
nwGUI.docEditor.updateTagHighLighting()
@@ -1514,7 +1514,7 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
assert nwGUI.docViewer._docHandle is None
assert nwGUI.docEditor._processTag(follow=True) is nwTrinary.POSITIVE
assert nwGUI.docViewer._docHandle == cHandle
assert nwGUI.closeDocViewer() is True
assert nwGUI.closeViewerPanel() is True
assert nwGUI.docViewer._docHandle is None
# On Unknown Tag, Create It
@@ -1553,7 +1553,7 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
cHandle = SHARED.project.newFile("People", C.hCharRoot)
assert nwGUI.openDocument(cHandle) is True
nwGUI.docEditor.replaceText(text)
assert nwGUI.saveDocument() is True
nwGUI.saveDocument()
assert nwGUI.projView.projTree.revealNewTreeItem(cHandle)
docEditor = nwGUI.docEditor
+2 -2
View File
@@ -185,12 +185,12 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
nwItem.setName("Test Title") # type: ignore
assert nwItem.itemName == "Test Title" # type: ignore
docViewer.updateDocInfo("4c4f28287af27")
assert docViewer.docHeader.docTitle.text() == "Characters \u203a Test Title"
assert docViewer.docHeader.itemTitle.text() == "Characters \u203a Test Title"
# Title without full path
CONFIG.showFullPath = False
docViewer.updateDocInfo("4c4f28287af27")
assert docViewer.docHeader.docTitle.text() == "Test Title"
assert docViewer.docHeader.itemTitle.text() == "Test Title"
CONFIG.showFullPath = True
# Document footer show/hide synopsis
+9 -10
View File
@@ -52,10 +52,8 @@ def testGuiMain_ProjectBlocker(nwGUI):
assert nwGUI.closeDocument() is False
assert nwGUI.openDocument(None) is False
assert nwGUI.openNextDocument(None) is False
assert nwGUI.saveDocument() is False
assert nwGUI.viewDocument(None) is False
assert nwGUI.importDocument() is False
assert nwGUI.openSelectedItem() is False
assert nwGUI.editItemLabel() is False
assert nwGUI.rebuildIndex() is False
@@ -109,7 +107,8 @@ def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
buildTestProject(nwGUI, projPath)
sHandle = "000000000000f"
assert nwGUI.openSelectedItem() is False
nwGUI.openSelectedItem()
assert nwGUI.docEditor.docHandle is None
# Project Tree has focus
nwGUI._changeView(nwView.PROJECT)
@@ -238,7 +237,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
nwGUI.projView.projTree.clearSelection()
nwGUI.projView.projTree._getTreeItem(C.hCharRoot).setSelected(True)
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
assert nwGUI.openSelectedItem()
nwGUI.openSelectedItem()
# Text Editor
# ===========
@@ -265,7 +264,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
nwGUI.projView.projTree.clearSelection()
nwGUI.projView.projTree._getTreeItem(C.hPlotRoot).setSelected(True)
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
assert nwGUI.openSelectedItem()
nwGUI.openSelectedItem()
# Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR)
@@ -287,7 +286,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
nwGUI.projView.projTree.clearSelection()
nwGUI.projView.projTree._getTreeItem(C.hWorldRoot).setSelected(True)
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
assert nwGUI.openSelectedItem()
nwGUI.openSelectedItem()
# Add Some Text
docEditor.replaceText("Hello World!")
@@ -319,7 +318,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
nwGUI.projView.projTree._getTreeItem(C.hNovelRoot).setExpanded(True)
nwGUI.projView.projTree._getTreeItem(C.hChapterDir).setExpanded(True)
nwGUI.projView.projTree._getTreeItem(C.hSceneDoc).setSelected(True)
assert nwGUI.openSelectedItem()
nwGUI.openSelectedItem()
# Type something into the document
nwGUI.switchFocus(nwWidget.EDITOR)
@@ -524,8 +523,8 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
# Save the document
assert docEditor.docChanged
assert nwGUI.saveDocument()
assert not docEditor.docChanged
nwGUI.saveDocument()
assert docEditor.docChanged is False
nwGUI.rebuildIndex()
# Open and view the edited document
@@ -533,7 +532,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
assert nwGUI.openDocument(C.hSceneDoc)
assert nwGUI.viewDocument(C.hSceneDoc)
assert nwGUI.saveProject()
assert nwGUI.closeDocViewer()
assert nwGUI.closeViewerPanel()
# Check the files
projFile = projPath / "nwProject.nwx"