Merge branch 'main' into add-taskpanel-walloffset
This commit is contained in:
@@ -1,3 +1,27 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2025 FreeCAD Project Association *
|
||||
# * *
|
||||
# * This file is part of FreeCAD. *
|
||||
# * *
|
||||
# * FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
# * under the terms of the GNU Lesser General Public License as *
|
||||
# * published by the Free Software Foundation, either version 2.1 of the *
|
||||
# * License, or (at your option) any later version. *
|
||||
# * *
|
||||
# * FreeCAD is distributed in the hope that it will be useful, but *
|
||||
# * WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
# * Lesser General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Lesser General Public *
|
||||
# * License along with FreeCAD. If not, see *
|
||||
# * <https://www.gnu.org/licenses/>. *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
import FreeCAD as App
|
||||
|
||||
if App.GuiUp:
|
||||
@@ -34,9 +58,13 @@ if App.GuiUp:
|
||||
and use a task panel.
|
||||
"""
|
||||
if getattr(App, "activeDraftCommand", None) \
|
||||
and getattr(App.activeDraftCommand, "doc", None) == gui_doc.Document \
|
||||
and getattr(App.activeDraftCommand, "ui", None):
|
||||
if hasattr(App.activeDraftCommand.ui, "reject"):
|
||||
ToDo.delay(App.activeDraftCommand.ui.reject, None)
|
||||
elif hasattr(App.activeDraftCommand.ui, "escape"):
|
||||
ToDo.delay(App.activeDraftCommand.ui.escape, None)
|
||||
and getattr(App.activeDraftCommand, "doc", None) == gui_doc.Document:
|
||||
if hasattr(App.activeDraftCommand, "ui"):
|
||||
if hasattr(App.activeDraftCommand.ui, "reject"):
|
||||
ToDo.delay(App.activeDraftCommand.ui.reject, None)
|
||||
elif hasattr(App.activeDraftCommand.ui, "escape"):
|
||||
ToDo.delay(App.activeDraftCommand.ui.escape, None)
|
||||
elif hasattr(Gui, "Snapper") \
|
||||
and hasattr(Gui.Snapper, "ui") \
|
||||
and hasattr(Gui.Snapper.ui, "escape"):
|
||||
ToDo.delay(Gui.Snapper.ui.escape, None)
|
||||
|
||||
@@ -391,15 +391,44 @@ def _param_from_PrefFontBox(widget):
|
||||
return path, entry, value
|
||||
|
||||
|
||||
def _get_shape_string_font_file():
|
||||
"""Try to get the file name of a sans serif font (TTC or TTF) from the OS."""
|
||||
# https://forum.freecad.org/viewtopic.php?t=96770
|
||||
# Windows font: "arial"
|
||||
# Mac fonts: "geneva" and "helvetica"
|
||||
# Linux fonts: "dejavusans" and "freesans"
|
||||
favorite_names = ("arial", "geneva", "helvetica", "dejavusans", "freesans")
|
||||
font_file_sans = None # Font with name containing "sans". 1st fallback.
|
||||
font_file_alpha = None # Font with name starting with a letter. 2nd fallback.
|
||||
# Reverse the order of the paths so that user related paths come last:
|
||||
for path in QtCore.QStandardPaths.standardLocations(QtCore.QStandardPaths.FontsLocation)[::-1]:
|
||||
# We don't use os.path.join as dir_path has forward slashes even on Windows.
|
||||
for (dir_path, dir_names, file_names) in os.walk(path):
|
||||
for file_name in file_names:
|
||||
base_name, ext = [s.lower() for s in os.path.splitext(file_name)]
|
||||
if not ext in (".ttc", ".ttf"):
|
||||
continue
|
||||
if base_name in favorite_names:
|
||||
return dir_path + "/" + file_name
|
||||
if font_file_sans is None and "sans" in base_name:
|
||||
font_file_sans = dir_path + "/" + file_name
|
||||
if font_file_alpha is None and base_name[0].isalpha():
|
||||
font_file_alpha = dir_path + "/" + file_name
|
||||
if font_file_sans is not None:
|
||||
return font_file_sans
|
||||
if font_file_alpha is not None:
|
||||
return font_file_alpha
|
||||
return ""
|
||||
|
||||
|
||||
def _get_param_dictionary():
|
||||
|
||||
# print("Creating preferences dictionary...")
|
||||
|
||||
param_dict = {}
|
||||
|
||||
hatch_pattern_file = os.path.join(
|
||||
App.getResourceDir().replace("\\", "/"), "Mod/TechDraw/PAT/FCPAT.pat"
|
||||
)
|
||||
hatch_pattern_file = App.getResourceDir().replace("\\", "/").rstrip("/") \
|
||||
+ "/Mod/TechDraw/PAT/FCPAT.pat"
|
||||
|
||||
# Draft parameters that are not in the preferences:
|
||||
param_dict["Mod/Draft"] = {
|
||||
@@ -437,7 +466,7 @@ def _get_param_dictionary():
|
||||
"ScaleCopy": ("bool", False),
|
||||
"ScaleRelative": ("bool", False),
|
||||
"ScaleUniform": ("bool", False),
|
||||
"ShapeStringFontFile": ("string", ""),
|
||||
"ShapeStringFontFile": ("string", _get_shape_string_font_file()),
|
||||
"ShapeStringHeight": ("float", 10.0),
|
||||
"ShapeStringText": ("string", translate("draft", "Default")),
|
||||
"snapModes": ("string", "100000000000000"),
|
||||
|
||||
Reference in New Issue
Block a user