From b9f983a34831751c9264bb8b41ea4c2a2a591b49 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Sep 2020 11:44:33 +0200 Subject: [PATCH 1/3] Moved fixed with definition to themes class, made time column in project load fixed width and added thin space between words and multiplier --- nw/common.py | 8 ++++---- nw/gui/projload.py | 1 + nw/gui/theme.py | 7 ++++++- nw/gui/writingstats.py | 22 +++++++++------------- tests/test_common.py | 14 +++++++------- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/nw/common.py b/nw/common.py index 68825f4d..04a39bf5 100644 --- a/nw/common.py +++ b/nw/common.py @@ -29,7 +29,7 @@ import logging from datetime import datetime -from nw.constants import nwConst +from nw.constants import nwConst, nwUnicode logger = logging.getLogger(__name__) @@ -150,11 +150,11 @@ def formatInt(theInt): theVal /= 1000.0 if theVal < 1000.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: - return "%4.1f%s" % (theVal, pF) + return "%4.1f%s%s" % (theVal, nwUnicode.U_THNSP, pF) else: - return "%3.0f%s" % (theVal, pF) + return "%3.0f%s%s" % (theVal, nwUnicode.U_THNSP, pF) return "%d" % theInt diff --git a/nw/gui/projload.py b/nw/gui/projload.py index 1c37d9c4..e8aed721 100644 --- a/nw/gui/projload.py +++ b/nw/gui/projload.py @@ -282,6 +282,7 @@ class GuiProjectLoad(QDialog): newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter) newItem.setTextAlignment(self.C_COUNT, 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) if not hasSelection: newItem.setSelected(True) diff --git a/nw/gui/theme.py b/nw/gui/theme.py index 123063b0..78f791db 100644 --- a/nw/gui/theme.py +++ b/nw/gui/theme.py @@ -138,8 +138,8 @@ class GuiTheme: logger.verbose("GUI DPI: %.1f" % self.guiDPI) logger.verbose("GUI Scale: %.2f" % self.guiScale) + # Fonts self.guiFont = qApp.font() - self.guiFontFixed = QFontDatabase.systemFont(QFontDatabase.FixedFont) qMetric = QFontMetrics(self.guiFont) self.fontPointSize = self.guiFont.pointSizeF() @@ -148,6 +148,11 @@ class GuiTheme: self.textNHeight = qMetric.boundingRect("N").height() 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 Point Size: %.2f" % self.fontPointSize) logger.verbose("GUI Font Pixel Size: %d" % self.fontPixelSize) diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py index 424912e5..27767916 100644 --- a/nw/gui/writingstats.py +++ b/nw/gui/writingstats.py @@ -33,7 +33,7 @@ from os import path from datetime import datetime from PyQt5.QtCore import Qt -from PyQt5.QtGui import QFont, QPixmap +from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import ( qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout, 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_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) sortCol = self.optState.validIntRange( self.optState.getInt("GuiWritingStats", "sortCol", 0), 0, 2, 0 @@ -127,23 +123,23 @@ class GuiWritingStats(QDialog): self.infoBox.setLayout(self.infoForm) 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.labelFilter = QLabel(self._formatTime(0)) - self.labelFilter.setFont(self.monoFont) + self.labelFilter.setFont(self.theTheme.guiFontFixed) self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.novelWords = QLabel("0") - self.novelWords.setFont(self.monoFont) + self.novelWords.setFont(self.theTheme.guiFontFixed) self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.notesWords = QLabel("0") - self.notesWords.setFont(self.monoFont) + self.notesWords.setFont(self.theTheme.guiFontFixed) self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) self.totalWords = QLabel("0") - self.totalWords.setFont(self.monoFont) + self.totalWords.setFont(self.theTheme.guiFontFixed) self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight) 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_BAR, Qt.AlignLeft | Qt.AlignVCenter) - newItem.setFont(self.C_TIME, self.monoFont) - newItem.setFont(self.C_LENGTH, self.monoFont) - newItem.setFont(self.C_COUNT, self.monoFont) + newItem.setFont(self.C_TIME, self.theTheme.guiFontFixed) + newItem.setFont(self.C_LENGTH, self.theTheme.guiFontFixed) + newItem.setFont(self.C_COUNT, self.theTheme.guiFontFixed) self.listBox.addTopLevelItem(newItem) self.timeFilter += sDiff diff --git a/tests/test_common.py b/tests/test_common.py index 41a81091..4dc9cfcf 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -86,13 +86,13 @@ def testFormatTime(): @pytest.mark.core def testFormatInt(): assert formatInt(1000) == "1000" - assert formatInt(1234) == "1.23k" - assert formatInt(12345) == "12.3k" - assert formatInt(123456) == "123k" - assert formatInt(1234567) == "1.23M" - assert formatInt(12345678) == "12.3M" - assert formatInt(123456789) == "123M" - assert formatInt(1234567890) == "1.23G" + assert formatInt(1234) == "1.23\u2009k" + assert formatInt(12345) == "12.3\u2009k" + assert formatInt(123456) == "123\u2009k" + assert formatInt(1234567) == "1.23\u2009M" + assert formatInt(12345678) == "12.3\u2009M" + assert formatInt(123456789) == "123\u2009M" + assert formatInt(1234567890) == "1.23\u2009G" @pytest.mark.core def testTransferCase(): From 3b1c03329acd189c8375b1248f9208b10f13cbfc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Sep 2020 12:39:35 +0200 Subject: [PATCH 2/3] Fix a couple of issues with the project tree context menu where the new file/folder was not showing if the trash folder was None, and isArch was wrong for files in subfolders --- nw/gui/projtree.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 0c909a91..0a9c3905 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -985,23 +985,26 @@ class GuiProjectTreeMenu(QMenu): """Update item settings from the nwItem. """ 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 - inTrash = theItem.parHandle == trashHandle - isTrash = theItem.itemHandle == trashHandle + trashHandle = self.theTree.theProject.projTree.trashRoot() + + inTrash = theItem.parHandle == trashHandle and trashHandle is not None + isTrash = theItem.itemHandle == trashHandle and trashHandle is not None isFile = theItem.itemType == nwItemType.FILE - isArch = theItem.itemClass == nwItemClass.ARCHIVE + isArch = theRoot.itemClass == nwItemClass.ARCHIVE isOrph = isFile and theItem.parHandle is None showOpen = isFile showView = isFile showEdit = not isTrash and not isOrph - showExport = isFile and not inTrash and not isOrph - showNewFile = not isTrash and not inTrash and not isOrph and not isArch - showNewFolder = not isTrash and not inTrash and not isOrph + showExport = isFile + showNewFile = not (isTrash or inTrash or isOrph or isArch) + showNewFolder = not (isTrash or inTrash or isOrph) showDelete = not isTrash showEmpty = isTrash From 4c82a195afb4f15da3ec31ccbd236a1972bbc4d9 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 20 Sep 2020 15:23:11 +0200 Subject: [PATCH 3/3] Turn off codecov patch check again --- codecov.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/codecov.yml b/codecov.yml index 0a7e08aa..41da9cd2 100644 --- a/codecov.yml +++ b/codecov.yml @@ -10,9 +10,7 @@ coverage: project: default: threshold: 1% - patch: - default: - threshold: 1% + patch: no changes: no parsers: