Merge branch 'main' into release_1.0rc2
This commit is contained in:
@@ -102,10 +102,9 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
self.colTrail = QColor(*self.theTheme.colEmph)
|
||||
self.colTrail.setAlpha(64)
|
||||
|
||||
self.colEmph = None
|
||||
if self.mainConf.highlightEmph:
|
||||
self.colEmph = QColor(*self.theTheme.colEmph)
|
||||
else:
|
||||
self.colEmph = None
|
||||
|
||||
self.hStyles = {
|
||||
"header1" : self._makeFormat(self.colHead, "bold", 1.8),
|
||||
|
||||
@@ -806,14 +806,6 @@ class GuiConfigEditEditingTab(QWidget):
|
||||
# Internal Functions
|
||||
##
|
||||
|
||||
def _disableComboItem(self, theList, theValue):
|
||||
"""Disable a list item in the combo box.
|
||||
"""
|
||||
theModel = theList.model()
|
||||
anItem = theModel.item(1)
|
||||
anItem.setFlags(anItem.flags() ^ Qt.ItemIsEnabled)
|
||||
return theModel
|
||||
|
||||
def _doUpdateSpellTool(self, currIdx):
|
||||
"""Update the list of dictionaries based on spell tool selected.
|
||||
"""
|
||||
|
||||
+3
-3
@@ -155,14 +155,14 @@ class GuiProjectLoad(QDialog):
|
||||
logger.verbose("GuiProjectLoad open button clicked")
|
||||
self._saveSettings()
|
||||
|
||||
self.openPath = None
|
||||
self.openState = self.NONE_STATE
|
||||
|
||||
selItems = self.listBox.selectedItems()
|
||||
if selItems:
|
||||
self.openPath = selItems[0].data(self.C_NAME, Qt.UserRole)
|
||||
self.openState = self.OPEN_STATE
|
||||
self.accept()
|
||||
else:
|
||||
self.openPath = None
|
||||
self.openState = self.NONE_STATE
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -220,9 +220,8 @@ class GuiProjectEditMain(QWidget):
|
||||
"Overrides main preferences."
|
||||
)
|
||||
|
||||
if self.theProject.projLang is None:
|
||||
spellIdx = 0
|
||||
else:
|
||||
spellIdx = 0
|
||||
if self.theProject.projLang is not None:
|
||||
spellIdx = self.spellLang.findData(self.theProject.projLang)
|
||||
if spellIdx != -1:
|
||||
self.spellLang.setCurrentIndex(spellIdx)
|
||||
@@ -515,9 +514,7 @@ class GuiProjectEditStatus(QWidget):
|
||||
"""Get the currently selected item.
|
||||
"""
|
||||
selItem = self.listBox.selectedItems()
|
||||
if len(selItem) == 0:
|
||||
return None
|
||||
if isinstance(selItem[0], QListWidgetItem):
|
||||
if len(selItem) > 0:
|
||||
return selItem[0]
|
||||
return None
|
||||
|
||||
|
||||
+6
-6
@@ -130,6 +130,7 @@ class GuiMainStatus(QStatusBar):
|
||||
"""Reset all widgets on the status bar to default values.
|
||||
"""
|
||||
self.setRefTime(None)
|
||||
self.setLanguage(None)
|
||||
self.setStats(0, 0)
|
||||
self.setProjectStatus(None)
|
||||
self.setDocumentStatus(None)
|
||||
@@ -234,15 +235,14 @@ class StatusLED(QAbstractButton):
|
||||
def setState(self, theState):
|
||||
"""Set the colour state.
|
||||
"""
|
||||
if theState is None:
|
||||
self._theCol = self.colNone
|
||||
elif theState:
|
||||
self._theCol = self.colNone
|
||||
if theState is True:
|
||||
self._theCol = self.colTrue
|
||||
elif not theState:
|
||||
elif theState is False:
|
||||
self._theCol = self.colFalse
|
||||
else:
|
||||
self._theCol = self.colNone
|
||||
|
||||
self.update()
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
+20
-28
@@ -39,7 +39,7 @@ from PyQt5.QtWidgets import (
|
||||
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
|
||||
)
|
||||
|
||||
from nw.common import formatTime
|
||||
from nw.common import formatTime, checkInt
|
||||
from nw.constants import nwConst, nwFiles, nwAlert
|
||||
from nw.gui.custom import QSwitch
|
||||
|
||||
@@ -316,37 +316,30 @@ class GuiWritingStats(QDialog):
|
||||
if dataFmt == self.FMT_JSON:
|
||||
fileExt = "json"
|
||||
textFmt = "JSON Data File"
|
||||
|
||||
elif dataFmt == self.FMT_CSV:
|
||||
fileExt = "csv"
|
||||
textFmt = "CSV Data File"
|
||||
|
||||
else:
|
||||
return False
|
||||
|
||||
# Generate the file name
|
||||
if fileExt:
|
||||
saveDir = self.mainConf.lastPath
|
||||
if not os.path.isdir(saveDir):
|
||||
saveDir = os.path.expanduser("~")
|
||||
saveDir = self.mainConf.lastPath
|
||||
if not os.path.isdir(saveDir):
|
||||
saveDir = os.path.expanduser("~")
|
||||
|
||||
fileName = "sessionStats.%s" % fileExt
|
||||
savePath = os.path.join(saveDir, fileName)
|
||||
fileName = "sessionStats.%s" % fileExt
|
||||
savePath = os.path.join(saveDir, fileName)
|
||||
|
||||
dlgOpt = QFileDialog.Options()
|
||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||
savePath, _ = QFileDialog.getSaveFileName(
|
||||
self, "Save Document As", savePath, options=dlgOpt
|
||||
)
|
||||
|
||||
if not savePath:
|
||||
return False
|
||||
|
||||
self.mainConf.setLastPath(savePath)
|
||||
|
||||
else:
|
||||
dlgOpt = QFileDialog.Options()
|
||||
dlgOpt |= QFileDialog.DontUseNativeDialog
|
||||
savePath, _ = QFileDialog.getSaveFileName(
|
||||
self, "Save Document As", savePath, options=dlgOpt
|
||||
)
|
||||
if not savePath:
|
||||
return False
|
||||
|
||||
self.mainConf.setLastPath(savePath)
|
||||
|
||||
# Do the actual writing
|
||||
wSuccess = False
|
||||
errMsg = ""
|
||||
@@ -366,7 +359,7 @@ class GuiWritingStats(QDialog):
|
||||
json.dump(jsonData, outFile, indent=2)
|
||||
wSuccess = True
|
||||
|
||||
elif dataFmt == self.FMT_CSV:
|
||||
if dataFmt == self.FMT_CSV:
|
||||
outFile.write(
|
||||
'"Date","Length (sec)","Words Changed","Novel Words","Note Words"\n'
|
||||
)
|
||||
@@ -374,11 +367,9 @@ class GuiWritingStats(QDialog):
|
||||
outFile.write(f'"{sD}",{tT:.0f},{wD},{wA},{wB}\n')
|
||||
wSuccess = True
|
||||
|
||||
else:
|
||||
errMsg = "Unknown format"
|
||||
|
||||
except Exception as e:
|
||||
errMsg = str(e).replace("\n", "<br>")
|
||||
errMsg = str(e)
|
||||
wSuccess = False
|
||||
|
||||
# Report to user
|
||||
if wSuccess:
|
||||
@@ -394,7 +385,7 @@ class GuiWritingStats(QDialog):
|
||||
), nwAlert.ERROR
|
||||
)
|
||||
|
||||
return True
|
||||
return wSuccess
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
@@ -406,6 +397,7 @@ class GuiWritingStats(QDialog):
|
||||
logger.debug("Loading session log file")
|
||||
|
||||
self.logData = []
|
||||
self.wordOffset = 0
|
||||
|
||||
ttNovel = 0
|
||||
ttNotes = 0
|
||||
@@ -417,7 +409,7 @@ class GuiWritingStats(QDialog):
|
||||
for inLine in inFile:
|
||||
if inLine.startswith("#"):
|
||||
if inLine.startswith("# Offset"):
|
||||
self.wordOffset = int(inLine[9:].strip())
|
||||
self.wordOffset = checkInt(inLine[9:].strip(), 0)
|
||||
logger.verbose(
|
||||
"Initial word count when log was started is %d" % self.wordOffset
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user