Some cleanup in the doc edit header

This commit is contained in:
Veronica K. B. Olsen
2020-06-11 17:54:43 +02:00
parent 2b878777d4
commit c3e6007f76
+14 -10
View File
@@ -1107,15 +1107,16 @@ class WordCounter(QThread):
class GuiDocEditHeader(QWidget): class GuiDocEditHeader(QWidget):
def __init__(self, theParent): def __init__(self, docEditor):
QWidget.__init__(self, theParent) QWidget.__init__(self, docEditor)
logger.debug("Initialising GuiDocEditHeader ...") logger.debug("Initialising GuiDocEditHeader ...")
self.mainConf = nw.CONFIG self.mainConf = nw.CONFIG
self.theParent = theParent self.docEditor = docEditor
self.theProject = theParent.theProject self.theParent = docEditor.theParent
self.theTheme = theParent.theTheme self.theProject = docEditor.theProject
self.theTheme = docEditor.theTheme
self.theHandle = None self.theHandle = None
# Make a QPalette that matches the Syntax Theme # Make a QPalette that matches the Syntax Theme
@@ -1193,11 +1194,12 @@ class GuiDocEditHeader(QWidget):
"""Sets the document title from the handle, or alternatively, """Sets the document title from the handle, or alternatively,
set the whole document path. set the whole document path.
""" """
self.theTitle.setText("")
self.theHandle = tHandle self.theHandle = tHandle
if tHandle is None: if tHandle is None:
self.theTitle.setText("")
self.closeButton.setVisible(False) self.closeButton.setVisible(False)
self.minmaxButton.setVisible(False) self.minmaxButton.setVisible(False)
return True
if self.mainConf.showFullPath: if self.mainConf.showFullPath:
tTitle = [] tTitle = []
@@ -1226,14 +1228,16 @@ class GuiDocEditHeader(QWidget):
def _closeDocument(self): def _closeDocument(self):
"""Trigger the close editor/viewer on the main window. """Trigger the close editor/viewer on the main window.
""" """
self.theParent.theParent.closeDocEditor() self.theParent.closeDocEditor()
self.closeButton.setVisible(False)
self.minmaxButton.setVisible(False)
return return
def _minmaxDocument(self): def _minmaxDocument(self):
"""Switch on or off zen mode. """Switch on or off zen mode.
""" """
self.theParent.theParent.toggleZenMode() self.theParent.toggleZenMode()
if self.theParent.theParent.isZenMode: if self.theParent.isZenMode:
self.minmaxButton.setIcon(self.theTheme.getIcon("minimise")) self.minmaxButton.setIcon(self.theTheme.getIcon("minimise"))
self.setContentsMargins(self.buttonSize, 0, 0, 0) self.setContentsMargins(self.buttonSize, 0, 0, 0)
self.closeButton.setVisible(False) self.closeButton.setVisible(False)
@@ -1251,7 +1255,7 @@ class GuiDocEditHeader(QWidget):
"""Capture a click on the title and ensure that the item is """Capture a click on the title and ensure that the item is
selected in the project tree. selected in the project tree.
""" """
self.theParent.setSelectedHandle(self.theHandle) self.theParent.treeView.setSelectedHandle(self.theHandle)
return return
# END Class GuiDocEditHeader # END Class GuiDocEditHeader