Update format statements and improve status bar clock

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