Need more calls to update document margins due to the document title bar.

This commit is contained in:
Veronica K. B. Olsen
2020-05-27 01:18:37 +02:00
parent fed2a0508e
commit e4f2e088bb
2 changed files with 27 additions and 17 deletions
+2 -1
View File
@@ -228,7 +228,6 @@ class GuiDocEditor(QTextEdit):
tHandle = self.theHandle
self.clearEditor()
self.loadText(tHandle, showStatus=False)
self.updateDocMargins()
return
def loadText(self, tHandle, tLine=None, showStatus=True):
@@ -289,6 +288,7 @@ class GuiDocEditor(QTextEdit):
"""
self.setPlainText(theText)
self.setDocumentChanged(True)
self.updateDocMargins()
return
def saveText(self):
@@ -370,6 +370,7 @@ class GuiDocEditor(QTextEdit):
"""
if tHandle == self.theHandle:
self.docTitle.setTitleFromHandle(self.theHandle)
self.updateDocMargins()
return
##
+25 -16
View File
@@ -145,6 +145,7 @@ class GuiDocViewer(QTextBrowser):
self.theHandle = tHandle
self.theProject.setLastViewed(tHandle)
self.docTitle.setTitleFromHandle(self.theHandle)
self.updateDocMargins()
# Make sure the main GUI knows we changed the content
self.theParent.viewMeta.refreshReferences(tHandle)
@@ -199,23 +200,11 @@ class GuiDocViewer(QTextBrowser):
return False
return True
def updateDocTitle(self, tHandle):
"""Called when an item label is changed to check if the document
title bar needs updating,
def updateDocMargins(self):
"""Automatically adjust the margins so the text is centred if
Config.textFixedW is enabled or we're in Zen mode. Otherwise,
just ensure the margins are set correctly.
"""
if tHandle == self.theHandle:
self.docTitle.setTitleFromHandle(self.theHandle)
return
##
# Events
##
def resizeEvent(self, theEvent):
"""Make sure the document title is the same width as the window.
"""
QTextBrowser.resizeEvent(self, theEvent)
tB = self.lineWidth()
tW = self.width() - 2*tB
tH = self.docTitle.height()
@@ -235,6 +224,26 @@ class GuiDocViewer(QTextBrowser):
return
def updateDocTitle(self, tHandle):
"""Called when an item label is changed to check if the document
title bar needs updating,
"""
if tHandle == self.theHandle:
self.docTitle.setTitleFromHandle(self.theHandle)
self.updateDocMargins()
return
##
# Events
##
def resizeEvent(self, theEvent):
"""Make sure the document title is the same width as the window.
"""
QTextBrowser.resizeEvent(self, theEvent)
self.updateDocMargins()
return
##
# Internal Functions
##