Remove monospace fonts from main GUI

This commit is contained in:
Veronica K. B. Olsen
2020-05-31 12:17:34 +02:00
parent e74b8ec6ce
commit 685af710a6
4 changed files with 20 additions and 22 deletions
+5 -9
View File
@@ -29,7 +29,7 @@ import logging
import nw
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont, QIcon, QPixmap, QFontMetrics
from PyQt5.QtGui import QFont, QIcon, QPixmap
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel
from nw.constants import (
@@ -65,10 +65,6 @@ class GuiDocDetails(QFrame):
self.fntLabel.setBold(True)
self.fntLabel.setPointSizeF(self.pS)
self.fntFixed = QFont()
self.fntFixed.setFamily("Monospace")
self.fntFixed.setPointSizeF(self.pS)
self.fntValue = QFont()
self.fntValue.setPointSizeF(self.pS)
@@ -103,7 +99,7 @@ class GuiDocDetails(QFrame):
self.className.setAlignment(Qt.AlignLeft)
self.classFlag = QLabel("")
self.classFlag.setFont(self.fntFixed)
self.classFlag.setFont(self.fntValue)
self.classFlag.setAlignment(Qt.AlignRight)
self.classData = QLabel("")
@@ -116,7 +112,7 @@ class GuiDocDetails(QFrame):
self.layoutName.setAlignment(Qt.AlignLeft)
self.layoutFlag = QLabel("")
self.layoutFlag.setFont(self.fntFixed)
self.layoutFlag.setFont(self.fntValue)
self.layoutFlag.setAlignment(Qt.AlignRight)
self.layoutData = QLabel("")
@@ -180,8 +176,8 @@ class GuiDocDetails(QFrame):
self.mainBox.setColumnStretch(4,0)
# Make sure the columns for flags and counts don't resize too often
flagWidth = QFontMetrics(self.fntFixed).boundingRect("Mm").width()
countWidth = QFontMetrics(self.fntValue).boundingRect("99,999").width()
flagWidth = self.theTheme.getTextWidth("Mm", self.fntValue)
countWidth = self.theTheme.getTextWidth("99,999", self.fntValue)
self.mainBox.setColumnMinimumWidth(1, flagWidth)
self.mainBox.setColumnMinimumWidth(4, countWidth)
-7
View File
@@ -99,10 +99,6 @@ class GuiDocTree(QTreeWidget):
self.resizeColumnToContents(self.C_EXPORT)
self.resizeColumnToContents(self.C_FLAGS)
self.fntFixed = QFont()
self.fntFixed.setFamily("Monospace")
self.fntFixed.setPointSizeF(0.9*self.theTheme.fontPointSize)
logger.debug("DocTree initialisation complete")
# Internal Mapping
@@ -582,10 +578,7 @@ class GuiDocTree(QTreeWidget):
newItem.setText(self.C_FLAGS, "")
newItem.setText(self.C_HANDLE, tHandle)
# newItem.setForeground(self.C_COUNT,QColor(*self.theParent.theTheme.treeWCount))
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
# newItem.setTextAlignment(self.C_EXPORT, Qt.AlignHCenter)
newItem.setFont(self.C_FLAGS, self.fntFixed)
self.theMap[tHandle] = newItem
if pHandle is None:
+1 -6
View File
@@ -57,10 +57,6 @@ class GuiMainStatus(QStatusBar):
self.projWords = 0
self.sessWords = 0
self.fntFixed = QFont()
self.fntFixed.setFamily("Monospace")
self.fntFixed.setPointSizeF(0.95*self.theTheme.fontPointSize)
colNone = QColor(*self.theTheme.statNone)
colTrue = QColor(*self.theTheme.statUnsaved)
colFalse = QColor(*self.theTheme.statSaved)
@@ -109,8 +105,7 @@ class GuiMainStatus(QStatusBar):
self.timeText = QLabel("")
self.timeIcon.setPixmap(self.theTheme.getPixmap("status_time", (iPx, iPx)))
self.timeText.setToolTip("Session Time")
self.timeText.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.timeText.setFont(self.fntFixed)
self.timeText.setFixedWidth(self.theTheme.getTextWidth("00:00:00."))
self.timeIcon.setContentsMargins(0, 0, 0, 0)
self.timeText.setContentsMargins(0, 0, 0, 0)
self.addPermanentWidget(self.timeIcon)
+14
View File
@@ -30,6 +30,7 @@ import configparser
import nw
from os import path, listdir
from math import ceil
from PyQt5.QtWidgets import qApp
from PyQt5.QtGui import (
@@ -141,6 +142,19 @@ class GuiTheme:
return
##
# Methods
##
def getTextWidth(self, theText, theFont=None):
"""Returns the width needed to contain a given piece of text.
"""
if isinstance(theFont, QFont):
qMetrics = QFontMetrics(theFont)
else:
qMetrics = QFontMetrics(self.guiFont)
return int(ceil(qMetrics.boundingRect(theText).width()))
##
# Actions
##