From b26ee7ae152d4727c32c59a2ce451fedd8fd5dff Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Mon, 1 Jun 2020 11:56:45 +0200
Subject: [PATCH 1/6] Fix project tree text font and size on some systems
---
nw/gui/elements/doctree.py | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/nw/gui/elements/doctree.py b/nw/gui/elements/doctree.py
index 62d5fd2f..2f4477af 100644
--- a/nw/gui/elements/doctree.py
+++ b/nw/gui/elements/doctree.py
@@ -52,7 +52,7 @@ class GuiDocTree(QTreeWidget):
def __init__(self, theParent, theProject):
QTreeWidget.__init__(self, theParent)
- logger.debug("Initialising DocTree ...")
+ logger.debug("Initialising GuiDocTree ...")
self.mainConf = nw.CONFIG
self.theParent = theParent
self.theTheme = theParent.theTheme
@@ -80,6 +80,14 @@ class GuiDocTree(QTreeWidget):
treeHead.setToolTip(self.C_EXPORT, "Include in build")
treeHead.setToolTip(self.C_FLAGS, "Status, class, and layout flags")
+ # Force the font to fix font sizing issues on some platforms
+ # like Ubuntu. This must also be set when the rows are added.
+ self.setFont(self.theTheme.guiFont)
+ treeHead.setFont(self.C_NAME, self.theTheme.guiFont)
+ treeHead.setFont(self.C_COUNT,self.theTheme.guiFont)
+ treeHead.setFont(self.C_EXPORT, self.theTheme.guiFont)
+ treeHead.setFont(self.C_FLAGS, self.theTheme.guiFont)
+
# Allow Move by Drag & Drop
self.setDragEnabled(True)
self.setDragDropMode(QAbstractItemView.InternalMove)
@@ -93,13 +101,14 @@ class GuiDocTree(QTreeWidget):
# self.setSelectionMode(QAbstractItemView.ExtendedSelection)
# self.setSelectionBehavior(QAbstractItemView.SelectRows)
+ # Get user's column width preferences for NAME and COUNT
for colN, colW in enumerate(self.mainConf.treeColWidth):
self.setColumnWidth(colN, colW)
self.resizeColumnToContents(self.C_EXPORT)
self.resizeColumnToContents(self.C_FLAGS)
- logger.debug("DocTree initialisation complete")
+ logger.debug("GuiDocTree initialisation complete")
# Internal Mapping
self.makeAlert = self.theParent.makeAlert
@@ -114,7 +123,7 @@ class GuiDocTree(QTreeWidget):
"""Clear the GUI content and the related maps.
"""
self.clear()
- self.theMap = {}
+ self.theMap = {}
self.orphRoot = None
return
@@ -578,7 +587,14 @@ class GuiDocTree(QTreeWidget):
newItem.setText(self.C_FLAGS, "")
newItem.setText(self.C_HANDLE, tHandle)
- newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
+ newItem.setTextAlignment(self.C_NAME, Qt.AlignLeft | Qt.AlignVCenter)
+ newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight | Qt.AlignVCenter)
+ newItem.setTextAlignment(self.C_EXPORT, Qt.AlignLeft | Qt.AlignVCenter)
+ newItem.setTextAlignment(self.C_FLAGS, Qt.AlignLeft | Qt.AlignVCenter)
+
+ newItem.setFont(self.C_NAME, self.theTheme.guiFont)
+ newItem.setFont(self.C_COUNT, self.theTheme.guiFont)
+ newItem.setFont(self.C_FLAGS, self.theTheme.guiFont)
self.theMap[tHandle] = newItem
if pHandle is None:
From 4464171cb4b5c77ad91d78796a27f99b6256366d Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Mon, 1 Jun 2020 12:10:07 +0200
Subject: [PATCH 2/6] ... and the same for outline tree
---
nw/gui/elements/outline.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/nw/gui/elements/outline.py b/nw/gui/elements/outline.py
index 7c196d2e..982f21c9 100644
--- a/nw/gui/elements/outline.py
+++ b/nw/gui/elements/outline.py
@@ -89,8 +89,9 @@ class GuiProjectOutline(QTreeWidget):
self.mainConf = nw.CONFIG
self.theParent = theParent
self.theProject = theProject
- self.theIndex = self.theParent.theIndex
- self.optState = self.theProject.optState
+ self.theTheme = theParent.theTheme
+ self.theIndex = theParent.theIndex
+ self.optState = theProject.optState
self.headerMenu = GuiOutlineHeaderMenu(self)
self.firstView = True
@@ -337,6 +338,8 @@ class GuiProjectOutline(QTreeWidget):
headItem.setTextAlignment(self.colIndex[nwOutline.CCOUNT], Qt.AlignRight)
headItem.setTextAlignment(self.colIndex[nwOutline.WCOUNT], Qt.AlignRight)
headItem.setTextAlignment(self.colIndex[nwOutline.PCOUNT], Qt.AlignRight)
+ for hItem in self.treeOrder:
+ headItem.setFont(self.colIndex[hItem], self.theTheme.guiFont)
currTitle = None
currChapter = None
@@ -427,6 +430,9 @@ class GuiProjectOutline(QTreeWidget):
newItem.setText(self.colIndex[nwOutline.ENTITY], ", ".join(theRefs[nwKeyWords.ENTITY_KEY]))
newItem.setText(self.colIndex[nwOutline.CUSTOM], ", ".join(theRefs[nwKeyWords.CUSTOM_KEY]))
+ for i in self.treeOrder:
+ newItem.setFont(self.colIndex[i], self.theTheme.guiFont)
+
return newItem
# END Class GuiProjectOutline
From ca5a6ad8aa6ad2667dc43f9416e051e5bb8e189b Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Mon, 1 Jun 2020 12:17:07 +0200
Subject: [PATCH 3/6] All trewwidgets needs font set ...
---
nw/gui/dialogs/projectload.py | 14 +++++++++++---
nw/gui/dialogs/projectsettings.py | 6 ++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/nw/gui/dialogs/projectload.py b/nw/gui/dialogs/projectload.py
index f5513ea0..9f8494fe 100644
--- a/nw/gui/dialogs/projectload.py
+++ b/nw/gui/dialogs/projectload.py
@@ -57,6 +57,7 @@ class GuiProjectLoad(QDialog):
self.mainConf = nw.CONFIG
self.theParent = theParent
+ self.theTheme = theParent.theTheme
self.openState = self.NONE_STATE
self.openPath = None
@@ -70,7 +71,7 @@ class GuiProjectLoad(QDialog):
self.setMinimumHeight(400)
self.setModal(True)
- self.guiDeco = self.theParent.theTheme.loadDecoration("nwicon", (96, 96))
+ self.guiDeco = self.theTheme.loadDecoration("nwicon", (96, 96))
self.innerBox.addWidget(self.guiDeco, 0, Qt.AlignTop)
self.projectForm = QGridLayout()
@@ -89,6 +90,9 @@ class GuiProjectLoad(QDialog):
treeHead = self.listBox.headerItem()
treeHead.setTextAlignment(1, Qt.AlignRight)
treeHead.setTextAlignment(2, Qt.AlignRight)
+ treeHead.setFont(0, self.theTheme.guiFont)
+ treeHead.setFont(1, self.theTheme.guiFont)
+ treeHead.setFont(2, self.theTheme.guiFont)
self.lblRecent = QLabel("Recently Opened Projects")
self.lblPath = QLabel("Path")
@@ -251,8 +255,12 @@ class GuiProjectLoad(QDialog):
newItem.setText(1, formatInt(listData[timeStamp][1]))
newItem.setText(2, datetime.fromtimestamp(timeStamp).strftime("%x %X"))
newItem.setText(3, listData[timeStamp][2])
- newItem.setTextAlignment(1, Qt.AlignRight)
- newItem.setTextAlignment(2, Qt.AlignRight)
+ newItem.setTextAlignment(0, Qt.AlignLeft | Qt.AlignVCenter)
+ newItem.setTextAlignment(1, Qt.AlignRight | Qt.AlignVCenter)
+ newItem.setTextAlignment(2, Qt.AlignRight | Qt.AlignVCenter)
+ newItem.setFont(0, self.theTheme.guiFont)
+ newItem.setFont(1, self.theTheme.guiFont)
+ newItem.setFont(2, self.theTheme.guiFont)
self.listBox.addTopLevelItem(newItem)
if not hasSelection:
newItem.setSelected(True)
diff --git a/nw/gui/dialogs/projectsettings.py b/nw/gui/dialogs/projectsettings.py
index a49193d1..96b63448 100644
--- a/nw/gui/dialogs/projectsettings.py
+++ b/nw/gui/dialogs/projectsettings.py
@@ -450,6 +450,10 @@ class GuiProjectEditReplace(QWidget):
self.listBox.itemSelectionChanged.connect(self._selectedItem)
self.listBox.setIndentation(0)
+ treeHead = self.listBox.headerItem()
+ treeHead.setFont(0, self.theTheme.guiFont)
+ treeHead.setFont(1, self.theTheme.guiFont)
+
for aKey, aVal in self.theProject.autoReplace.items():
newItem = QTreeWidgetItem(["<%s>" % aKey, aVal])
self.listBox.addTopLevelItem(newItem)
@@ -542,6 +546,8 @@ class GuiProjectEditReplace(QWidget):
saveKey = "" % (self.listBox.topLevelItemCount() + 1)
newVal = ""
newItem = QTreeWidgetItem([saveKey, newVal])
+ newItem.setFont(0, self.theTheme.guiFont)
+ newItem.setFont(1, self.theTheme.guiFont)
self.listBox.addTopLevelItem(newItem)
return True
From d59a164d25409ac87647a286893fd5c66955bc10 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Mon, 1 Jun 2020 12:19:18 +0200
Subject: [PATCH 4/6] Missed a spot ...
---
nw/gui/dialogs/projectsettings.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/nw/gui/dialogs/projectsettings.py b/nw/gui/dialogs/projectsettings.py
index 96b63448..66af994a 100644
--- a/nw/gui/dialogs/projectsettings.py
+++ b/nw/gui/dialogs/projectsettings.py
@@ -456,6 +456,8 @@ class GuiProjectEditReplace(QWidget):
for aKey, aVal in self.theProject.autoReplace.items():
newItem = QTreeWidgetItem(["<%s>" % aKey, aVal])
+ newItem.setFont(0, self.theTheme.guiFont)
+ newItem.setFont(1, self.theTheme.guiFont)
self.listBox.addTopLevelItem(newItem)
self.listBox.sortByColumn(0, Qt.AscendingOrder)
From b50125172bf57b6bd6ea53511892626602d6b0cc Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Mon, 1 Jun 2020 12:23:41 +0200
Subject: [PATCH 5/6] Also scale the icons
---
nw/gui/dialogs/projectload.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/nw/gui/dialogs/projectload.py b/nw/gui/dialogs/projectload.py
index 9f8494fe..99c2eaa3 100644
--- a/nw/gui/dialogs/projectload.py
+++ b/nw/gui/dialogs/projectload.py
@@ -31,7 +31,7 @@ import nw
from os import path
from datetime import datetime
-from PyQt5.QtCore import Qt
+from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QKeySequence
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QGridLayout, QPushButton, QTreeWidget,
@@ -77,6 +77,7 @@ class GuiProjectLoad(QDialog):
self.projectForm = QGridLayout()
self.projectForm.setContentsMargins(0, 0, 0, 0)
+ iPx = self.theTheme.textIconSize
self.listBox = QTreeWidget()
self.listBox.setSelectionMode(QAbstractItemView.SingleSelection)
self.listBox.setDragDropMode(QAbstractItemView.NoDragDrop)
@@ -86,6 +87,7 @@ class GuiProjectLoad(QDialog):
self.listBox.setColumnHidden(3, True)
self.listBox.itemSelectionChanged.connect(self._doSelectRecent)
self.listBox.itemDoubleClicked.connect(self._doOpenRecent)
+ self.listBox.setIconSize(QSize(iPx, iPx))
treeHead = self.listBox.headerItem()
treeHead.setTextAlignment(1, Qt.AlignRight)
From 16d1357c73a81aac04025b6d961fa1f74542b1d5 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Mon, 1 Jun 2020 12:28:31 +0200
Subject: [PATCH 6/6] Also scale '...' buttons
---
nw/gui/build.py | 2 +-
nw/gui/dialogs/preferences.py | 4 ++--
nw/gui/dialogs/projectload.py | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/nw/gui/build.py b/nw/gui/build.py
index 3c2e73da..72df5920 100644
--- a/nw/gui/build.py
+++ b/nw/gui/build.py
@@ -181,7 +181,7 @@ class GuiBuildNovel(QDialog):
self.optState.getString("GuiBuildNovel", "textFont", self.mainConf.textFont)
)
self.fontButton = QPushButton("...")
- self.fontButton.setMaximumWidth(30)
+ self.fontButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("...")))
self.fontButton.clicked.connect(self._selectFont)
self.textSize = QSpinBox(self)
diff --git a/nw/gui/dialogs/preferences.py b/nw/gui/dialogs/preferences.py
index be45b396..35abd6b3 100644
--- a/nw/gui/dialogs/preferences.py
+++ b/nw/gui/dialogs/preferences.py
@@ -188,7 +188,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.guiFont.setFixedWidth(162)
self.guiFont.setText(self.mainConf.guiFont)
self.fontButton = QPushButton("...")
- self.fontButton.setMaximumWidth(30)
+ self.fontButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("...")))
self.fontButton.clicked.connect(self._selectFont)
self.mainForm.addRow(
"Font family",
@@ -393,7 +393,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.textStyleFont.setFixedWidth(162)
self.textStyleFont.setText(self.mainConf.textFont)
self.fontButton = QPushButton("...")
- self.fontButton.setMaximumWidth(30)
+ self.fontButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("...")))
self.fontButton.clicked.connect(self._selectFont)
self.mainForm.addRow(
"Font family",
diff --git a/nw/gui/dialogs/projectload.py b/nw/gui/dialogs/projectload.py
index 99c2eaa3..63f0be9f 100644
--- a/nw/gui/dialogs/projectload.py
+++ b/nw/gui/dialogs/projectload.py
@@ -102,7 +102,7 @@ class GuiProjectLoad(QDialog):
self.selPath.setReadOnly(True)
self.browseButton = QPushButton("...")
- self.browseButton.setMaximumWidth(30)
+ self.browseButton.setMaximumWidth(int(2.5*self.theTheme.getTextWidth("...")))
self.browseButton.clicked.connect(self._doBrowse)
self.projectForm.addWidget(self.lblRecent, 0, 0, 1, 3)