The document title bar is no populated on document open

This commit is contained in:
Veronica K. B. Olsen
2020-05-01 17:36:02 +02:00
parent 0387ce67b7
commit 7d91a15841
4 changed files with 84 additions and 7 deletions
+38 -5
View File
@@ -32,23 +32,28 @@ from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import QLabel
from nw.constants import nwUnicode
logger = logging.getLogger(__name__)
class GuiDocTitleBar(QLabel):
def __init__(self, theParent):
def __init__(self, theParent, theProject):
QLabel.__init__(self, theParent)
logger.debug("Initialising DocTitleBar ...")
self.mainConf = nw.CONFIG
self.theParent = theParent
self.theTheme = theParent.theTheme
self.mainConf = nw.CONFIG
self.theParent = theParent
self.theProject = theProject
self.theTheme = theParent.theTheme
self.theHandle = None
self.setText("A > B > C")
self.setText("")
self.setContentsMargins(8,2,8,2)
self.setAutoFillBackground(True)
self.setAlignment(Qt.AlignCenter)
self.setWordWrap(True)
docPalette = self.palette()
docPalette.setColor(QPalette.Window, QColor(*self.theTheme.colBack))
docPalette.setColor(QPalette.Text, QColor(*self.theTheme.colText))
@@ -58,4 +63,32 @@ class GuiDocTitleBar(QLabel):
return
def setTitleFromHandle(self, tHandle):
"""Sets the document title from the handle, or alternatively,
set the whole document path.
"""
self.setText("")
self.theHandle = tHandle
if tHandle is None:
return False
if True:
tTitle = []
tTree = self.theProject.getItemPath(tHandle)
for aHandle in reversed(tTree):
nwItem = self.theProject.getItem(aHandle)
if nwItem is not None:
tTitle.append(nwItem.itemName)
sSep = " %s " % nwUnicode.U_RTRI
self.setText(sSep.join(tTitle))
else:
nwItem = self.theProject.getItem(tHandle)
if nwItem is None:
return False
self.setText(nwItem.itemName)
return True
# END Class GuiDocTitleBar