Merge pull request #464 from vkbo/gui_improvements
GUI Improvements (Integers)
This commit is contained in:
@@ -899,8 +899,10 @@ class GuiBuildNovel(QDialog):
|
|||||||
def _doPrintPreview(self, thePrinter):
|
def _doPrintPreview(self, thePrinter):
|
||||||
"""Connect the print preview painter to the document viewer.
|
"""Connect the print preview painter to the document viewer.
|
||||||
"""
|
"""
|
||||||
|
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
thePrinter.setOrientation(QPrinter.Portrait)
|
thePrinter.setOrientation(QPrinter.Portrait)
|
||||||
self.docView.qDocument.print(thePrinter)
|
self.docView.qDocument.print(thePrinter)
|
||||||
|
qApp.restoreOverrideCursor()
|
||||||
return
|
return
|
||||||
|
|
||||||
def _selectFont(self):
|
def _selectFont(self):
|
||||||
|
|||||||
+2
-2
@@ -2273,10 +2273,10 @@ class GuiDocEditFooter(QWidget):
|
|||||||
wCount = self.theItem.wordCount
|
wCount = self.theItem.wordCount
|
||||||
wDiff = wCount - self.theItem.initCount
|
wDiff = wCount - self.theItem.initCount
|
||||||
|
|
||||||
self.wordsText.setText("Words: {:n} ({:+n})".format(wCount, wDiff))
|
self.wordsText.setText(f"Words: {wCount:n} ({wDiff:+n})")
|
||||||
|
|
||||||
byteSize = self.docEditor.qDocument.characterCount()
|
byteSize = self.docEditor.qDocument.characterCount()
|
||||||
self.wordsText.setToolTip("Document size is {:n} bytes".format(byteSize))
|
self.wordsText.setToolTip(f"Document size is {byteSize:n} bytes")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
+19
-12
@@ -34,10 +34,10 @@ import logging
|
|||||||
|
|
||||||
from PyQt5.QtCore import Qt, QUrl, QSize, pyqtSlot
|
from PyQt5.QtCore import Qt, QUrl, QSize, pyqtSlot
|
||||||
from PyQt5.QtGui import (
|
from PyQt5.QtGui import (
|
||||||
QTextOption, QFont, QPalette, QColor, QTextCursor, QIcon
|
QTextOption, QFont, QPalette, QColor, QTextCursor, QIcon, QCursor
|
||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QTextBrowser, QWidget, QScrollArea, QLabel, QHBoxLayout, QToolButton,
|
qApp, QTextBrowser, QWidget, QScrollArea, QLabel, QHBoxLayout, QToolButton,
|
||||||
QAction, QMenu
|
QAction, QMenu
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -124,11 +124,15 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
theOpt.setAlignment(Qt.AlignJustify)
|
theOpt.setAlignment(Qt.AlignJustify)
|
||||||
self.qDocument.setDefaultTextOption(theOpt)
|
self.qDocument.setDefaultTextOption(theOpt)
|
||||||
|
|
||||||
|
# Refresh the tab stops
|
||||||
|
if self.mainConf.verQtValue >= 51000:
|
||||||
|
self.setTabStopDistance(self.mainConf.getTabWidth())
|
||||||
|
else:
|
||||||
|
self.setTabStopWidth(self.mainConf.getTabWidth())
|
||||||
|
|
||||||
# If we have a document open, we should reload it in case the font changed
|
# If we have a document open, we should reload it in case the font changed
|
||||||
if self.theHandle is not None:
|
if self.theHandle is not None:
|
||||||
tHandle = self.theHandle
|
self.redrawText()
|
||||||
self.clearViewer()
|
|
||||||
self.loadText(tHandle)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -144,6 +148,8 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
logger.debug("Generating preview for item %s" % tHandle)
|
logger.debug("Generating preview for item %s" % tHandle)
|
||||||
|
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
|
|
||||||
sPos = self.verticalScrollBar().value()
|
sPos = self.verticalScrollBar().value()
|
||||||
aDoc = ToHtml(self.theProject, self.theParent)
|
aDoc = ToHtml(self.theProject, self.theParent)
|
||||||
aDoc.setPreview(True, self.mainConf.viewComments, self.mainConf.viewSynopsis)
|
aDoc.setPreview(True, self.mainConf.viewComments, self.mainConf.viewSynopsis)
|
||||||
@@ -195,7 +201,8 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
|
|
||||||
# Since we change the content while it may still be rendering, we mark
|
# Since we change the content while it may still be rendering, we mark
|
||||||
# the document dirty again to make sure it's re-rendered properly.
|
# the document dirty again to make sure it's re-rendered properly.
|
||||||
self.qDocument.markContentsDirty(0, self.qDocument.characterCount())
|
self.redrawText()
|
||||||
|
qApp.restoreOverrideCursor()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -205,6 +212,12 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
self.loadText(self.theHandle, updateHistory=False)
|
self.loadText(self.theHandle, updateHistory=False)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def redrawText(self):
|
||||||
|
"""Redraw the text by marking the document content as "dirty".
|
||||||
|
"""
|
||||||
|
self.qDocument.markContentsDirty(0, self.qDocument.characterCount())
|
||||||
|
return
|
||||||
|
|
||||||
def loadFromTag(self, theTag):
|
def loadFromTag(self, theTag):
|
||||||
"""Load text in the document from a reference given by a meta
|
"""Load text in the document from a reference given by a meta
|
||||||
tag rather than a known handle. This function depends on the
|
tag rather than a known handle. This function depends on the
|
||||||
@@ -489,12 +502,6 @@ class GuiDocViewer(QTextBrowser):
|
|||||||
"mark {{"
|
"mark {{"
|
||||||
" color: rgb({eColR},{eColG},{eColB});"
|
" color: rgb({eColR},{eColG},{eColB});"
|
||||||
"}}\n"
|
"}}\n"
|
||||||
"table {{"
|
|
||||||
" margin: 10px 0px;"
|
|
||||||
"}}\n"
|
|
||||||
"td {{"
|
|
||||||
" padding: 0px 4px;"
|
|
||||||
"}}\n"
|
|
||||||
".tags {{"
|
".tags {{"
|
||||||
" color: rgb({kColR},{kColG},{kColB});"
|
" color: rgb({kColR},{kColG},{kColB});"
|
||||||
" font-wright: bold;"
|
" font-wright: bold;"
|
||||||
|
|||||||
@@ -195,9 +195,9 @@ class GuiItemDetails(QWidget):
|
|||||||
we're already showing.
|
we're already showing.
|
||||||
"""
|
"""
|
||||||
if tHandle == self.theHandle:
|
if tHandle == self.theHandle:
|
||||||
self.cCountData.setText("{:n}".format(cC))
|
self.cCountData.setText(f"{cC:n}")
|
||||||
self.wCountData.setText("{:n}".format(wC))
|
self.wCountData.setText(f"{wC:n}")
|
||||||
self.pCountData.setText("{:n}".format(pC))
|
self.pCountData.setText(f"{pC:n}")
|
||||||
return
|
return
|
||||||
|
|
||||||
def updateViewBox(self, tHandle):
|
def updateViewBox(self, tHandle):
|
||||||
@@ -252,9 +252,9 @@ class GuiItemDetails(QWidget):
|
|||||||
self.layoutData.setText(nwLabels.LAYOUT_NAME[nwItem.itemLayout])
|
self.layoutData.setText(nwLabels.LAYOUT_NAME[nwItem.itemLayout])
|
||||||
|
|
||||||
if nwItem.itemType == nwItemType.FILE:
|
if nwItem.itemType == nwItemType.FILE:
|
||||||
self.cCountData.setText("{:n}".format(nwItem.charCount))
|
self.cCountData.setText(f"{nwItem.charCount:n}")
|
||||||
self.wCountData.setText("{:n}".format(nwItem.wordCount))
|
self.wCountData.setText(f"{nwItem.wordCount:n}")
|
||||||
self.pCountData.setText("{:n}".format(nwItem.paraCount))
|
self.pCountData.setText(f"{nwItem.paraCount:n}")
|
||||||
else:
|
else:
|
||||||
self.cCountData.setText("–")
|
self.cCountData.setText("–")
|
||||||
self.wCountData.setText("–")
|
self.wCountData.setText("–")
|
||||||
|
|||||||
+3
-3
@@ -431,9 +431,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], str(novIdx["cCount"]))
|
newItem.setText(self.colIndex[nwOutline.CCOUNT], "{:n}".format(novIdx["cCount"]))
|
||||||
newItem.setText(self.colIndex[nwOutline.WCOUNT], str(novIdx["wCount"]))
|
newItem.setText(self.colIndex[nwOutline.WCOUNT], "{:n}".format(novIdx["wCount"]))
|
||||||
newItem.setText(self.colIndex[nwOutline.PCOUNT], str(novIdx["pCount"]))
|
newItem.setText(self.colIndex[nwOutline.PCOUNT], "{:n}".format(novIdx["pCount"]))
|
||||||
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)
|
||||||
|
|||||||
@@ -282,15 +282,15 @@ class GuiProjectEditMeta(QWidget):
|
|||||||
|
|
||||||
self.nRootLabel = QLabel("Root folders:")
|
self.nRootLabel = QLabel("Root folders:")
|
||||||
self.nRootLabel.setIndent(xInd)
|
self.nRootLabel.setIndent(xInd)
|
||||||
self.nRootValue = QLabel("{:n}".format(nR))
|
self.nRootValue = QLabel(f"{nR:n}")
|
||||||
|
|
||||||
self.nDirLabel = QLabel("Folders:")
|
self.nDirLabel = QLabel("Folders:")
|
||||||
self.nDirLabel.setIndent(xInd)
|
self.nDirLabel.setIndent(xInd)
|
||||||
self.nDirValue = QLabel("{:n}".format(nD))
|
self.nDirValue = QLabel(f"{nD:n}")
|
||||||
|
|
||||||
self.nFileLabel = QLabel("Documents:")
|
self.nFileLabel = QLabel("Documents:")
|
||||||
self.nFileLabel.setIndent(xInd)
|
self.nFileLabel.setIndent(xInd)
|
||||||
self.nFileValue = QLabel("{:n}".format(nF))
|
self.nFileValue = QLabel(f"{nF:n}")
|
||||||
|
|
||||||
self.wordsLabel = QLabel("Word count:")
|
self.wordsLabel = QLabel("Word count:")
|
||||||
self.wordsLabel.setIndent(xInd)
|
self.wordsLabel.setIndent(xInd)
|
||||||
|
|||||||
+8
-5
@@ -401,7 +401,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
if nwItemS is None:
|
if nwItemS is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
wCount = int(trItemS.text(self.C_COUNT))
|
wCount = int(trItemS.data(self.C_COUNT, Qt.UserRole))
|
||||||
if nwItemS.itemType == nwItemType.FILE:
|
if nwItemS.itemType == nwItemType.FILE:
|
||||||
logger.debug("User requested file %s moved to trash" % tHandle)
|
logger.debug("User requested file %s moved to trash" % tHandle)
|
||||||
trItemP = trItemS.parent()
|
trItemP = trItemS.parent()
|
||||||
@@ -550,12 +550,13 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
"""
|
"""
|
||||||
tItem = self._getTreeItem(tHandle)
|
tItem = self._getTreeItem(tHandle)
|
||||||
if tItem is not None:
|
if tItem is not None:
|
||||||
tItem.setText(self.C_COUNT, str(theCount))
|
tItem.setText(self.C_COUNT, f"{theCount:n}")
|
||||||
|
tItem.setData(self.C_COUNT, Qt.UserRole, int(theCount))
|
||||||
pItem = tItem.parent()
|
pItem = tItem.parent()
|
||||||
if pItem is not None:
|
if pItem is not None:
|
||||||
pCount = 0
|
pCount = 0
|
||||||
for i in range(pItem.childCount()):
|
for i in range(pItem.childCount()):
|
||||||
pCount += int(pItem.child(i).text(self.C_COUNT))
|
pCount += int(pItem.child(i).data(self.C_COUNT, Qt.UserRole))
|
||||||
pHandle = pItem.data(self.C_NAME, Qt.UserRole)
|
pHandle = pItem.data(self.C_NAME, Qt.UserRole)
|
||||||
|
|
||||||
if not nDepth > nwConst.maxDepth + 1 and pHandle != "":
|
if not nDepth > nwConst.maxDepth + 1 and pHandle != "":
|
||||||
@@ -575,7 +576,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
tItem = self.topLevelItem(n)
|
tItem = self.topLevelItem(n)
|
||||||
if tItem == self.orphRoot:
|
if tItem == self.orphRoot:
|
||||||
continue
|
continue
|
||||||
nWords += int(tItem.text(self.C_COUNT))
|
nWords += int(tItem.data(self.C_COUNT, Qt.UserRole))
|
||||||
|
|
||||||
self.theProject.setProjectWordCount(nWords)
|
self.theProject.setProjectWordCount(nWords)
|
||||||
sWords = self.theProject.getSessionWordCount()
|
sWords = self.theProject.getSessionWordCount()
|
||||||
@@ -715,7 +716,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.makeAlert("The item cannot be moved to that location.", nwAlert.ERROR)
|
self.makeAlert("The item cannot be moved to that location.", nwAlert.ERROR)
|
||||||
return
|
return
|
||||||
|
|
||||||
wCount = int(sItem.text(self.C_COUNT))
|
wCount = int(sItem.data(self.C_COUNT, Qt.UserRole))
|
||||||
isSame = snItem.itemClass == dnItem.itemClass
|
isSame = snItem.itemClass == dnItem.itemClass
|
||||||
isNone = snItem.itemClass == nwItemClass.NO_CLASS
|
isNone = snItem.itemClass == nwItemClass.NO_CLASS
|
||||||
isNote = snItem.itemLayout == nwItemLayout.NOTE
|
isNote = snItem.itemLayout == nwItemLayout.NOTE
|
||||||
@@ -809,6 +810,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
newItem.setTextAlignment(self.C_FLAGS, Qt.AlignLeft | Qt.AlignVCenter)
|
newItem.setTextAlignment(self.C_FLAGS, Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
|
|
||||||
newItem.setData(self.C_NAME, Qt.UserRole, tHandle)
|
newItem.setData(self.C_NAME, Qt.UserRole, tHandle)
|
||||||
|
newItem.setData(self.C_COUNT, Qt.UserRole, 0)
|
||||||
|
|
||||||
self.theMap[tHandle] = newItem
|
self.theMap[tHandle] = newItem
|
||||||
if pHandle is None:
|
if pHandle is None:
|
||||||
@@ -881,6 +883,7 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self.orphRoot = newItem
|
self.orphRoot = newItem
|
||||||
newItem.setExpanded(True)
|
newItem.setExpanded(True)
|
||||||
newItem.setData(self.C_NAME, Qt.UserRole, "")
|
newItem.setData(self.C_NAME, Qt.UserRole, "")
|
||||||
|
newItem.setData(self.C_COUNT, Qt.UserRole, 0)
|
||||||
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("proj_orphan"))
|
newItem.setIcon(self.C_NAME, self.theTheme.getIcon("proj_orphan"))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -454,10 +454,11 @@ class GuiWritingStats(QDialog):
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
ttWords = ttNovel + ttNotes
|
||||||
self.labelTotal.setText(self._formatTime(ttTime))
|
self.labelTotal.setText(self._formatTime(ttTime))
|
||||||
self.novelWords.setText("{:n}".format(ttNovel))
|
self.novelWords.setText(f"{ttNovel:n}")
|
||||||
self.notesWords.setText("{:n}".format(ttNotes))
|
self.notesWords.setText(f"{ttNotes:n}")
|
||||||
self.totalWords.setText("{:n}".format(ttNovel + ttNotes))
|
self.totalWords.setText(f"{ttWords:n}")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -544,7 +545,7 @@ class GuiWritingStats(QDialog):
|
|||||||
newItem = QTreeWidgetItem()
|
newItem = QTreeWidgetItem()
|
||||||
newItem.setText(self.C_TIME, sStart)
|
newItem.setText(self.C_TIME, sStart)
|
||||||
newItem.setText(self.C_LENGTH, self._formatTime(sDiff))
|
newItem.setText(self.C_LENGTH, self._formatTime(sDiff))
|
||||||
newItem.setText(self.C_COUNT, "{:n}".format(nWords))
|
newItem.setText(self.C_COUNT, f"{nWords:n}")
|
||||||
|
|
||||||
if nWords > 0 and listMax > 0:
|
if nWords > 0 and listMax > 0:
|
||||||
theBar = self.barImage.scaled(
|
theBar = self.barImage.scaled(
|
||||||
|
|||||||
Reference in New Issue
Block a user