First some cleanup of the document widgets
This commit is contained in:
+15
-9
@@ -7,7 +7,7 @@
|
||||
|
||||
File History:
|
||||
Created: 2018-09-29 [0.0.1] GuiDocEditor
|
||||
Created: 2019-04-22 [0.0.1] WordCounter
|
||||
Created: 2019-04-22 [0.0.1] BackgroundWordCounter
|
||||
Created: 2020-04-25 [0.4.5] GuiDocEditHeader
|
||||
|
||||
This file is a part of novelWriter
|
||||
@@ -126,7 +126,7 @@ class GuiDocEditor(QTextEdit):
|
||||
self.wcTimer.setInterval(int(self.wcInterval*1000))
|
||||
self.wcTimer.timeout.connect(self._runCounter)
|
||||
|
||||
self.wCounter = WordCounter(self)
|
||||
self.wCounter = BackgroundWordCounter(self)
|
||||
self.wCounter.finished.connect(self._updateCounts)
|
||||
|
||||
self.initEditor()
|
||||
@@ -338,11 +338,7 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
docFormat = self.qDocument.rootFrame().frameFormat()
|
||||
docFormat.setLeftMargin(tM)
|
||||
docFormat.setRightMargin(tM)
|
||||
if tT > 0:
|
||||
docFormat.setTopMargin(tT)
|
||||
else:
|
||||
docFormat.setTopMargin(0)
|
||||
docFormat.setTopMargin(max(0, tT))
|
||||
|
||||
# Updating root frame triggers a QTextDocument->contentsChange
|
||||
# signal, which we do not want as it re-runs the syntax
|
||||
@@ -1205,7 +1201,12 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
# END Class GuiDocEditor
|
||||
|
||||
class WordCounter(QThread):
|
||||
# =============================================================================================== #
|
||||
# The Off GUI Thread Word Counter
|
||||
# Runs the word counter in the background for the doCEditor
|
||||
# =============================================================================================== #
|
||||
|
||||
class BackgroundWordCounter(QThread):
|
||||
|
||||
def __init__(self, theParent):
|
||||
QThread.__init__(self, theParent)
|
||||
@@ -1228,7 +1229,12 @@ class WordCounter(QThread):
|
||||
|
||||
return
|
||||
|
||||
## END Class WordCounter
|
||||
## END Class BackgroundWordCounter
|
||||
|
||||
# =============================================================================================== #
|
||||
# The Embedded Document Header
|
||||
# Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport
|
||||
# =============================================================================================== #
|
||||
|
||||
class GuiDocEditHeader(QWidget):
|
||||
|
||||
|
||||
+12
-11
@@ -236,13 +236,14 @@ class GuiDocViewer(QTextBrowser):
|
||||
else:
|
||||
sW = 0
|
||||
|
||||
cM = self.mainConf.getTextMargin()
|
||||
tB = self.frameWidth()
|
||||
tW = self.width() - 2*tB - sW
|
||||
tH = self.docHeader.height()
|
||||
fH = self.docFooter.height()
|
||||
fY = self.height() - fH - tB
|
||||
tT = self.mainConf.getTextMargin() - tH
|
||||
bT = self.mainConf.getTextMargin() - fH
|
||||
tT = cM - tH
|
||||
bT = cM - fH
|
||||
self.docHeader.setGeometry(tB, tB, tW, tH)
|
||||
self.docFooter.setGeometry(tB, fY, tW, fH)
|
||||
self.setViewportMargins(0, tH, 0, fH)
|
||||
@@ -558,16 +559,16 @@ class GuiDocViewHeader(QWidget):
|
||||
|
||||
class GuiDocViewFooter(QWidget):
|
||||
|
||||
def __init__(self, theParent):
|
||||
QWidget.__init__(self, theParent)
|
||||
def __init__(self, docViewer):
|
||||
QWidget.__init__(self, docViewer)
|
||||
|
||||
logger.debug("Initialising GuiDocViewFooter ...")
|
||||
|
||||
self.mainConf = nw.CONFIG
|
||||
self.theParent = theParent
|
||||
self.theTheme = theParent.theTheme
|
||||
self.optState = theParent.theProject.optState
|
||||
self.viewMeta = theParent.theParent.viewMeta
|
||||
self.docViewer = docViewer
|
||||
self.theParent = docViewer.theParent
|
||||
self.theTheme = docViewer.theTheme
|
||||
self.viewMeta = docViewer.theParent.viewMeta
|
||||
self.theHandle = None
|
||||
|
||||
# Make a QPalette that matches the Syntax Theme
|
||||
@@ -669,9 +670,9 @@ class GuiDocViewFooter(QWidget):
|
||||
"""Toggle the sticky flag for the reference panel.
|
||||
"""
|
||||
logger.verbose("Reference sticky is %s" % str(theState))
|
||||
self.theParent.stickyRef = theState
|
||||
if not theState and self.theParent.theHandle is not None:
|
||||
self.viewMeta.refreshReferences(self.theParent.theHandle)
|
||||
self.docViewer.stickyRef = theState
|
||||
if not theState and self.docViewer.theHandle is not None:
|
||||
self.viewMeta.refreshReferences(self.docViewer.theHandle)
|
||||
return
|
||||
|
||||
# END Class GuiDocViewFooter
|
||||
|
||||
Reference in New Issue
Block a user