Update font description and add native font dialog setting to config
This commit is contained in:
@@ -405,7 +405,9 @@ def describeFont(font: QFont) -> str:
|
||||
"""Describe a font in a way that can be displayed on the GUI."""
|
||||
if isinstance(font, QFont):
|
||||
info = QFontInfo(font)
|
||||
return f"{font.family()} {info.styleName()} @ {font.pointSize()} pt"
|
||||
family = info.family()
|
||||
styles = [v for v in info.styleName().split() if v not in family]
|
||||
return " ".join([f"{info.pointSize()} pt", family] + styles)
|
||||
return "Error"
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ class Config:
|
||||
self.hideVScroll = False # Hide vertical scroll bars on main widgets
|
||||
self.hideHScroll = False # Hide horizontal scroll bars on main widgets
|
||||
self.lastNotes = "0x0" # The latest release notes that have been shown
|
||||
self.nativeFont = False # Use native font dialog
|
||||
self.nativeFont = True # Use native font dialog
|
||||
|
||||
# Size Settings
|
||||
self._mainWinSize = [1200, 650] # Last size of the main GUI window
|
||||
@@ -599,6 +599,7 @@ class Config:
|
||||
self.hideVScroll = conf.rdBool(sec, "hidevscroll", self.hideVScroll)
|
||||
self.hideHScroll = conf.rdBool(sec, "hidehscroll", self.hideHScroll)
|
||||
self.lastNotes = conf.rdStr(sec, "lastnotes", self.lastNotes)
|
||||
self.nativeFont = conf.rdBool(sec, "nativefont", self.nativeFont)
|
||||
self._lastPath = conf.rdPath(sec, "lastpath", self._lastPath)
|
||||
|
||||
# Sizes
|
||||
@@ -708,6 +709,7 @@ class Config:
|
||||
"hidevscroll": str(self.hideVScroll),
|
||||
"hidehscroll": str(self.hideHScroll),
|
||||
"lastnotes": str(self.lastNotes),
|
||||
"nativefont": str(self.nativeFont),
|
||||
"lastpath": str(self._lastPath),
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ localisation = en_GB
|
||||
hidevscroll = False
|
||||
hidehscroll = False
|
||||
lastnotes = 0x0
|
||||
nativefont = True
|
||||
lastpath =
|
||||
|
||||
[Sizes]
|
||||
|
||||
@@ -492,7 +492,8 @@ def testBaseCommon_describeFont():
|
||||
"""Test the describeFont function."""
|
||||
fontDB = QFontDatabase()
|
||||
font = fontDB.systemFont(QFontDatabase.SystemFont.GeneralFont)
|
||||
assert font.family() in describeFont(font)
|
||||
font.setPointSize(12)
|
||||
assert describeFont(font).startswith("12 pt")
|
||||
assert describeFont(None) == "Error" # type: ignore
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user