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