Draft: add font name dropdown to preferences (#20400)

Fixes #20330.
This commit is contained in:
Roy-043
2025-03-27 13:11:47 +01:00
committed by GitHub
parent 22b1f9b297
commit 51f4917c24
2 changed files with 47 additions and 18 deletions

View File

@@ -367,6 +367,29 @@ def _param_from_PrefFileChooser(widget):
return path, entry, ""
def _param_from_PrefFontBox(widget):
if App.GuiUp:
from PySide import QtGui
font = QtGui.QFont()
font.setStyleHint(QtGui.QFont.StyleHint.SansSerif)
value = font.defaultFamily()
else:
value = ""
for elem in list(widget):
if "name" in elem.keys():
att_name = elem.attrib["name"]
if att_name == "prefEntry":
entry = elem.find("cstring").text
elif att_name == "prefPath":
path = elem.find("cstring").text
# We must set the parameter if it does not exist, else
# the Gui::PrefFontBox will show the wrong value.
param_grp = App.ParamGet("User parameter:BaseApp/Preferences/" + path)
if entry not in param_grp.GetStrings():
param_grp.SetString(entry, value)
return path, entry, value
def _get_param_dictionary():
# print("Creating preferences dictionary...")
@@ -595,6 +618,9 @@ def _get_param_dictionary():
elif att_class == "Gui::PrefFileChooser":
path, entry, value = _param_from_PrefFileChooser(widget)
typ = "string"
elif att_class == "Gui::PrefFontBox":
path, entry, value = _param_from_PrefFontBox(widget)
typ = "string"
if path is not None:
if path in param_dict: