Shuffle around private slots in main GUI
This commit is contained in:
@@ -227,7 +227,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.mainMenu.requestDocInsert.connect(self._passDocumentInsert)
|
self.mainMenu.requestDocInsert.connect(self._passDocumentInsert)
|
||||||
self.mainMenu.requestDocInsertText.connect(self._passDocumentInsert)
|
self.mainMenu.requestDocInsertText.connect(self._passDocumentInsert)
|
||||||
self.mainMenu.requestDocKeyWordInsert.connect(self.docEditor.insertKeyWord)
|
self.mainMenu.requestDocKeyWordInsert.connect(self.docEditor.insertKeyWord)
|
||||||
self.mainMenu.requestFocusChange.connect(self.switchFocus)
|
self.mainMenu.requestFocusChange.connect(self._switchFocus)
|
||||||
self.mainMenu.requestViewChange.connect(self._changeView)
|
self.mainMenu.requestViewChange.connect(self._changeView)
|
||||||
|
|
||||||
self.sideBar.requestViewChange.connect(self._changeView)
|
self.sideBar.requestViewChange.connect(self._changeView)
|
||||||
@@ -944,14 +944,18 @@ class GuiMain(QMainWindow):
|
|||||||
SHARED.setFocusMode(not SHARED.focusMode)
|
SHARED.setFocusMode(not SHARED.focusMode)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Private Slots
|
||||||
|
##
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def _focusModeChanged(self, focusMode: bool) -> None:
|
def _focusModeChanged(self, focusMode: bool) -> None:
|
||||||
"""Handle change of focus mode. The Main GUI Focus Mode hides tree,
|
"""Handle change of focus mode. The Main GUI Focus Mode hides
|
||||||
view, statusbar and menu.
|
tree, view, statusbar and menu.
|
||||||
"""
|
"""
|
||||||
if focusMode:
|
if focusMode:
|
||||||
logger.debug("Activating Focus Mode")
|
logger.debug("Activating Focus Mode")
|
||||||
self.switchFocus(nwWidget.EDITOR)
|
self._switchFocus(nwWidget.EDITOR)
|
||||||
else:
|
else:
|
||||||
logger.debug("Deactivating Focus Mode")
|
logger.debug("Deactivating Focus Mode")
|
||||||
|
|
||||||
@@ -975,7 +979,7 @@ class GuiMain(QMainWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot(nwWidget)
|
@pyqtSlot(nwWidget)
|
||||||
def switchFocus(self, paneNo: nwWidget) -> None:
|
def _switchFocus(self, paneNo: nwWidget) -> None:
|
||||||
"""Switch focus between main GUI views."""
|
"""Switch focus between main GUI views."""
|
||||||
if paneNo == nwWidget.TREE:
|
if paneNo == nwWidget.TREE:
|
||||||
if self.projStack.currentWidget() is self.projView:
|
if self.projStack.currentWidget() is self.projView:
|
||||||
@@ -1004,10 +1008,6 @@ class GuiMain(QMainWindow):
|
|||||||
self.outlineView.setTreeFocus()
|
self.outlineView.setTreeFocus()
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
|
||||||
# Private Slots
|
|
||||||
##
|
|
||||||
|
|
||||||
@pyqtSlot(bool, bool, bool, bool)
|
@pyqtSlot(bool, bool, bool, bool)
|
||||||
def _processConfigChanges(self, restart: bool, tree: bool, theme: bool, syntax: bool) -> None:
|
def _processConfigChanges(self, restart: bool, tree: bool, theme: bool, syntax: bool) -> None:
|
||||||
"""Refresh GUI based on flags from the Preferences dialog."""
|
"""Refresh GUI based on flags from the Preferences dialog."""
|
||||||
|
|||||||
@@ -1678,7 +1678,7 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
completer = docEditor._completer
|
completer = docEditor._completer
|
||||||
|
|
||||||
# Create Scene
|
# Create Scene
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI._switchFocus(nwWidget.EDITOR)
|
||||||
for c in "### Scene One":
|
for c in "### Scene One":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
|
|
||||||
# Project Tree has focus
|
# Project Tree has focus
|
||||||
nwGUI._changeView(nwView.PROJECT)
|
nwGUI._changeView(nwView.PROJECT)
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.projStack.setCurrentIndex(0)
|
nwGUI.projStack.setCurrentIndex(0)
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
|
mp.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
|
||||||
@@ -137,7 +137,7 @@ def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
|
|
||||||
# Project Outline has focus
|
# Project Outline has focus
|
||||||
nwGUI._changeView(nwView.OUTLINE)
|
nwGUI._changeView(nwView.OUTLINE)
|
||||||
nwGUI.switchFocus(nwWidget.OUTLINE)
|
nwGUI._switchFocus(nwWidget.OUTLINE)
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiOutlineView, "treeHasFocus", lambda *a: True)
|
mp.setattr(GuiOutlineView, "treeHasFocus", lambda *a: True)
|
||||||
assert nwGUI.docEditor.docHandle is None
|
assert nwGUI.docEditor.docHandle is None
|
||||||
@@ -230,7 +230,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
CONFIG.autoScroll = True
|
CONFIG.autoScroll = True
|
||||||
|
|
||||||
# Add a Character File
|
# Add a Character File
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.projView.projTree.clearSelection()
|
nwGUI.projView.projTree.clearSelection()
|
||||||
nwGUI.projView.projTree._getTreeItem(C.hCharRoot).setSelected(True)
|
nwGUI.projView.projTree._getTreeItem(C.hCharRoot).setSelected(True)
|
||||||
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
||||||
@@ -250,7 +250,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
docEditor._qDocument.syntaxHighlighter.initHighlighter()
|
docEditor._qDocument.syntaxHighlighter.initHighlighter()
|
||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI._switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Jane Doe":
|
for c in "# Jane Doe":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
@@ -265,14 +265,14 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Add a Plot File
|
# Add a Plot File
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.projView.projTree.clearSelection()
|
nwGUI.projView.projTree.clearSelection()
|
||||||
nwGUI.projView.projTree._getTreeItem(C.hPlotRoot).setSelected(True)
|
nwGUI.projView.projTree._getTreeItem(C.hPlotRoot).setSelected(True)
|
||||||
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
||||||
nwGUI.openSelectedItem()
|
nwGUI.openSelectedItem()
|
||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI._switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Main Plot":
|
for c in "# Main Plot":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
@@ -287,7 +287,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Add a World File
|
# Add a World File
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.projView.projTree.clearSelection()
|
nwGUI.projView.projTree.clearSelection()
|
||||||
nwGUI.projView.projTree._getTreeItem(C.hWorldRoot).setSelected(True)
|
nwGUI.projView.projTree._getTreeItem(C.hWorldRoot).setSelected(True)
|
||||||
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE, None, isNote=True)
|
||||||
@@ -299,7 +299,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
docEditor.replaceText("")
|
docEditor.replaceText("")
|
||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI._switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Main Location":
|
for c in "# Main Location":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
@@ -318,7 +318,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
nwGUI._autoSaveProject()
|
nwGUI._autoSaveProject()
|
||||||
|
|
||||||
# Select the 'New Scene' file
|
# Select the 'New Scene' file
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.projView.projTree.clearSelection()
|
nwGUI.projView.projTree.clearSelection()
|
||||||
nwGUI.projView.projTree._getTreeItem(C.hNovelRoot).setExpanded(True)
|
nwGUI.projView.projTree._getTreeItem(C.hNovelRoot).setExpanded(True)
|
||||||
nwGUI.projView.projTree._getTreeItem(C.hChapterDir).setExpanded(True)
|
nwGUI.projView.projTree._getTreeItem(C.hChapterDir).setExpanded(True)
|
||||||
@@ -326,7 +326,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
nwGUI.openSelectedItem()
|
nwGUI.openSelectedItem()
|
||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.switchFocus(nwWidget.EDITOR)
|
nwGUI._switchFocus(nwWidget.EDITOR)
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
||||||
for c in "# Novel":
|
for c in "# Novel":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
@@ -535,7 +535,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
nwGUI.rebuildIndex()
|
nwGUI.rebuildIndex()
|
||||||
|
|
||||||
# Open and view the edited document
|
# Open and view the edited document
|
||||||
nwGUI.switchFocus(nwWidget.VIEWER)
|
nwGUI._switchFocus(nwWidget.VIEWER)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc)
|
assert nwGUI.openDocument(C.hSceneDoc)
|
||||||
assert nwGUI.viewDocument(C.hSceneDoc)
|
assert nwGUI.viewDocument(C.hSceneDoc)
|
||||||
assert nwGUI.saveProject()
|
assert nwGUI.saveProject()
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
|
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
|
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.projView.projTree.clearSelection()
|
nwGUI.projView.projTree.clearSelection()
|
||||||
nwGUI.projView.projTree._getTreeItem(C.hCharRoot).setSelected(True)
|
nwGUI.projView.projTree._getTreeItem(C.hCharRoot).setSelected(True)
|
||||||
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE)
|
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE)
|
||||||
|
|||||||
@@ -1111,7 +1111,7 @@ def testGuiProjTree_ContextMenu(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
# Create a project
|
# Create a project
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
nwGUI.openProject(projPath)
|
nwGUI.openProject(projPath)
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
|
|
||||||
# Handles for new objects
|
# Handles for new objects
|
||||||
hCharNote = "0000000000011"
|
hCharNote = "0000000000011"
|
||||||
@@ -1408,7 +1408,7 @@ def testGuiProjTree_Templates(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
# Create a project
|
# Create a project
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
nwGUI.openProject(projPath)
|
nwGUI.openProject(projPath)
|
||||||
nwGUI.switchFocus(nwWidget.TREE)
|
nwGUI._switchFocus(nwWidget.TREE)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
|
|
||||||
project = SHARED.project
|
project = SHARED.project
|
||||||
|
|||||||
Reference in New Issue
Block a user