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