Update format statements and improve status bar clock
This commit is contained in:
@@ -25,5 +25,5 @@ jobs:
|
||||
flake8 tests --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
- name: Coding Style Violations
|
||||
run: |
|
||||
flake8 nw --count --max-line-length=99 --ignore E203,E221,E226,E241,E251,E261,E266,E302,E305 --show-source --statistics
|
||||
flake8 tests --count --max-line-length=99 --ignore E203,E221,E226,E241,E251,E261,E266,E302,E305 --show-source --statistics
|
||||
flake8 nw --count --max-line-length=99 --ignore E203,E221,E226,E228,E241,E251,E261,E266,E302,E305 --show-source --statistics
|
||||
flake8 tests --count --max-line-length=99 --ignore E203,E221,E226,E228,E241,E251,E261,E266,E302,E305 --show-source --statistics
|
||||
|
||||
@@ -222,7 +222,6 @@ class GuiAbout(QDialog):
|
||||
hColB = self.theParent.theTheme.colHead[2],
|
||||
)
|
||||
self.pageAbout.document().setDefaultStyleSheet(styleSheet)
|
||||
# self.pageCredit.document().setDefaultStyleSheet(styleSheet)
|
||||
self.pageLicense.document().setDefaultStyleSheet(styleSheet)
|
||||
|
||||
return
|
||||
|
||||
+9
-10
@@ -807,16 +807,16 @@ class GuiDocEditor(QTextEdit):
|
||||
return self.docSearch.cycleFocus(toNext)
|
||||
return True
|
||||
|
||||
def mouseReleaseEvent(self, mEvent):
|
||||
def mouseReleaseEvent(self, theEvent):
|
||||
"""If the mouse button is released and the control key is
|
||||
pressed, check if we're clicking on a tag, and trigger the
|
||||
follow tag function.
|
||||
"""
|
||||
if qApp.keyboardModifiers() == Qt.ControlModifier:
|
||||
theCursor = self.cursorForPosition(mEvent.pos())
|
||||
theCursor = self.cursorForPosition(theEvent.pos())
|
||||
self._followTag(theCursor)
|
||||
|
||||
QTextEdit.mouseReleaseEvent(self, mEvent)
|
||||
QTextEdit.mouseReleaseEvent(self, theEvent)
|
||||
self.docFooter.updateLineCount()
|
||||
|
||||
return
|
||||
@@ -1203,20 +1203,19 @@ class GuiDocEditor(QTextEdit):
|
||||
"""Check if document size crosses the big document limit set in
|
||||
config. If so, we will set the big document flag to True.
|
||||
"""
|
||||
newState = theSize > self.mainConf.bigDocLimit*1000
|
||||
bigLim = self.mainConf.bigDocLimit*1000
|
||||
newState = theSize > bigLim
|
||||
|
||||
if newState != self.bigDoc:
|
||||
if newState:
|
||||
logger.info(
|
||||
"The document size is {:n} > {:n}, big doc mode has been enabled".format(
|
||||
theSize, self.mainConf.bigDocLimit*1000
|
||||
)
|
||||
f"The document size is {theSize:n} > {bigLim:n}, "
|
||||
f"big doc mode has been enabled"
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
"The document size is {:n} <= {:n}, big doc mode has been disabled".format(
|
||||
theSize, self.mainConf.bigDocLimit*1000
|
||||
)
|
||||
f"The document size is {theSize:n} <= {bigLim:n}, "
|
||||
f"big doc mode has been disabled"
|
||||
)
|
||||
|
||||
self.bigDoc = newState
|
||||
|
||||
@@ -149,18 +149,22 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
|
||||
# Quoted Strings
|
||||
if self.mainConf.highlightQuotes:
|
||||
fmtDO = self.mainConf.fmtDoubleQuotes[0]
|
||||
fmtDC = self.mainConf.fmtDoubleQuotes[1]
|
||||
fmtSO = self.mainConf.fmtSingleQuotes[0]
|
||||
fmtSC = self.mainConf.fmtSingleQuotes[1]
|
||||
self.hRules.append((
|
||||
"\\B{:s}(.*?){:s}\\B".format('"', '"'), {
|
||||
"\\B\"(.*?)\"\\B", {
|
||||
0 : self.hStyles["dialogue1"],
|
||||
}
|
||||
))
|
||||
self.hRules.append((
|
||||
"\\B{:s}(.*?){:s}\\B".format(*self.mainConf.fmtDoubleQuotes), {
|
||||
f"\\B{fmtDO:s}(.*?){fmtDC:s}\\B", {
|
||||
0 : self.hStyles["dialogue2"],
|
||||
}
|
||||
))
|
||||
self.hRules.append((
|
||||
"\\B{:s}(.*?){:s}\\B".format(*self.mainConf.fmtSingleQuotes), {
|
||||
f"\\B{fmtSO:s}(.*?){fmtSC:s}\\B", {
|
||||
0 : self.hStyles["dialogue3"],
|
||||
}
|
||||
))
|
||||
|
||||
+7
-3
@@ -439,6 +439,10 @@ class GuiOutline(QTreeWidget):
|
||||
newItem = QTreeWidgetItem()
|
||||
hIcon = "doc_%s" % tLevel.lower()
|
||||
|
||||
cC = int(novIdx["cCount"])
|
||||
wC = int(novIdx["wCount"])
|
||||
pC = int(novIdx["pCount"])
|
||||
|
||||
newItem.setText(self.colIndex[nwOutline.TITLE], novIdx["title"])
|
||||
newItem.setData(self.colIndex[nwOutline.TITLE], Qt.UserRole, tHandle)
|
||||
newItem.setIcon(self.colIndex[nwOutline.TITLE], self.theTheme.getIcon(hIcon))
|
||||
@@ -448,9 +452,9 @@ class GuiOutline(QTreeWidget):
|
||||
newItem.setText(self.colIndex[nwOutline.LINE], sTitle[1:].lstrip("0"))
|
||||
newItem.setData(self.colIndex[nwOutline.LINE], Qt.UserRole, sTitle)
|
||||
newItem.setText(self.colIndex[nwOutline.SYNOP], novIdx["synopsis"])
|
||||
newItem.setText(self.colIndex[nwOutline.CCOUNT], "{:n}".format(novIdx["cCount"]))
|
||||
newItem.setText(self.colIndex[nwOutline.WCOUNT], "{:n}".format(novIdx["wCount"]))
|
||||
newItem.setText(self.colIndex[nwOutline.PCOUNT], "{:n}".format(novIdx["pCount"]))
|
||||
newItem.setText(self.colIndex[nwOutline.CCOUNT], f"{cC:n}")
|
||||
newItem.setText(self.colIndex[nwOutline.WCOUNT], f"{wC:n}")
|
||||
newItem.setText(self.colIndex[nwOutline.PCOUNT], f"{pC:n}")
|
||||
newItem.setTextAlignment(self.colIndex[nwOutline.CCOUNT], Qt.AlignRight)
|
||||
newItem.setTextAlignment(self.colIndex[nwOutline.WCOUNT], Qt.AlignRight)
|
||||
newItem.setTextAlignment(self.colIndex[nwOutline.PCOUNT], Qt.AlignRight)
|
||||
|
||||
@@ -266,9 +266,13 @@ class GuiOutlineDetails(QScrollArea):
|
||||
self.fileValue.setText(nwItem.itemName)
|
||||
self.itemValue.setText(nwItem.itemStatus)
|
||||
|
||||
self.cCValue.setText("{:n}".format(checkInt(novIdx["cCount"], 0)))
|
||||
self.wCValue.setText("{:n}".format(checkInt(novIdx["wCount"], 0)))
|
||||
self.pCValue.setText("{:n}".format(checkInt(novIdx["pCount"], 0)))
|
||||
cC = checkInt(novIdx["cCount"], 0)
|
||||
wC = checkInt(novIdx["wCount"], 0)
|
||||
pC = checkInt(novIdx["pCount"], 0)
|
||||
|
||||
self.cCValue.setText(f"{cC:n}")
|
||||
self.wCValue.setText(f"{wC:n}")
|
||||
self.pCValue.setText(f"{pC:n}")
|
||||
|
||||
self.synopValue.setText(novIdx["synopsis"])
|
||||
|
||||
|
||||
@@ -270,11 +270,12 @@ class GuiProjectEditMeta(QWidget):
|
||||
|
||||
self.revLabel = QLabel("Revision count:")
|
||||
self.revLabel.setIndent(xInd)
|
||||
self.revValue = QLabel("{:n}".format(self.theProject.saveCount))
|
||||
self.revValue = QLabel(f"{self.theProject.saveCount:n}")
|
||||
|
||||
editHours = self.theProject.editTime/3600
|
||||
self.editLabel = QLabel("Edit time:")
|
||||
self.editLabel.setIndent(xInd)
|
||||
self.editValue = QLabel("{:.2f} hours".format(self.theProject.editTime/3600))
|
||||
self.editValue = QLabel(f"{editHours:.2f} hours")
|
||||
|
||||
self.statsLabel = QLabel("<b>Project Stats</b>")
|
||||
|
||||
@@ -294,7 +295,7 @@ class GuiProjectEditMeta(QWidget):
|
||||
|
||||
self.wordsLabel = QLabel("Word count:")
|
||||
self.wordsLabel.setIndent(xInd)
|
||||
self.wordsValue = QLabel("{:n}".format(self.theProject.currWCount))
|
||||
self.wordsValue = QLabel(f"{self.theProject.currWCount:n}")
|
||||
|
||||
self.mainForm.addWidget(self.headLabel, 0, 0, 1, 2, Qt.AlignTop)
|
||||
self.mainForm.addWidget(self.nameLabel, 1, 0, 1, 1, Qt.AlignTop)
|
||||
|
||||
+9
-12
@@ -196,10 +196,7 @@ class GuiMainStatus(QStatusBar):
|
||||
"Project word count (session change)"
|
||||
)
|
||||
self.statsText.setText((
|
||||
"Words: {pWC:n} ({sWC:+n})"
|
||||
).format(
|
||||
pWC = self.projWords,
|
||||
sWC = self.sessWords,
|
||||
f"Words: {self.projWords:n} ({self.sessWords:+n})"
|
||||
))
|
||||
return
|
||||
|
||||
@@ -207,16 +204,16 @@ class GuiMainStatus(QStatusBar):
|
||||
"""Update the session clock.
|
||||
"""
|
||||
if self.refTime is None:
|
||||
theTime = "00:00:00"
|
||||
self.timeText.setText("00:00:00")
|
||||
else:
|
||||
# This is much faster than using datetime format
|
||||
tS = int(time() - self.refTime)
|
||||
tM = int(tS/60)
|
||||
tH = int(tM/60)
|
||||
tM = tM - tH*60
|
||||
tS = tS - tM*60 - tH*3600
|
||||
theTime = "%02d:%02d:%02d" % (tH, tM, tS)
|
||||
self.timeText.setText(theTime)
|
||||
tM = tS//60
|
||||
tH = tM//60
|
||||
tM %= 60
|
||||
tS %= 60
|
||||
self.timeText.setText(f"{tH:02d}:{tM:02d}:{tS:02d}")
|
||||
|
||||
return
|
||||
|
||||
# END Class GuiMainStatus
|
||||
@@ -237,7 +234,7 @@ class StatusLED(QAbstractButton):
|
||||
return
|
||||
|
||||
##
|
||||
# Getters and Setters
|
||||
# Setters
|
||||
##
|
||||
|
||||
def setState(self, theState):
|
||||
|
||||
Reference in New Issue
Block a user