Merge branch 'master' into gui_tweaks
This commit is contained in:
@@ -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 (
|
||||
@@ -66,10 +66,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)
|
||||
|
||||
@@ -104,7 +100,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("")
|
||||
@@ -117,7 +113,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("")
|
||||
@@ -181,8 +177,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)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
+2
-6
@@ -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)
|
||||
@@ -105,12 +101,12 @@ class GuiMainStatus(QStatusBar):
|
||||
self.addPermanentWidget(self.statsText)
|
||||
|
||||
## The Session Clock
|
||||
### Set the mimimum width so the label doesn't rescale every second
|
||||
self.timeIcon = QLabel()
|
||||
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.setMinimumWidth(self.theTheme.getTextWidth("00:00:00:"))
|
||||
self.timeIcon.setContentsMargins(0, 0, 0, 0)
|
||||
self.timeText.setContentsMargins(0, 0, 0, 0)
|
||||
self.addPermanentWidget(self.timeIcon)
|
||||
|
||||
@@ -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
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user