Merge branch 'main' into release_1.0.1
This commit is contained in:
+4
-1
@@ -606,10 +606,13 @@ class NWProject():
|
|||||||
self.theParent.setStatus("Opened Project: %s" % self.projName)
|
self.theParent.setStatus("Opened Project: %s" % self.projName)
|
||||||
|
|
||||||
self._scanProjectFolder()
|
self._scanProjectFolder()
|
||||||
self.setProjectChanged(False)
|
|
||||||
|
self.currWCount = self.lastWCount
|
||||||
self.projOpened = time()
|
self.projOpened = time()
|
||||||
self.projAltered = False
|
self.projAltered = False
|
||||||
|
|
||||||
self._writeLockFile()
|
self._writeLockFile()
|
||||||
|
self.setProjectChanged(False)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
+18
-5
@@ -316,7 +316,6 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.lastEdit = time()
|
self.lastEdit = time()
|
||||||
self._runCounter()
|
self._runCounter()
|
||||||
self.wcTimer.start()
|
self.wcTimer.start()
|
||||||
self.setDocumentChanged(False)
|
|
||||||
self.theHandle = tHandle
|
self.theHandle = tHandle
|
||||||
|
|
||||||
self.setReadOnly(False)
|
self.setReadOnly(False)
|
||||||
@@ -341,6 +340,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.docFooter.updateLineCount()
|
self.docFooter.updateLineCount()
|
||||||
self.lengthLast = self.qDocument.characterCount()
|
self.lengthLast = self.qDocument.characterCount()
|
||||||
|
|
||||||
|
qApp.processEvents()
|
||||||
|
self.setDocumentChanged(False)
|
||||||
|
|
||||||
qApp.restoreOverrideCursor()
|
qApp.restoreOverrideCursor()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -373,8 +375,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
self.setPlainText(theText)
|
self.setPlainText(theText)
|
||||||
self.setDocumentChanged(True)
|
|
||||||
self.updateDocMargins()
|
self.updateDocMargins()
|
||||||
|
self.setDocumentChanged(True)
|
||||||
qApp.restoreOverrideCursor()
|
qApp.restoreOverrideCursor()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -450,11 +452,17 @@ class GuiDocEditor(QTextEdit):
|
|||||||
lM = max(cM, fH)
|
lM = max(cM, fH)
|
||||||
self.setViewportMargins(tM, uM, tM, lM)
|
self.setViewportMargins(tM, uM, tM, lM)
|
||||||
|
|
||||||
|
docChanged = self.docChanged
|
||||||
if self.mainConf.scrollPastEnd:
|
if self.mainConf.scrollPastEnd:
|
||||||
docFrame = self.qDocument.rootFrame().frameFormat()
|
docFrame = self.qDocument.rootFrame().frameFormat()
|
||||||
docFrame.setBottomMargin(max(0, 0.6*(wH - uM - lM - 4*tB)))
|
docFrame.setBottomMargin(max(0, 0.6*(wH - uM - lM - 4*tB)))
|
||||||
self.qDocument.rootFrame().setFrameFormat(docFrame)
|
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
|
return
|
||||||
|
|
||||||
def updateDocInfo(self, tHandle):
|
def updateDocInfo(self, tHandle):
|
||||||
@@ -895,12 +903,13 @@ class GuiDocEditor(QTextEdit):
|
|||||||
##
|
##
|
||||||
|
|
||||||
@pyqtSlot(int, int, int)
|
@pyqtSlot(int, int, int)
|
||||||
def _docChange(self, thePos, charsRemoved, charsAdded):
|
def _docChange(self, thePos, chrRem, chrAdd):
|
||||||
"""Triggered by QTextDocument->contentsChanged. This also
|
"""Triggered by QTextDocument->contentsChanged. This also
|
||||||
triggers the syntax highlighter.
|
triggers the syntax highlighter.
|
||||||
"""
|
"""
|
||||||
self.lastEdit = time()
|
self.lastEdit = time()
|
||||||
self.lastFind = None
|
self.lastFind = None
|
||||||
|
|
||||||
if self.qDocument.characterCount() > nwConst.MAX_DOCSIZE:
|
if self.qDocument.characterCount() > nwConst.MAX_DOCSIZE:
|
||||||
self.theParent.makeAlert((
|
self.theParent.makeAlert((
|
||||||
"The document has grown too big and you cannot add more text to it. "
|
"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)
|
) % (nwConst.MAX_DOCSIZE/1.0e6), nwAlert.ERROR)
|
||||||
self.undo()
|
self.undo()
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.docChanged:
|
if not self.docChanged:
|
||||||
self.setDocumentChanged(True)
|
self.setDocumentChanged(chrRem != 0 or chrAdd != 0)
|
||||||
|
|
||||||
if not self.wcTimer.isActive():
|
if not self.wcTimer.isActive():
|
||||||
self.wcTimer.start()
|
self.wcTimer.start()
|
||||||
if self.doReplace and charsAdded == 1:
|
|
||||||
|
if self.doReplace and chrAdd == 1:
|
||||||
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@pyqtSlot("QPoint")
|
@pyqtSlot("QPoint")
|
||||||
|
|||||||
+2
-17
@@ -51,9 +51,6 @@ class GuiMainStatus(QStatusBar):
|
|||||||
self.theTheme = theParent.theTheme
|
self.theTheme = theParent.theTheme
|
||||||
self.refTime = None
|
self.refTime = None
|
||||||
|
|
||||||
self.projWords = 0
|
|
||||||
self.sessWords = 0
|
|
||||||
|
|
||||||
colNone = QColor(*self.theTheme.statNone)
|
colNone = QColor(*self.theTheme.statNone)
|
||||||
colTrue = QColor(*self.theTheme.statUnsaved)
|
colTrue = QColor(*self.theTheme.statUnsaved)
|
||||||
colFalse = QColor(*self.theTheme.statSaved)
|
colFalse = QColor(*self.theTheme.statSaved)
|
||||||
@@ -182,26 +179,14 @@ class GuiMainStatus(QStatusBar):
|
|||||||
def setStats(self, pWC, sWC):
|
def setStats(self, pWC, sWC):
|
||||||
"""Set the current project statistics.
|
"""Set the current project statistics.
|
||||||
"""
|
"""
|
||||||
self.projWords = pWC
|
self.statsText.setText(f"Words: {pWC:n} ({sWC:+n})")
|
||||||
self.sessWords = sWC
|
self.statsText.setToolTip("Project word count (session change)")
|
||||||
self._updateStats()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# 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):
|
def _updateTime(self):
|
||||||
"""Update the session clock.
|
"""Update the session clock.
|
||||||
"""
|
"""
|
||||||
|
|||||||
+9
-1
@@ -428,10 +428,12 @@ class GuiMain(QMainWindow):
|
|||||||
self.docEditor.setSpellCheck(self.theProject.spellCheck)
|
self.docEditor.setSpellCheck(self.theProject.spellCheck)
|
||||||
self.mainMenu.setAutoOutline(self.theProject.autoOutline)
|
self.mainMenu.setAutoOutline(self.theProject.autoOutline)
|
||||||
self.statusBar.setRefTime(self.theProject.projOpened)
|
self.statusBar.setRefTime(self.theProject.projOpened)
|
||||||
|
self.statusBar.setStats(self.theProject.currWCount, 0)
|
||||||
|
|
||||||
# Restore previously open documents, if any
|
# Restore previously open documents, if any
|
||||||
if self.theProject.lastEdited is not None:
|
if self.theProject.lastEdited is not None:
|
||||||
self.openDocument(self.theProject.lastEdited, doScroll=True)
|
self.openDocument(self.theProject.lastEdited, doScroll=True)
|
||||||
|
|
||||||
if self.theProject.lastViewed is not None:
|
if self.theProject.lastViewed is not None:
|
||||||
self.viewDocument(self.theProject.lastViewed)
|
self.viewDocument(self.theProject.lastViewed)
|
||||||
|
|
||||||
@@ -439,6 +441,12 @@ class GuiMain(QMainWindow):
|
|||||||
if self.theIndex.indexBroken:
|
if self.theIndex.indexBroken:
|
||||||
self.rebuildIndex()
|
self.rebuildIndex()
|
||||||
|
|
||||||
|
# Make sure the changed status is set to false on all that was
|
||||||
|
# just opened
|
||||||
|
qApp.processEvents()
|
||||||
|
self.docEditor.setDocumentChanged(False)
|
||||||
|
self.theProject.setProjectChanged(False)
|
||||||
|
|
||||||
logger.debug("Project load complete")
|
logger.debug("Project load complete")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -459,7 +467,7 @@ class GuiMain(QMainWindow):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
self.treeView.saveTreeOrder()
|
self.treeView.saveTreeOrder()
|
||||||
self.theProject.saveProject(autoSave)
|
self.theProject.saveProject(autoSave=autoSave)
|
||||||
self.theIndex.saveIndex()
|
self.theIndex.saveIndex()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user