Merge branch 'main' into release_1.0b3

This commit is contained in:
Veronica K. B. Olsen
2020-09-20 15:29:25 +02:00
7 changed files with 39 additions and 36 deletions
+1 -3
View File
@@ -10,9 +10,7 @@ coverage:
project: project:
default: default:
threshold: 1% threshold: 1%
patch: patch: no
default:
threshold: 1%
changes: no changes: no
parsers: parsers:
+4 -4
View File
@@ -29,7 +29,7 @@ import logging
from datetime import datetime from datetime import datetime
from nw.constants import nwConst from nw.constants import nwConst, nwUnicode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -150,11 +150,11 @@ def formatInt(theInt):
theVal /= 1000.0 theVal /= 1000.0
if theVal < 1000.0: if theVal < 1000.0:
if theVal < 10.0: if theVal < 10.0:
return "%4.2f%s" % (theVal, pF) return "%4.2f%s%s" % (theVal, nwUnicode.U_THNSP, pF)
elif theVal < 100.0: elif theVal < 100.0:
return "%4.1f%s" % (theVal, pF) return "%4.1f%s%s" % (theVal, nwUnicode.U_THNSP, pF)
else: else:
return "%3.0f%s" % (theVal, pF) return "%3.0f%s%s" % (theVal, nwUnicode.U_THNSP, pF)
return "%d" % theInt return "%d" % theInt
+1
View File
@@ -282,6 +282,7 @@ class GuiProjectLoad(QDialog):
newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter) newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter) newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter) newItem.setTextAlignment(self.C_TIME, Qt.AlignRight | Qt.AlignVCenter)
newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed)
self.listBox.addTopLevelItem(newItem) self.listBox.addTopLevelItem(newItem)
if not hasSelection: if not hasSelection:
newItem.setSelected(True) newItem.setSelected(True)
+11 -8
View File
@@ -985,23 +985,26 @@ class GuiProjectTreeMenu(QMenu):
"""Update item settings from the nwItem. """Update item settings from the nwItem.
""" """
self.theItem = theItem self.theItem = theItem
trashHandle = self.theTree.theProject.projTree.trashRoot() theRoot = self.theTree.theProject.projTree.getRootItem(theItem.itemHandle)
if theItem is None: if theItem is None or theRoot is None:
logger.error("Failed to extract information to build tree context menu")
return False return False
inTrash = theItem.parHandle == trashHandle trashHandle = self.theTree.theProject.projTree.trashRoot()
isTrash = theItem.itemHandle == trashHandle
inTrash = theItem.parHandle == trashHandle and trashHandle is not None
isTrash = theItem.itemHandle == trashHandle and trashHandle is not None
isFile = theItem.itemType == nwItemType.FILE isFile = theItem.itemType == nwItemType.FILE
isArch = theItem.itemClass == nwItemClass.ARCHIVE isArch = theRoot.itemClass == nwItemClass.ARCHIVE
isOrph = isFile and theItem.parHandle is None isOrph = isFile and theItem.parHandle is None
showOpen = isFile showOpen = isFile
showView = isFile showView = isFile
showEdit = not isTrash and not isOrph showEdit = not isTrash and not isOrph
showExport = isFile and not inTrash and not isOrph showExport = isFile
showNewFile = not isTrash and not inTrash and not isOrph and not isArch showNewFile = not (isTrash or inTrash or isOrph or isArch)
showNewFolder = not isTrash and not inTrash and not isOrph showNewFolder = not (isTrash or inTrash or isOrph)
showDelete = not isTrash showDelete = not isTrash
showEmpty = isTrash showEmpty = isTrash
+6 -1
View File
@@ -138,8 +138,8 @@ class GuiTheme:
logger.verbose("GUI DPI: %.1f" % self.guiDPI) logger.verbose("GUI DPI: %.1f" % self.guiDPI)
logger.verbose("GUI Scale: %.2f" % self.guiScale) logger.verbose("GUI Scale: %.2f" % self.guiScale)
# Fonts
self.guiFont = qApp.font() self.guiFont = qApp.font()
self.guiFontFixed = QFontDatabase.systemFont(QFontDatabase.FixedFont)
qMetric = QFontMetrics(self.guiFont) qMetric = QFontMetrics(self.guiFont)
self.fontPointSize = self.guiFont.pointSizeF() self.fontPointSize = self.guiFont.pointSizeF()
@@ -148,6 +148,11 @@ class GuiTheme:
self.textNHeight = qMetric.boundingRect("N").height() self.textNHeight = qMetric.boundingRect("N").height()
self.textNWidth = qMetric.boundingRect("N").width() self.textNWidth = qMetric.boundingRect("N").width()
# Monospace Font
self.guiFontFixed = QFont()
self.guiFontFixed.setPointSizeF(0.95*self.fontPointSize)
self.guiFontFixed.setFamily(QFontDatabase.systemFont(QFontDatabase.FixedFont).family())
logger.verbose("GUI Font Family: %s" % self.guiFont.family()) logger.verbose("GUI Font Family: %s" % self.guiFont.family())
logger.verbose("GUI Font Point Size: %.2f" % self.fontPointSize) logger.verbose("GUI Font Point Size: %.2f" % self.fontPointSize)
logger.verbose("GUI Font Pixel Size: %d" % self.fontPixelSize) logger.verbose("GUI Font Pixel Size: %d" % self.fontPixelSize)
+9 -13
View File
@@ -33,7 +33,7 @@ from os import path
from datetime import datetime from datetime import datetime
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont, QPixmap from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout, qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout,
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
@@ -100,10 +100,6 @@ class GuiWritingStats(QDialog):
hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight) hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight) hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)
self.monoFont = QFont()
self.monoFont.setPointSizeF(0.9*self.theTheme.fontPointSize)
self.monoFont.setFamily(self.theTheme.guiFontFixed.family())
sortValid = (Qt.AscendingOrder, Qt.DescendingOrder) sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
sortCol = self.optState.validIntRange( sortCol = self.optState.validIntRange(
self.optState.getInt("GuiWritingStats", "sortCol", 0), 0, 2, 0 self.optState.getInt("GuiWritingStats", "sortCol", 0), 0, 2, 0
@@ -127,23 +123,23 @@ class GuiWritingStats(QDialog):
self.infoBox.setLayout(self.infoForm) self.infoBox.setLayout(self.infoForm)
self.labelTotal = QLabel(self._formatTime(0)) self.labelTotal = QLabel(self._formatTime(0))
self.labelTotal.setFont(self.monoFont) self.labelTotal.setFont(self.theTheme.guiFontFixed)
self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.labelFilter = QLabel(self._formatTime(0)) self.labelFilter = QLabel(self._formatTime(0))
self.labelFilter.setFont(self.monoFont) self.labelFilter.setFont(self.theTheme.guiFontFixed)
self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.novelWords = QLabel("0") self.novelWords = QLabel("0")
self.novelWords.setFont(self.monoFont) self.novelWords.setFont(self.theTheme.guiFontFixed)
self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.notesWords = QLabel("0") self.notesWords = QLabel("0")
self.notesWords.setFont(self.monoFont) self.notesWords.setFont(self.theTheme.guiFontFixed)
self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.totalWords = QLabel("0") self.totalWords = QLabel("0")
self.totalWords.setFont(self.monoFont) self.totalWords.setFont(self.theTheme.guiFontFixed)
self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.infoForm.addWidget(QLabel("Total Time:"), 0, 0) self.infoForm.addWidget(QLabel("Total Time:"), 0, 0)
@@ -559,9 +555,9 @@ class GuiWritingStats(QDialog):
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight) newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
newItem.setTextAlignment(self.C_BAR, Qt.AlignLeft | Qt.AlignVCenter) newItem.setTextAlignment(self.C_BAR, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setFont(self.C_TIME, self.monoFont) newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed)
newItem.setFont(self.C_LENGTH, self.monoFont) newItem.setFont(self.C_LENGTH, self.theTheme.guiFontFixed)
newItem.setFont(self.C_COUNT, self.monoFont) newItem.setFont(self.C_COUNT, self.theTheme.guiFontFixed)
self.listBox.addTopLevelItem(newItem) self.listBox.addTopLevelItem(newItem)
self.timeFilter += sDiff self.timeFilter += sDiff
+7 -7
View File
@@ -86,13 +86,13 @@ def testFormatTime():
@pytest.mark.core @pytest.mark.core
def testFormatInt(): def testFormatInt():
assert formatInt(1000) == "1000" assert formatInt(1000) == "1000"
assert formatInt(1234) == "1.23k" assert formatInt(1234) == "1.23\u2009k"
assert formatInt(12345) == "12.3k" assert formatInt(12345) == "12.3\u2009k"
assert formatInt(123456) == "123k" assert formatInt(123456) == "123\u2009k"
assert formatInt(1234567) == "1.23M" assert formatInt(1234567) == "1.23\u2009M"
assert formatInt(12345678) == "12.3M" assert formatInt(12345678) == "12.3\u2009M"
assert formatInt(123456789) == "123M" assert formatInt(123456789) == "123\u2009M"
assert formatInt(1234567890) == "1.23G" assert formatInt(1234567890) == "1.23\u2009G"
@pytest.mark.core @pytest.mark.core
def testTransferCase(): def testTransferCase():