Merge branch 'main' into dev

This commit is contained in:
Veronica K. B. Olsen
2021-01-09 21:42:18 +01:00
4 changed files with 33 additions and 24 deletions
+18 -5
View File
@@ -316,7 +316,6 @@ class GuiDocEditor(QTextEdit):
self.lastEdit = time()
self._runCounter()
self.wcTimer.start()
self.setDocumentChanged(False)
self.theHandle = tHandle
self.setReadOnly(False)
@@ -341,6 +340,9 @@ class GuiDocEditor(QTextEdit):
self.docFooter.updateLineCount()
self.lengthLast = self.qDocument.characterCount()
qApp.processEvents()
self.setDocumentChanged(False)
qApp.restoreOverrideCursor()
return True
@@ -373,8 +375,8 @@ class GuiDocEditor(QTextEdit):
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
self.setPlainText(theText)
self.setDocumentChanged(True)
self.updateDocMargins()
self.setDocumentChanged(True)
qApp.restoreOverrideCursor()
return True
@@ -450,11 +452,17 @@ class GuiDocEditor(QTextEdit):
lM = max(cM, fH)
self.setViewportMargins(tM, uM, tM, lM)
docChanged = self.docChanged
if self.mainConf.scrollPastEnd:
docFrame = self.qDocument.rootFrame().frameFormat()
docFrame.setBottomMargin(max(0, 0.6*(wH - uM - lM - 4*tB)))
self.qDocument.rootFrame().setFrameFormat(docFrame)
# This is needed as the setFrameFormat function itself will
# trigger the contetsChanged signal which sets docChanged, so we
# set it back to whatever it was before.
self.setDocumentChanged(docChanged)
return
def updateDocInfo(self, tHandle):
@@ -895,12 +903,13 @@ class GuiDocEditor(QTextEdit):
##
@pyqtSlot(int, int, int)
def _docChange(self, thePos, charsRemoved, charsAdded):
def _docChange(self, thePos, chrRem, chrAdd):
"""Triggered by QTextDocument->contentsChanged. This also
triggers the syntax highlighter.
"""
self.lastEdit = time()
self.lastFind = None
if self.qDocument.characterCount() > nwConst.MAX_DOCSIZE:
self.theParent.makeAlert((
"The document has grown too big and you cannot add more text to it. "
@@ -908,12 +917,16 @@ class GuiDocEditor(QTextEdit):
) % (nwConst.MAX_DOCSIZE/1.0e6), nwAlert.ERROR)
self.undo()
return
if not self.docChanged:
self.setDocumentChanged(True)
self.setDocumentChanged(chrRem != 0 or chrAdd != 0)
if not self.wcTimer.isActive():
self.wcTimer.start()
if self.doReplace and charsAdded == 1:
if self.doReplace and chrAdd == 1:
self._docAutoReplace(self.qDocument.findBlock(thePos))
return
@pyqtSlot("QPoint")
+2 -17
View File
@@ -51,9 +51,6 @@ class GuiMainStatus(QStatusBar):
self.theTheme = theParent.theTheme
self.refTime = None
self.projWords = 0
self.sessWords = 0
colNone = QColor(*self.theTheme.statNone)
colTrue = QColor(*self.theTheme.statUnsaved)
colFalse = QColor(*self.theTheme.statSaved)
@@ -182,26 +179,14 @@ class GuiMainStatus(QStatusBar):
def setStats(self, pWC, sWC):
"""Set the current project statistics.
"""
self.projWords = pWC
self.sessWords = sWC
self._updateStats()
self.statsText.setText(f"Words: {pWC:n} ({sWC:+n})")
self.statsText.setToolTip("Project word count (session change)")
return
##
# Internal Functions
##
def _updateStats(self):
"""Update statistics.
"""
self.statsText.setToolTip(
"Project word count (session change)"
)
self.statsText.setText(
f"Words: {self.projWords:n} ({self.sessWords:+n})"
)
return
def _updateTime(self):
"""Update the session clock.
"""