Make some minor changes for consistency between similar classes
This commit is contained in:
@@ -69,8 +69,8 @@ class GuiNovelView(QWidget):
|
|||||||
self.theProject = mainGui.theProject
|
self.theProject = mainGui.theProject
|
||||||
|
|
||||||
# Build GUI
|
# Build GUI
|
||||||
self.novelTree = GuiNovelTree(self)
|
|
||||||
self.novelBar = GuiNovelToolBar(self)
|
self.novelBar = GuiNovelToolBar(self)
|
||||||
|
self.novelTree = GuiNovelTree(self)
|
||||||
|
|
||||||
# Assemble
|
# Assemble
|
||||||
self.outerBox = QVBoxLayout()
|
self.outerBox = QVBoxLayout()
|
||||||
@@ -93,6 +93,8 @@ class GuiNovelView(QWidget):
|
|||||||
##
|
##
|
||||||
|
|
||||||
def initSettings(self):
|
def initSettings(self):
|
||||||
|
"""Initialise GUI elements that depend on specific settings.
|
||||||
|
"""
|
||||||
self.novelTree.initSettings()
|
self.novelTree.initSettings()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -110,7 +112,7 @@ class GuiNovelView(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def openProjectTasks(self):
|
def openProjectTasks(self):
|
||||||
"""Run opening project tasks.
|
"""Run open project tasks.
|
||||||
"""
|
"""
|
||||||
lastNovel = self.theProject.lastNovel
|
lastNovel = self.theProject.lastNovel
|
||||||
if lastNovel not in self.theProject.tree:
|
if lastNovel not in self.theProject.tree:
|
||||||
@@ -136,8 +138,8 @@ class GuiNovelView(QWidget):
|
|||||||
self.theProject.options.setValue("GuiNovelView", "lastCol", lastColType)
|
self.theProject.options.setValue("GuiNovelView", "lastCol", lastColType)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setFocus(self):
|
def setTreeFocus(self):
|
||||||
"""Forward the set focus call to the tree widget.
|
"""Set the focus to the tree widget.
|
||||||
"""
|
"""
|
||||||
self.novelTree.setFocus()
|
self.novelTree.setFocus()
|
||||||
return
|
return
|
||||||
|
|||||||
+22
-14
@@ -97,9 +97,11 @@ class GuiOutlineView(QWidget):
|
|||||||
# Methods
|
# Methods
|
||||||
##
|
##
|
||||||
|
|
||||||
def initOutline(self):
|
def initSettings(self):
|
||||||
self.outlineTree.initOutline()
|
"""Initialise GUI elements that depend on specific settings.
|
||||||
self.outlineData.initDetails()
|
"""
|
||||||
|
self.outlineTree.initSettings()
|
||||||
|
self.outlineData.initSettings()
|
||||||
return
|
return
|
||||||
|
|
||||||
def refreshTree(self):
|
def refreshTree(self):
|
||||||
@@ -109,11 +111,13 @@ class GuiOutlineView(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def clearProject(self):
|
def clearProject(self):
|
||||||
|
"""Clear project-related GUI content.
|
||||||
|
"""
|
||||||
self.outlineData.clearDetails()
|
self.outlineData.clearDetails()
|
||||||
return
|
return
|
||||||
|
|
||||||
def openProjectTasks(self):
|
def openProjectTasks(self):
|
||||||
"""Run opening project tasks.
|
"""Run open project tasks.
|
||||||
"""
|
"""
|
||||||
lastOutline = self.theProject.lastOutline
|
lastOutline = self.theProject.lastOutline
|
||||||
if not (lastOutline in self.theProject.tree or lastOutline is None):
|
if not (lastOutline in self.theProject.tree or lastOutline is None):
|
||||||
@@ -127,20 +131,24 @@ class GuiOutlineView(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def closeOutline(self):
|
def closeProjectTasks(self):
|
||||||
self.outlineTree.closeOutline()
|
self.outlineTree.closeProjectTasks()
|
||||||
self.outlineData.updateClasses()
|
self.outlineData.updateClasses()
|
||||||
return
|
return
|
||||||
|
|
||||||
def splitSizes(self):
|
def splitSizes(self):
|
||||||
return self.splitOutline.sizes()
|
return self.splitOutline.sizes()
|
||||||
|
|
||||||
def treeHasFocus(self):
|
|
||||||
return self.outlineTree.hasFocus()
|
|
||||||
|
|
||||||
def setTreeFocus(self):
|
def setTreeFocus(self):
|
||||||
|
"""Set the focus to the tree widget.
|
||||||
|
"""
|
||||||
return self.outlineTree.setFocus()
|
return self.outlineTree.setFocus()
|
||||||
|
|
||||||
|
def treeHasFocus(self):
|
||||||
|
"""Check if the outline tree has focus.
|
||||||
|
"""
|
||||||
|
return self.outlineTree.hasFocus()
|
||||||
|
|
||||||
##
|
##
|
||||||
# Public Slots
|
# Public Slots
|
||||||
##
|
##
|
||||||
@@ -407,7 +415,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
self._firstView = True
|
self._firstView = True
|
||||||
self._lastBuild = 0
|
self._lastBuild = 0
|
||||||
|
|
||||||
self.initOutline()
|
self.initSettings()
|
||||||
self.clearContent()
|
self.clearContent()
|
||||||
|
|
||||||
self.hiddenStateChanged.emit()
|
self.hiddenStateChanged.emit()
|
||||||
@@ -428,7 +436,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
# Methods
|
# Methods
|
||||||
##
|
##
|
||||||
|
|
||||||
def initOutline(self):
|
def initSettings(self):
|
||||||
"""Set or update outline settings.
|
"""Set or update outline settings.
|
||||||
"""
|
"""
|
||||||
# Scroll bars
|
# Scroll bars
|
||||||
@@ -491,7 +499,7 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def closeOutline(self):
|
def closeProjectTasks(self):
|
||||||
"""Called before a project is closed.
|
"""Called before a project is closed.
|
||||||
"""
|
"""
|
||||||
self._saveHeaderState()
|
self._saveHeaderState()
|
||||||
@@ -971,13 +979,13 @@ class GuiOutlineDetails(QScrollArea):
|
|||||||
self.setWidgetResizable(True)
|
self.setWidgetResizable(True)
|
||||||
self.setFrameStyle(QFrame.NoFrame)
|
self.setFrameStyle(QFrame.NoFrame)
|
||||||
|
|
||||||
self.initDetails()
|
self.initSettings()
|
||||||
|
|
||||||
logger.debug("GuiOutlineDetails initialisation complete")
|
logger.debug("GuiOutlineDetails initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def initDetails(self):
|
def initSettings(self):
|
||||||
"""Set or update outline settings.
|
"""Set or update outline settings.
|
||||||
"""
|
"""
|
||||||
# Scroll bars
|
# Scroll bars
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ class GuiMain(QMainWindow):
|
|||||||
if saveOK:
|
if saveOK:
|
||||||
self.closeDocument()
|
self.closeDocument()
|
||||||
self.docViewer.clearNavHistory()
|
self.docViewer.clearNavHistory()
|
||||||
self.outlineView.closeOutline()
|
self.outlineView.closeProjectTasks()
|
||||||
self.novelView.closeProjectTasks()
|
self.novelView.closeProjectTasks()
|
||||||
|
|
||||||
self.theProject.closeProject(self.idleTime)
|
self.theProject.closeProject(self.idleTime)
|
||||||
@@ -930,7 +930,7 @@ class GuiMain(QMainWindow):
|
|||||||
self.docViewer.initViewer()
|
self.docViewer.initViewer()
|
||||||
self.projView.initSettings()
|
self.projView.initSettings()
|
||||||
self.novelView.initSettings()
|
self.novelView.initSettings()
|
||||||
self.outlineView.initOutline()
|
self.outlineView.initSettings()
|
||||||
self._updateStatusWordCount()
|
self._updateStatusWordCount()
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -1191,7 +1191,7 @@ class GuiMain(QMainWindow):
|
|||||||
if tabIdx == self.idxProjView:
|
if tabIdx == self.idxProjView:
|
||||||
self.projView.setFocus()
|
self.projView.setFocus()
|
||||||
elif tabIdx == self.idxNovelView:
|
elif tabIdx == self.idxNovelView:
|
||||||
self.novelView.setFocus()
|
self.novelView.setTreeFocus()
|
||||||
elif paneNo == nwWidget.EDITOR:
|
elif paneNo == nwWidget.EDITOR:
|
||||||
self._changeView(nwView.EDITOR)
|
self._changeView(nwView.EDITOR)
|
||||||
self.docEditor.setFocus()
|
self.docEditor.setFocus()
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, fncDir):
|
|||||||
# Toggle scrollbars
|
# Toggle scrollbars
|
||||||
nwGUI.mainConf.hideVScroll = True
|
nwGUI.mainConf.hideVScroll = True
|
||||||
nwGUI.mainConf.hideHScroll = True
|
nwGUI.mainConf.hideHScroll = True
|
||||||
outlineView.initOutline()
|
outlineView.initSettings()
|
||||||
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert outlineData.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert outlineData.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
@@ -62,7 +62,7 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, fncDir):
|
|||||||
|
|
||||||
nwGUI.mainConf.hideVScroll = False
|
nwGUI.mainConf.hideVScroll = False
|
||||||
nwGUI.mainConf.hideHScroll = False
|
nwGUI.mainConf.hideHScroll = False
|
||||||
outlineView.initOutline()
|
outlineView.initSettings()
|
||||||
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert outlineTree.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert outlineTree.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
assert outlineData.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert outlineData.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
|
|||||||
Reference in New Issue
Block a user