From faef0c6f27b3658dc18c5c69ee91ba25047a357c Mon Sep 17 00:00:00 2001 From: luzpaz Date: Thu, 30 Nov 2023 12:51:10 +0000 Subject: [PATCH 1/7] Fix various typos --- src/Gui/ApplicationPy.cpp | 2 +- src/Gui/CommandDoc.cpp | 2 +- src/Mod/AddonManager/NetworkManager.py | 2 +- src/Mod/PartDesign/App/ShapeBinder.cpp | 2 +- src/Mod/TechDraw/Gui/QGIRichAnno.cpp | 2 +- src/Mod/TechDraw/Gui/TaskRichAnno.cpp | 2 +- tests/src/Gui/QuantitySpinBox.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index bcb4437d1873..f49ac86d8a06 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -547,7 +547,7 @@ PyObject* Application::sGetDocument(PyObject * /*self*/, PyObject *args) return pcDoc->getPyObject(); } - PyErr_SetString(PyExc_TypeError, "Either string or App.Document exprected"); + PyErr_SetString(PyExc_TypeError, "Either string or App.Document expected"); return nullptr; } diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index cce02a49f7de..2d99fccf1192 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1286,7 +1286,7 @@ StdCmdSelectAll::StdCmdSelectAll() sWhatsThis = "Std_SelectAll"; sStatusTip = QT_TR_NOOP("Select all"); sPixmap = "edit-select-all"; - //sAccel = "Ctrl+A"; // superseeds shortcuts for text edits + //sAccel = "Ctrl+A"; // supersedes shortcuts for text edits } void StdCmdSelectAll::activated(int iMsg) diff --git a/src/Mod/AddonManager/NetworkManager.py b/src/Mod/AddonManager/NetworkManager.py index c869f73d6474..8c7a47551294 100644 --- a/src/Mod/AddonManager/NetworkManager.py +++ b/src/Mod/AddonManager/NetworkManager.py @@ -174,7 +174,7 @@ def __init__(self): def _setup_proxy(self): """Set up the proxy based on user preferences or prompts on command line""" - # Set up the proxy, if necesssary: + # Set up the proxy, if necessary: if HAVE_FREECAD: ( noProxyCheck, diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 1339f3650b3c..b1473a6bcda5 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -891,7 +891,7 @@ void SubShapeBinder::checkPropertyStatus() { // Make Shape transient can reduce some file size, and maybe reduce file // loading time as well. But there maybe complication arise when doing - // TopoShape version upgrade. So we DO NOT set trasient at the moment. + // TopoShape version upgrade. So we DO NOT set transient at the moment. // // Shape.setStatus(App::Property::Transient, !PartialLoad.getValue() && BindMode.getValue()==0); } diff --git a/src/Mod/TechDraw/Gui/QGIRichAnno.cpp b/src/Mod/TechDraw/Gui/QGIRichAnno.cpp index 01ca2965efbc..77c698f2869b 100644 --- a/src/Mod/TechDraw/Gui/QGIRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/QGIRichAnno.cpp @@ -243,7 +243,7 @@ QString QGIRichAnno::convertTextSizes(const QString& inHtml) const QStringList findList; QStringList replList; - // find each occurence of "font-size:..." and calculate the equivalent size in scene units + // find each occurrence of "font-size:..." and calculate the equivalent size in scene units // or CSS pixels int pos = 0; while ((pos = inHtml.indexOf(rxFontSize, pos, &match)) != -1) { diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp index d1f5d752d762..73ea6e48e37b 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp @@ -310,7 +310,7 @@ void TaskRichAnno::createAnnoFeature() m_annoFeat->X.setValue(Rez::appX(vTemp.x)); m_annoFeat->Y.setValue(Rez::appX(vTemp.y)); } else { - //if we don't have a base featrue, we can't calculate start position, so just put it mid-page + //if we don't have a base feature, we can't calculate start position, so just put it mid-page m_annoFeat->X.setValue(m_basePage->getPageWidth()/2.0); m_annoFeat->Y.setValue(m_basePage->getPageHeight()/2.0); } diff --git a/tests/src/Gui/QuantitySpinBox.cpp b/tests/src/Gui/QuantitySpinBox.cpp index 4e12f731e737..b1af5a5a3f26 100644 --- a/tests/src/Gui/QuantitySpinBox.cpp +++ b/tests/src/Gui/QuantitySpinBox.cpp @@ -59,7 +59,7 @@ private Q_SLOTS: auto val1 = qsb->value(); QCOMPARE(val1.getFormat().precision, 7); - // format shoudn't change after setting a double + // format shouldn't change after setting a double qsb->setValue(3.5); auto val2 = qsb->value(); QCOMPARE(val2.getFormat().precision, 7); From 391d08e6d54b37e1d6e03bb354b747ba72082ce0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 30 Nov 2023 14:03:26 +0100 Subject: [PATCH 2/7] Gui: simplify Application::sGetMarkerIndex --- src/Gui/ApplicationPy.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index f49ac86d8a06..781ec22848ee 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -1427,7 +1427,7 @@ PyObject* Application::sCreateViewer(PyObject * /*self*/, PyObject *args) PyObject* Application::sGetMarkerIndex(PyObject * /*self*/, PyObject *args) { - char *pstr; + char *pstr {}; int defSize = 9; if (!PyArg_ParseTuple(args, "s|i", &pstr, &defSize)) return nullptr; @@ -1449,18 +1449,12 @@ PyObject* Application::sGetMarkerIndex(PyObject * /*self*/, PyObject *args) {"default", "CIRCLE_FILLED"} }; - std::list>::iterator markerStyle; - - for (markerStyle = markerList.begin(); markerStyle != markerList.end(); ++markerStyle) - { - if (marker_arg == (*markerStyle).first || marker_arg == (*markerStyle).second) - break; - } + auto findIt = std::find_if(markerList.begin(), markerList.end(), [&marker_arg](const auto& it) { + return marker_arg == it.first || marker_arg == it.second; + }); - marker_arg = "CIRCLE_FILLED"; + marker_arg = (findIt != markerList.end() ? findIt->second : "CIRCLE_FILLED"); - if (markerStyle != markerList.end()) - marker_arg = (*markerStyle).second; //get the marker size auto sizeList = Gui::Inventor::MarkerBitmaps::getSupportedSizes(marker_arg); From 92d69c9641535e269aad1b7996aa8c0728d437a6 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Thu, 30 Nov 2023 21:19:25 +0100 Subject: [PATCH 3/7] Draft: update Draft_SetStyle * Added handling of DefaultShapeVertexColor, DefaultShapePointSize, DefaultAnnoLineColor and DefaultAnnoLineWidth preferences. * Rearranged the task panel. Additionally the DefaultDrawStyle and DefaultDisplayMode preferences are now applied by format_object in gui_utils.py. --- .../Draft/Resources/ui/TaskPanel_SetStyle.ui | 343 ++++++++++-------- src/Mod/Draft/draftguitools/gui_setstyle.py | 341 +++++++++-------- src/Mod/Draft/draftutils/gui_utils.py | 20 +- src/Mod/Draft/draftutils/utils.py | 1 + 4 files changed, 389 insertions(+), 316 deletions(-) diff --git a/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui b/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui index ec0ca1d09105..8cd841628121 100644 --- a/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui +++ b/src/Mod/Draft/Resources/ui/TaskPanel_SetStyle.ui @@ -19,7 +19,7 @@ - Fills the values below with a stored style preset + Fill the values below from a stored style preset @@ -37,7 +37,7 @@ - Save current style as a preset... + Save the current style as a preset... @@ -53,52 +53,99 @@ - Lines and faces + Shapes QLayout::SetDefaultConstraint - + - Line color + Shape color - - - The color of lines - + - + - Line width + Transparency + + + % + + + 100 + + + + + + + Line color + + + + + + + + + + + Line width + + + + px - - + + + + Point color + + + + + + + + + + + Point size + + + + + + + px + + + + + Draw style - + - - The line style - Solid @@ -121,18 +168,15 @@ - - + + Display mode - + - - The display mode for faces - Flat Lines @@ -140,12 +184,12 @@ - Wireframe + Shaded - Shaded + Wireframe @@ -155,40 +199,6 @@ - - - - Shape color - - - - - - - The color of faces - - - - - - - Transparency - - - - - - - The transparency of faces - - - % - - - 100 - - - @@ -197,69 +207,69 @@ Annotations - - - - - The size of texts and dimension texts - - - + + + + + Text color - + - The color of texts and dimension texts + The color for texts, dimension texts and label texts - - + + - Text font + Font name - - - - Text size + + + + + 0 + 0 + + + + The font for texts, dimensions and labels - - + + - Line spacing + Font size - - - - Text color + + + + The height for texts, dimension texts and label texts + + + - - - - - 0 - 0 - - - - The font to use for texts and dimensions + + + + Line spacing - + - The spacing between different lines of text + The line spacing for multi-line texts and labels (relative to the font size) @@ -271,29 +281,41 @@ Dimensions - + - + - Arrow style + Line and arrow color - - - - The space between the text and the dimension line + + + + + + + + Line width - - + + + + + + px - - - - The type of dimension arrows + + + + Arrow type + + + + Dot @@ -321,112 +343,119 @@ - - + + - Ext lines + Arrow size - + - - The size of dimension arrows - - + + + + Show unit + + + + - If the unit suffix is shown on dimension texts or not - - - Qt::RightToLeft + If checked, a unit symbol is added to dimension texts - - + + - Text spacing + Unit override - + - The distance the dimension line is extended past the extension lines - - - + The unit override for dimensions. Leave blank to use the current FreeCAD unit. - - - - Arrow size - - - - - + + Dim overshoot - - + + - Length of the extension lines beyond the dimension line + The distance the dimension line is extended past the extension lines - + + + + Ext lines + + + + - Length of the extension lines + The length of extension lines. Use 0 for full extension lines. A negative value +defines the gap between the ends of the extension lines and the measured points. +A positive value defines the maximum length of the extension lines. Only used +for linear dimensions. - - + + - Show unit + Ext overshoot - - - - Ext overshoot + + + + The length of extension lines above the dimension line + + + - - + + - Unit override + Text spacing - - + + - The unit to use for dimensions. Leave blank to use current FreeCAD unit + The space between the dimension line and the dimension text + + + @@ -438,7 +467,7 @@ - Apply above style to selected object(s) + Apply the above style to selected object(s) Selected @@ -452,7 +481,7 @@ - Apply above style to all annotations (texts, dimensions and labels) + Apply the above style to all annotations (texts, dimensions and labels) Annotations diff --git a/src/Mod/Draft/draftguitools/gui_setstyle.py b/src/Mod/Draft/draftguitools/gui_setstyle.py index 91cc61d9913a..241034e0ed5c 100644 --- a/src/Mod/Draft/draftguitools/gui_setstyle.py +++ b/src/Mod/Draft/draftguitools/gui_setstyle.py @@ -28,22 +28,26 @@ ## \addtogroup draftguitools # @{ -import FreeCAD +from PySide import QtCore +from PySide import QtGui + +import FreeCAD as App +import FreeCADGui as Gui +import Draft_rc import os -import draftutils.utils as utils -if FreeCAD.GuiUp: - import FreeCADGui - import Draft_rc +from FreeCAD import Units as U +from draftutils import utils + def QT_TRANSLATE_NOOP(ctx,txt): return txt -translate = FreeCAD.Qt.translate +translate = App.Qt.translate __title__ = "FreeCAD Draft Workbench GUI Tools - Styling tools" __author__ = ("Yorik van Havre") __url__ = "https://www.freecad.org" -PRESETPATH = os.path.join(FreeCAD.getUserAppDataDir(),"Draft","StylePresets.json") +PRESETPATH = os.path.join(App.getUserAppDataDir(), "Draft", "StylePresets.json") class Draft_SetStyle: @@ -52,16 +56,16 @@ class Draft_SetStyle: def GetResources(self): - d = {'Pixmap': 'Draft_Apply', - 'Accel': "S, S", - 'MenuText': QT_TRANSLATE_NOOP("Draft_SetStyle", "Set style"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_SetStyle", "Sets default styles")} - return d + return { + "Pixmap": "Draft_Apply", + "Accel": "S, S", + "MenuText": QT_TRANSLATE_NOOP("Draft_SetStyle", "Set style"), + "ToolTip": QT_TRANSLATE_NOOP("Draft_SetStyle", "Sets default styles") + } def Activated(self): - FreeCADGui.Control.showDialog(Draft_SetStyle_TaskPanel()) - + Gui.Control.showDialog(Draft_SetStyle_TaskPanel()) class Draft_SetStyle_TaskPanel: @@ -70,35 +74,45 @@ class Draft_SetStyle_TaskPanel: def __init__(self): - from PySide import QtCore,QtGui self.p = "User parameter:BaseApp/Preferences/" - self.form = FreeCADGui.PySideUic.loadUi(":/ui/TaskPanel_SetStyle.ui") + param_draft = App.ParamGet(self.p + "Mod/Draft") + param_view = App.ParamGet(self.p + "View") + + self.form = Gui.PySideUic.loadUi(":/ui/TaskPanel_SetStyle.ui") self.form.setWindowIcon(QtGui.QIcon.fromTheme("gtk-apply", QtGui.QIcon(":/icons/Draft_Apply.svg"))) + + self.form.saveButton.setIcon(QtGui.QIcon.fromTheme("gtk-save", QtGui.QIcon(":/icons/document-save.svg"))) self.form.applyButton.setIcon(QtGui.QIcon.fromTheme("gtk-apply", QtGui.QIcon(":/icons/Draft_Apply.svg"))) self.form.annotButton.setIcon(QtGui.QIcon(":/icons/Draft_Text.svg")) - self.form.LineColor.setProperty("color",self.getPrefColor("View","DefaultShapeLineColor",255)) - self.form.LineWidth.setValue(FreeCAD.ParamGet(self.p+"View").GetInt("DefaultShapeLineWidth",2)) - self.form.DrawStyle.setCurrentIndex(FreeCAD.ParamGet(self.p+"Mod/Draft").GetInt("DefaultDrawStyle",0)) - self.form.DisplayMode.setCurrentIndex(FreeCAD.ParamGet(self.p+"Mod/Draft").GetInt("DefaultDisplayMode",0)) - self.form.ShapeColor.setProperty("color",self.getPrefColor("View","DefaultShapeColor",4294967295)) - self.form.Transparency.setValue(FreeCAD.ParamGet(self.p+"View").GetInt("DefaultShapeTransparency",0)) - self.form.TextFont.setCurrentFont(QtGui.QFont(FreeCAD.ParamGet(self.p+"Mod/Draft").GetString("textfont","Sans"))) - self.form.TextSize.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("textheight",10),FreeCAD.Units.Length).UserString) - self.form.TextColor.setProperty("color",self.getPrefColor("Mod/Draft","DefaultTextColor",255)) - self.form.ArrowStyle.setCurrentIndex(FreeCAD.ParamGet(self.p+"Mod/Draft").GetInt("dimsymbol",0)) - self.form.ArrowSize.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("arrowsize",5),FreeCAD.Units.Length).UserString) - self.form.ShowUnit.setChecked(FreeCAD.ParamGet(self.p+"Mod/Draft").GetBool("showUnit",True)) - self.form.UnitOverride.setText(FreeCAD.ParamGet(self.p+"Mod/Draft").GetString("overrideUnit","")) - self.form.saveButton.setIcon(QtGui.QIcon.fromTheme("gtk-save", QtGui.QIcon(":/icons/document-save.svg"))) - self.form.TextSpacing.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("dimspacing",1),FreeCAD.Units.Length).UserString) - self.form.LineSpacing.setValue(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("LineSpacing",1)) - self.form.DimOvershoot.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("dimovershoot",0),FreeCAD.Units.Length).UserString) - self.form.ExtLines.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("extlines",0),FreeCAD.Units.Length).UserString) - self.form.ExtOvershoot.setText(FreeCAD.Units.Quantity(FreeCAD.ParamGet(self.p+"Mod/Draft").GetFloat("extovershoot",0),FreeCAD.Units.Length).UserString) + + self.form.ShapeColor.setProperty("color", self.getColor(param_view.GetUnsigned("DefaultShapeColor", 3435973887))) + self.form.Transparency.setValue(param_view.GetInt("DefaultShapeTransparency", 0)) + self.form.LineColor.setProperty("color", self.getColor(param_view.GetUnsigned("DefaultShapeLineColor", 255))) + self.form.LineWidth.setValue(param_view.GetInt("DefaultShapeLineWidth", 2)) + self.form.PointColor.setProperty("color", self.getColor(param_view.GetUnsigned("DefaultShapeVertexColor", 255))) + self.form.PointSize.setValue(param_view.GetInt("DefaultShapePointSize", 2)) + self.form.DrawStyle.setCurrentIndex(param_draft.GetInt("DefaultDrawStyle", 0)) + self.form.DisplayMode.setCurrentIndex(param_draft.GetInt("DefaultDisplayMode", 0)) + self.form.TextColor.setProperty("color", self.getColor(param_draft.GetUnsigned("DefaultTextColor", 255))) + self.form.TextFont.setCurrentFont(QtGui.QFont(param_draft.GetString("textfont", "Sans"))) + self.form.TextSize.setText(U.Quantity(param_draft.GetFloat("textheight", 3.5), U.Length).UserString) + self.form.LineSpacing.setValue(param_draft.GetFloat("LineSpacing", 1)) + self.form.AnnoLineColor.setProperty("color", self.getColor(param_draft.GetUnsigned("DefaultAnnoLineColor", 255))) + self.form.AnnoLineWidth.setValue(param_draft.GetInt("DefaultAnnoLineWidth", 2)) + self.form.ArrowStyle.setCurrentIndex(param_draft.GetInt("dimsymbol", 0)) + self.form.ArrowSize.setText(U.Quantity(param_draft.GetFloat("arrowsize", 1), U.Length).UserString) + self.form.ShowUnit.setChecked(param_draft.GetBool("showUnit", True)) + self.form.UnitOverride.setText(param_draft.GetString("overrideUnit", "")) + self.form.DimOvershoot.setText(U.Quantity(param_draft.GetFloat("dimovershoot", 0), U.Length).UserString) + self.form.ExtLines.setText(U.Quantity(param_draft.GetFloat("extlines", -0.5), U.Length).UserString) + self.form.ExtOvershoot.setText(U.Quantity(param_draft.GetFloat("extovershoot", 2), U.Length).UserString) + self.form.TextSpacing.setText(U.Quantity(param_draft.GetFloat("dimspacing", 1), U.Length).UserString) + self.form.saveButton.clicked.connect(self.onSaveStyle) self.form.applyButton.clicked.connect(self.onApplyStyle) self.form.annotButton.clicked.connect(self.onApplyAnnot) self.form.comboPresets.currentIndexChanged.connect(self.onLoadStyle) + self.loadDefaults() def loadDefaults(self): @@ -111,106 +125,115 @@ def loadDefaults(self): self.form.comboPresets.addItems(presets) current = self.getValues() for name, preset in pdict.items(): - if all(item in current.items() for item in preset.items()): #if preset == current: + if all(item in current.items() for item in preset.items()): # if preset == current: self.form.comboPresets.setCurrentIndex(1 + (pdict_keys.index(name))) break - def getPrefColor(self,group,prop,default): + def getColor(self, c): - c = FreeCAD.ParamGet(self.p+group).GetUnsigned(prop,default) - return self.getColor(c) - - def getColor(self,c): - - from PySide import QtGui return QtGui.QColor(utils.rgba_to_argb(c)) def getValues(self): preset = {} + preset["ShapeColor"] = utils.argb_to_rgba(self.form.ShapeColor.property("color").rgba()) + preset["Transparency"] = self.form.Transparency.value() preset["LineColor"] = utils.argb_to_rgba(self.form.LineColor.property("color").rgba()) preset["LineWidth"] = self.form.LineWidth.value() + preset["PointColor"] = utils.argb_to_rgba(self.form.PointColor.property("color").rgba()) + preset["PointSize"] = self.form.PointSize.value() preset["DrawStyle"] = self.form.DrawStyle.currentIndex() preset["DisplayMode"] = self.form.DisplayMode.currentIndex() - preset["ShapeColor"] = utils.argb_to_rgba(self.form.ShapeColor.property("color").rgba()) - preset["Transparency"] = self.form.Transparency.value() - preset["TextFont"] = self.form.TextFont.currentFont().family() - preset["TextSize"] = FreeCAD.Units.Quantity(self.form.TextSize.text()).Value preset["TextColor"] = utils.argb_to_rgba(self.form.TextColor.property("color").rgba()) + preset["TextFont"] = self.form.TextFont.currentFont().family() + preset["TextSize"] = U.Quantity(self.form.TextSize.text()).Value + preset["LineSpacing"] = self.form.LineSpacing.value() + preset["AnnoLineColor"] = utils.argb_to_rgba(self.form.AnnoLineColor.property("color").rgba()) + preset["AnnoLineWidth"] = self.form.AnnoLineWidth.value() preset["ArrowStyle"] = self.form.ArrowStyle.currentIndex() - preset["ArrowSize"] = FreeCAD.Units.Quantity(self.form.ArrowSize.text()).Value + preset["ArrowSize"] = U.Quantity(self.form.ArrowSize.text()).Value preset["ShowUnit"] = self.form.ShowUnit.isChecked() preset["UnitOverride"] = self.form.UnitOverride.text() - preset["TextSpacing"] = FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value - preset["LineSpacing"] = self.form.LineSpacing.value() - preset["DimOvershoot"] = FreeCAD.Units.Quantity(self.form.DimOvershoot.text()).Value - preset["ExtLines"] = FreeCAD.Units.Quantity(self.form.ExtLines.text()).Value - preset["ExtOvershoot"] = FreeCAD.Units.Quantity(self.form.ExtOvershoot.text()).Value + preset["DimOvershoot"] = U.Quantity(self.form.DimOvershoot.text()).Value + preset["ExtLines"] = U.Quantity(self.form.ExtLines.text()).Value + preset["ExtOvershoot"] = U.Quantity(self.form.ExtOvershoot.text()).Value + preset["TextSpacing"] = U.Quantity(self.form.TextSpacing.text()).Value return preset def setValues(self,preset): - from PySide import QtCore,QtGui - self.form.LineColor.setProperty("color",self.getColor(preset.get("LineColor",255))) - self.form.LineWidth.setValue(preset.get("LineWidth",1)) - self.form.DrawStyle.setCurrentIndex(preset.get("DrawStyle",0)) - self.form.DisplayMode.setCurrentIndex(preset.get("DisplayMode",0)) - self.form.ShapeColor.setProperty("color",self.getColor(preset.get("ShapeColor",4294967295))) - self.form.Transparency.setValue(preset.get("Transparency",0)) - self.form.TextFont.setCurrentFont(QtGui.QFont(preset.get("TextFont","sans"))) - self.form.TextColor.setProperty("color",self.getColor(preset.get("TextColor",255))) - self.form.ArrowStyle.setCurrentIndex(preset.get("ArrowStyle",0)) - self.form.ShowUnit.setChecked(preset.get("ShowUnit",False)) - self.form.UnitOverride.setText(preset.get("UnitOverride","")) - self.form.TextSize.setText(FreeCAD.Units.Quantity(preset.get("TextSize",25),FreeCAD.Units.Length).UserString) - self.form.ArrowSize.setText(FreeCAD.Units.Quantity(preset.get("ArrowSize",5),FreeCAD.Units.Length).UserString) - self.form.TextSpacing.setText(FreeCAD.Units.Quantity(preset.get("TextSpacing",25),FreeCAD.Units.Length).UserString) - self.form.LineSpacing.setValue(preset.get("LineSpacing",3)) - self.form.DimOvershoot.setText(FreeCAD.Units.Quantity(preset.get("DimOvershoot",0),FreeCAD.Units.Length).UserString) - self.form.ExtLines.setText(FreeCAD.Units.Quantity(preset.get("ExtLines",0),FreeCAD.Units.Length).UserString) - self.form.ExtOvershoot.setText(FreeCAD.Units.Quantity(preset.get("ExtOvershoot",0),FreeCAD.Units.Length).UserString) + # For compatibility with V0.21 and earlier some properties, if missing, revert to others: + # 'new' prop -> old prop + # --------------------------- + # PointColor -> LineColor + # PointSize -> LineWidth + # AnnoLineColor -> LineColor + # AnnoLineWidth -> LineWidth + self.form.ShapeColor.setProperty("color", self.getColor(preset.get("ShapeColor", 3435973887))) + self.form.Transparency.setValue(preset.get("Transparency", 0)) + self.form.LineColor.setProperty("color", self.getColor(preset.get("LineColor", 255))) + self.form.LineWidth.setValue(preset.get("LineWidth", 2)) + self.form.PointColor.setProperty("color", self.getColor(preset.get("PointColor", preset.get("LineColor", 255)))) + self.form.PointSize.setValue(preset.get("PointSize", preset.get("LineWidth", 2))) + self.form.DrawStyle.setCurrentIndex(preset.get("DrawStyle", 0)) + self.form.DisplayMode.setCurrentIndex(preset.get("DisplayMode", 0)) + self.form.TextColor.setProperty("color", self.getColor(preset.get("TextColor", 255))) + self.form.TextFont.setCurrentFont(QtGui.QFont(preset.get("TextFont", "Sans"))) + self.form.TextSize.setText(U.Quantity(preset.get("TextSize", 3.5),U.Length).UserString) + self.form.LineSpacing.setValue(preset.get("LineSpacing", 1)) + self.form.AnnoLineColor.setProperty("color", self.getColor(preset.get("AnnoLineColor", preset.get("LineColor", 255)))) + self.form.AnnoLineWidth.setValue(preset.get("AnnoLineWidth", preset.get("LineWidth", 2))) + self.form.ArrowStyle.setCurrentIndex(preset.get("ArrowStyle", 0)) + self.form.ArrowSize.setText(U.Quantity(preset.get("ArrowSize", 1), U.Length).UserString) + self.form.ShowUnit.setChecked(preset.get("ShowUnit", True)) + self.form.UnitOverride.setText(preset.get("UnitOverride", "")) + self.form.DimOvershoot.setText(U.Quantity(preset.get("DimOvershoot", 0), U.Length).UserString) + self.form.ExtLines.setText(U.Quantity(preset.get("ExtLines", -0.5), U.Length).UserString) + self.form.ExtOvershoot.setText(U.Quantity(preset.get("ExtOvershoot", 2), U.Length).UserString) + self.form.TextSpacing.setText(U.Quantity(preset.get("TextSpacing", 1), U.Length).UserString) def reject(self): - FreeCADGui.Control.closeDialog() + Gui.Control.closeDialog() def accept(self): - param_draft = FreeCAD.ParamGet(self.p + "Mod/Draft") - param_view = FreeCAD.ParamGet(self.p + "View") - - param_view.SetUnsigned("DefaultShapeLineColor",utils.argb_to_rgba(self.form.LineColor.property("color").rgba())) - param_view.SetInt("DefaultShapeLineWidth",self.form.LineWidth.value()) - param_view.SetUnsigned("DefaultShapeVertexColor",utils.argb_to_rgba(self.form.LineColor.property("color").rgba())) - param_view.SetInt("DefaultShapePointSize",self.form.LineWidth.value()) - param_draft.SetInt("DefaultDrawStyle",self.form.DrawStyle.currentIndex()) - param_draft.SetInt("DefaultDisplayMode",self.form.DisplayMode.currentIndex()) - param_view.SetUnsigned("DefaultShapeColor",utils.argb_to_rgba(self.form.ShapeColor.property("color").rgba())) - param_view.SetInt("DefaultShapeTransparency",self.form.Transparency.value()) - param_draft.SetString("textfont",self.form.TextFont.currentFont().family()) - param_draft.SetFloat("textheight",FreeCAD.Units.Quantity(self.form.TextSize.text()).Value) - param_draft.SetUnsigned("DefaultTextColor",utils.argb_to_rgba(self.form.TextColor.property("color").rgba())) - param_draft.SetInt("dimsymbol",self.form.ArrowStyle.currentIndex()) - param_draft.SetFloat("arrowsize",FreeCAD.Units.Quantity(self.form.ArrowSize.text()).Value) - param_draft.SetBool("showUnit",self.form.ShowUnit.isChecked()) - param_draft.SetString("overrideUnit",self.form.UnitOverride.text()) - param_draft.SetFloat("dimspacing",FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value) - param_draft.SetFloat("LineSpacing",self.form.LineSpacing.value()) - param_draft.SetFloat("dimovershoot",FreeCAD.Units.Quantity(self.form.DimOvershoot.text()).Value) - param_draft.SetFloat("extlines",FreeCAD.Units.Quantity(self.form.ExtLines.text()).Value) - param_draft.SetFloat("extovershoot",FreeCAD.Units.Quantity(self.form.ExtOvershoot.text()).Value) + param_draft = App.ParamGet(self.p + "Mod/Draft") + param_view = App.ParamGet(self.p + "View") + + param_view.SetUnsigned("DefaultShapeColor", utils.argb_to_rgba(self.form.ShapeColor.property("color").rgba())) + param_view.SetInt("DefaultShapeTransparency", self.form.Transparency.value()) + param_view.SetUnsigned("DefaultShapeLineColor", utils.argb_to_rgba(self.form.LineColor.property("color").rgba())) + param_view.SetInt("DefaultShapeLineWidth", self.form.LineWidth.value()) + param_view.SetUnsigned("DefaultShapeVertexColor", utils.argb_to_rgba(self.form.PointColor.property("color").rgba())) + param_view.SetInt("DefaultShapePointSize", self.form.PointSize.value()) + param_draft.SetInt("DefaultDrawStyle", self.form.DrawStyle.currentIndex()) + param_draft.SetInt("DefaultDisplayMode", self.form.DisplayMode.currentIndex()) + param_draft.SetUnsigned("DefaultTextColor", utils.argb_to_rgba(self.form.TextColor.property("color").rgba())) + param_draft.SetString("textfont", self.form.TextFont.currentFont().family()) + param_draft.SetFloat("textheight", U.Quantity(self.form.TextSize.text()).Value) + param_draft.SetFloat("LineSpacing", self.form.LineSpacing.value()) + param_draft.SetUnsigned("DefaultAnnoLineColor", utils.argb_to_rgba(self.form.AnnoLineColor.property("color").rgba())) + param_draft.SetInt("DefaultAnnoLineWidth", self.form.AnnoLineWidth.value()) + param_draft.SetInt("dimsymbol", self.form.ArrowStyle.currentIndex()) + param_draft.SetFloat("arrowsize", U.Quantity(self.form.ArrowSize.text()).Value) + param_draft.SetBool("showUnit", self.form.ShowUnit.isChecked()) + param_draft.SetString("overrideUnit", self.form.UnitOverride.text()) + param_draft.SetFloat("dimovershoot", U.Quantity(self.form.DimOvershoot.text()).Value) + param_draft.SetFloat("extlines", U.Quantity(self.form.ExtLines.text()).Value) + param_draft.SetFloat("extovershoot", U.Quantity(self.form.ExtOvershoot.text()).Value) + param_draft.SetFloat("dimspacing", U.Quantity(self.form.TextSpacing.text()).Value) self.reject() def onApplyStyle(self): - for obj in FreeCADGui.Selection.getSelection(): + for obj in Gui.Selection.getSelection(): self.apply_style_to_obj(obj) def onApplyAnnot(self): - if FreeCAD.ActiveDocument is not None: # Command can be called without a document. - from draftutils import utils - objs = FreeCAD.ActiveDocument.Objects + if App.ActiveDocument is not None: # Command can be called without a document. + objs = App.ActiveDocument.Objects typs = ["Dimension", "LinearDimension", "AngularDimension", "Text", "DraftText", "Label"] for obj in objs: @@ -224,49 +247,56 @@ def apply_style_to_obj(self, obj): return properties = vobj.PropertiesList - if "LineColor" in properties: - vobj.LineColor = self.form.LineColor.property("color").getRgbF()[:3] # Remove Alpha (which is 1 instead of 0). - if "LineWidth" in properties: - vobj.LineWidth = self.form.LineWidth.value() - if "PointColor" in properties: - vobj.PointColor = self.form.LineColor.property("color").getRgbF()[:3] - if "PointSize" in properties: - vobj.PointSize = self.form.LineWidth.value() - if "DrawStyle" in properties: - vobj.DrawStyle = ["Solid", "Dashed", "Dotted", "Dashdot"][self.form.DrawStyle.currentIndex()] - if "DisplayMode" in properties: - dmodes = ["Flat Lines", "Wireframe", "Shaded", "Points"] - dm = dmodes[self.form.DisplayMode.currentIndex()] - if dm in vobj.getEnumerationsOfProperty("DisplayMode"): - vobj.DisplayMode = dm - if "ShapeColor" in properties: - vobj.ShapeColor = self.form.ShapeColor.property("color").getRgbF()[:3] - if "Transparency" in properties: - vobj.Transparency = self.form.Transparency.value() - if "FontName" in properties: - vobj.FontName = self.form.TextFont.currentFont().family() - if "FontSize" in properties: - vobj.FontSize = FreeCAD.Units.Quantity(self.form.TextSize.text()).Value - if "TextColor" in properties: - vobj.TextColor = self.form.TextColor.property("color").getRgbF()[:3] - if "ArrowType" in properties: - vobj.ArrowType = ["Dot", "Circle", "Arrow", "Tick", "Tick-2"][self.form.ArrowStyle.currentIndex()] - if "ArrowSize" in properties: - vobj.ArrowSize = FreeCAD.Units.Quantity(self.form.ArrowSize.text()).Value - if "ShowUnit" in properties: - vobj.ShowUnit = self.form.ShowUnit.isChecked() - if "UnitOverride" in properties: - vobj.UnitOverride = self.form.UnitOverride.text() - if "TextSpacing" in properties: - vobj.TextSpacing = FreeCAD.Units.Quantity(self.form.TextSpacing.text()).Value - if "LineSpacing" in properties: - vobj.LineSpacing = self.form.LineSpacing.value() - if "DimOvershoot" in properties: - vobj.DimOvershoot = FreeCAD.Units.Quantity(self.form.DimOvershoot.text()).Value - if "ExtLines" in properties: - vobj.ExtLines = FreeCAD.Units.Quantity(self.form.ExtLines.text()).Value - if "ExtOvershoot" in properties: - vobj.ExtOvershoot = FreeCAD.Units.Quantity(self.form.ExtOvershoot.text()).Value + if "FontName" not in properties: # Shapes + if "ShapeColor" in properties: + vobj.ShapeColor = self.form.ShapeColor.property("color").getRgbF()[:3] # Remove Alpha (which is 1 instead of 0). + if "Transparency" in properties: + vobj.Transparency = self.form.Transparency.value() + if "LineColor" in properties: + vobj.LineColor = self.form.LineColor.property("color").getRgbF()[:3] + if "LineWidth" in properties: + vobj.LineWidth = self.form.LineWidth.value() + if "PointColor" in properties: + vobj.PointColor = self.form.PointColor.property("color").getRgbF()[:3] + if "PointSize" in properties: + vobj.PointSize = self.form.PointSize.value() + if "DrawStyle" in properties: + dstyles = ["Solid", "Dashed", "Dotted", "Dashdot"] + vobj.DrawStyle = dstyles[self.form.DrawStyle.currentIndex()] + if "DisplayMode" in properties: + dmodes = ["Flat Lines", "Shaded", "Wireframe", "Points"] + dm = dmodes[self.form.DisplayMode.currentIndex()] + if dm in vobj.getEnumerationsOfProperty("DisplayMode"): + vobj.DisplayMode = dm + else: # Annotations + if "TextColor" in properties: + vobj.TextColor = self.form.TextColor.property("color").getRgbF()[:3] + if "FontName" in properties: + vobj.FontName = self.form.TextFont.currentFont().family() + if "FontSize" in properties: + vobj.FontSize = U.Quantity(self.form.TextSize.text()).Value + if "LineSpacing" in properties: + vobj.LineSpacing = self.form.LineSpacing.value() + if "LineColor" in properties: + vobj.LineColor = self.form.AnnoLineColor.property("color").getRgbF()[:3] + if "LineWidth" in properties: + vobj.LineWidth = self.form.AnnoLineWidth.value() + if "ArrowType" in properties: + vobj.ArrowType = ["Dot", "Circle", "Arrow", "Tick", "Tick-2"][self.form.ArrowStyle.currentIndex()] + if "ArrowSize" in properties: + vobj.ArrowSize = U.Quantity(self.form.ArrowSize.text()).Value + if "ShowUnit" in properties: + vobj.ShowUnit = self.form.ShowUnit.isChecked() + if "UnitOverride" in properties: + vobj.UnitOverride = self.form.UnitOverride.text() + if "DimOvershoot" in properties: + vobj.DimOvershoot = U.Quantity(self.form.DimOvershoot.text()).Value + if "ExtLines" in properties: + vobj.ExtLines = U.Quantity(self.form.ExtLines.text()).Value + if "ExtOvershoot" in properties: + vobj.ExtOvershoot = U.Quantity(self.form.ExtOvershoot.text()).Value + if "TextSpacing" in properties: + vobj.TextSpacing = U.Quantity(self.form.TextSpacing.text()).Value def onLoadStyle(self,index): @@ -278,18 +308,17 @@ def onLoadStyle(self,index): def onSaveStyle(self): - from PySide import QtCore,QtGui reply = QtGui.QInputDialog.getText(None, - translate("Draft","Save style"), - translate("Draft","Name of this new style:")) + translate("Draft", "Save style"), + translate("Draft", "Name of this new style:")) if reply[1]: name = reply[0] pdict = self.load() if pdict: if name in pdict: reply = QtGui.QMessageBox.question(None, - translate("Draft","Warning"), - translate("Draft","Name exists. Overwrite?"), + translate("Draft", "Warning"), + translate("Draft", "Name exists. Overwrite?"), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.No: @@ -308,10 +337,12 @@ def load(self): import json from json.decoder import JSONDecodeError except Exception: - FreeCAD.Console.PrintError(translate("Draft","Error: json module not found. Unable to load style")+"\n") + App.Console.PrintError( + translate("Draft", "Error: json module not found. Unable to load style") + "\n" + ) return if os.path.exists(PRESETPATH): - with open(PRESETPATH,"r") as f: + with open(PRESETPATH, "r") as f: try: pdict = json.load(f) except JSONDecodeError: @@ -325,15 +356,17 @@ def save(self,d): try: import json except Exception: - FreeCAD.Console.PrintError(translate("Draft","Error: json module not found. Unable to save style")+"\n") + App.Console.PrintError( + translate("Draft", "Error: json module not found. Unable to save style") + "\n" + ) return folder = os.path.dirname(PRESETPATH) if not os.path.exists(folder): os.makedirs(folder) - with open(PRESETPATH,"w") as f: - json.dump(d,f,indent=4) + with open(PRESETPATH, "w") as f: + json.dump(d, f, indent=4) -FreeCADGui.addCommand('Draft_SetStyle', Draft_SetStyle()) +Gui.addCommand("Draft_SetStyle", Draft_SetStyle()) ## @} diff --git a/src/Mod/Draft/draftutils/gui_utils.py b/src/Mod/Draft/draftutils/gui_utils.py index 2625ce600439..a518c32ae651 100644 --- a/src/Mod/Draft/draftutils/gui_utils.py +++ b/src/Mod/Draft/draftutils/gui_utils.py @@ -464,6 +464,16 @@ def format_object(target, origin=None): if not hasattr(target, 'ViewObject'): return obrep = target.ViewObject + obprops = obrep.PropertiesList + if "FontName" not in obprops: + if "DrawStyle" in obprops: + dstyles = ["Solid", "Dashed", "Dotted", "Dashdot"] + obrep.DrawStyle = dstyles[utils.getParam("DefaultDrawStyle", 0)] + if "DisplayMode" in obprops: + dmodes = ["Flat Lines", "Shaded", "Wireframe", "Points"] + dm = dmodes[utils.getParam("DefaultDisplayMode", 0)] + if dm in obrep.getEnumerationsOfProperty("DisplayMode"): + obrep.DisplayMode = dm if Gui.draftToolBar.isConstructionMode(): doc = App.ActiveDocument col = Gui.draftToolBar.getDefaultColor("constr") + (0.0,) @@ -472,13 +482,13 @@ def format_object(target, origin=None): grp = doc.addObject("App::DocumentObjectGroup", "Draft_Construction") grp.Label = utils.get_param("constructiongroupname", "Construction") grp.addObject(target) - if "TextColor" in obrep.PropertiesList: + if "TextColor" in obprops: obrep.TextColor = col - if "PointColor" in obrep.PropertiesList: + if "PointColor" in obprops: obrep.PointColor = col - if "LineColor" in obrep.PropertiesList: + if "LineColor" in obprops: obrep.LineColor = col - if "ShapeColor" in obrep.PropertiesList: + if "ShapeColor" in obprops: obrep.ShapeColor = col if hasattr(obrep, "Transparency"): obrep.Transparency = 80 @@ -487,7 +497,7 @@ def format_object(target, origin=None): for p in matchrep.PropertiesList: if p not in ("DisplayMode", "BoundingBox", "Proxy", "RootNode", "Visibility"): - if p in obrep.PropertiesList: + if p in obprops: if not obrep.getEditorMode(p): if hasattr(getattr(matchrep, p), "Value"): val = getattr(matchrep, p).Value diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 4b3580cd0145..67ee641d7056 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -173,6 +173,7 @@ def get_param_type(param): "linewidth", "modconstrain", "modsnap", "maxSnapEdges", "modalt", "HatchPatternResolution", "snapStyle", "DefaultAnnoDisplayMode", "DefaultAnnoLineWidth", + "DefaultDrawStyle", "DefaultDisplayMode", "gridSize", "gridTransparency"): return "int" elif param in ("constructiongroupname", "textfont", From 0e9d5914cb5590df599a0cd07e417648fb46a92b Mon Sep 17 00:00:00 2001 From: Jacob Oursland Date: Thu, 30 Nov 2023 13:02:11 -0800 Subject: [PATCH 4/7] Do not use pthreads in gtest with MSVC compilers. (#11584) --- tests/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b7d9e410a130..463aaf8f28a9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,7 @@ if(MSVC) gtest_force_shared_crt "Use shared (DLL) run-time lib even when Google Test is built as static lib." ON) + option(gtest_disable_pthreads "Disable uses of pthreads in gtest." ON) set(Google_Tests_LIBS oldnames.lib From 2914938c72c1bac7cbd7c5bbe090b6baa8939eb8 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Thu, 30 Nov 2023 22:47:15 +0100 Subject: [PATCH 5/7] Gui: Add ability to easily lock Toolbars from UI This adds the Std_ToggleToolBarLock action mentioned in #4992. It is exposed in the context menu of toolbar and also in the view -> toolbars app menu. --- src/Gui/CommandWindow.cpp | 42 ++++++++++++++++++++++++++++++++++++++ src/Gui/MainWindow.cpp | 4 ++++ src/Gui/ToolBarManager.cpp | 30 ++++++++++++++++++++++----- src/Gui/ToolBarManager.h | 9 +++++--- src/Gui/Workbench.cpp | 1 + 5 files changed, 78 insertions(+), 8 deletions(-) diff --git a/src/Gui/CommandWindow.cpp b/src/Gui/CommandWindow.cpp index a2adf626a91e..6b48d5f83aa3 100644 --- a/src/Gui/CommandWindow.cpp +++ b/src/Gui/CommandWindow.cpp @@ -36,6 +36,7 @@ #include "Document.h" #include "DlgActivateWindowImp.h" #include "DockWindowManager.h" +#include "ToolBarManager.h" #include #include @@ -339,6 +340,46 @@ Action * StdCmdToolBarMenu::createAction() return pcAction; } +//=========================================================================== +// Std_DlgToggleToolBarLock +//=========================================================================== +DEF_STD_CMD_C(StdCmdToggleToolBarLock) + +StdCmdToggleToolBarLock::StdCmdToggleToolBarLock() + :Command("Std_ToggleToolBarLock") +{ + sGroup = "Tools"; + sMenuText = QT_TR_NOOP("Lock toolbars"); + sToolTipText = QT_TR_NOOP("Locks toolbar so they are no longer moveable"); + sWhatsThis = "Std_ToggleToolBarLock"; + sStatusTip = QT_TR_NOOP("Locks toolbar so they are no longer moveable"); + eType = 0; +} + + +Action* StdCmdToggleToolBarLock::createAction() +{ + Action* action = Command::createAction(); + + action->setCheckable(true); + action->setChecked(ToolBarManager::getInstance()->areToolBarsLocked(), true); + + return action; +} + +void StdCmdToggleToolBarLock::activated(int iMsg) +{ + Q_UNUSED(iMsg); + + auto manager = ToolBarManager::getInstance(); + auto toggled = !manager->areToolBarsLocked(); + + manager->setToolBarsLocked(toggled); + + getAction()->setChecked(toggled); +} + + //=========================================================================== // Std_ViewStatusBar //=========================================================================== @@ -475,6 +516,7 @@ void CreateWindowStdCommands() rcCmdMgr.addCommand(new StdCmdWindows()); rcCmdMgr.addCommand(new StdCmdDockViewMenu()); rcCmdMgr.addCommand(new StdCmdToolBarMenu()); + rcCmdMgr.addCommand(new StdCmdToggleToolBarLock()); rcCmdMgr.addCommand(new StdCmdWindowsMenu()); rcCmdMgr.addCommand(new StdCmdStatusBar()); rcCmdMgr.addCommand(new StdCmdUserInterface()); diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 46b7bba165cb..d72a3dd3a36e 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1387,6 +1387,10 @@ void MainWindow::onToolBarMenuAboutToShow() menu->addAction(action); } } + + menu->addSeparator(); + + Application::Instance->commandManager().getCommandByName("Std_ToggleToolBarLock")->addTo(menu); } void MainWindow::onDockWindowMenuAboutToShow() diff --git a/src/Gui/ToolBarManager.cpp b/src/Gui/ToolBarManager.cpp index dbbdca3f9703..a6e9d561e112 100644 --- a/src/Gui/ToolBarManager.cpp +++ b/src/Gui/ToolBarManager.cpp @@ -408,11 +408,7 @@ void ToolBarManager::restoreState() const } } - - hPref = App::GetApplication().GetUserParameter().GetGroup("BaseApp") - ->GetGroup("Preferences")->GetGroup("General"); - bool lockToolBars = hPref->GetBool("LockToolBars", false); - setMovable(!lockToolBars); + setMovable(!areToolBarsLocked()); } void ToolBarManager::retranslate() const @@ -426,6 +422,30 @@ void ToolBarManager::retranslate() const } } +bool Gui::ToolBarManager::areToolBarsLocked() const +{ + auto hPref = App::GetApplication() + .GetUserParameter() + .GetGroup("BaseApp") + ->GetGroup("Preferences") + ->GetGroup("General"); + + return hPref->GetBool("LockToolBars", false); +} + +void Gui::ToolBarManager::setToolBarsLocked(bool locked) const +{ + auto hPref = App::GetApplication() + .GetUserParameter() + .GetGroup("BaseApp") + ->GetGroup("Preferences") + ->GetGroup("General"); + + hPref->SetBool("LockToolBars", locked); + + setMovable(!locked); +} + void Gui::ToolBarManager::setMovable(bool moveable) const { for (auto& tb : toolBars()) { diff --git a/src/Gui/ToolBarManager.h b/src/Gui/ToolBarManager.h index a84da34cbcda..86059f08f7e5 100644 --- a/src/Gui/ToolBarManager.h +++ b/src/Gui/ToolBarManager.h @@ -103,14 +103,17 @@ class GuiExport ToolBarManager void restoreState() const; void retranslate() const; - void setMovable(bool movable) const; + bool areToolBarsLocked() const; + void setToolBarsLocked(bool locked) const; void setState(const QList& names, State state); - void setState (const QString& name, State state); - + void setState(const QString& name, State state); + protected: void setup(ToolBarItem*, QToolBar*) const; + void setMovable(bool movable) const; + ToolBarItem::DefaultVisibility getToolbarPolicy(const QToolBar *) const; /** Returns a list of all currently existing toolbars. */ diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index c4d50c1ba903..163d1ba8de78 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -620,6 +620,7 @@ void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const void StdWorkbench::createMainWindowPopupMenu(MenuItem* item) const { + *item << "Std_ToggleToolBarLock"; *item << "Std_DlgCustomize"; } From ce41c0c3913399029aac8715e02cae2adba288be Mon Sep 17 00:00:00 2001 From: bdieterm Date: Thu, 30 Nov 2023 06:24:36 +0100 Subject: [PATCH 6/7] Gui: fix partially initialized default transparency --- src/Gui/ViewProviderGeometryObject.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index 03102539b101..c61b9ab0b14f 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -94,6 +94,7 @@ ViewProviderGeometryObject::ViewProviderGeometryObject() pcShapeMaterial = new SoMaterial; pcShapeMaterial->diffuseColor.setValue(r, g, b); pcShapeMaterial->transparency = float(initialTransparency); + ShapeMaterial.setTransparency((float)initialTransparency / 100.0f); pcShapeMaterial->ref(); pcBoundingBox = new Gui::SoFCBoundingBox; From a4db18af5624f801662e1a6ee19da861c77b8ff6 Mon Sep 17 00:00:00 2001 From: bgbsww Date: Thu, 30 Nov 2023 07:39:05 -0500 Subject: [PATCH 7/7] Default freenet to true for sweep to fix rendering bug --- src/Mod/Part/App/PartFeatures.cpp | 2 +- src/Mod/Part/Gui/TaskSweep.ui | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/App/PartFeatures.cpp b/src/Mod/Part/App/PartFeatures.cpp index 35b34e61cac8..facce022f3d3 100644 --- a/src/Mod/Part/App/PartFeatures.cpp +++ b/src/Mod/Part/App/PartFeatures.cpp @@ -369,7 +369,7 @@ Sweep::Sweep() Sections.setSize(0); ADD_PROPERTY_TYPE(Spine,(nullptr),"Sweep",App::Prop_None,"Path to sweep along"); ADD_PROPERTY_TYPE(Solid,(false),"Sweep",App::Prop_None,"Create solid"); - ADD_PROPERTY_TYPE(Frenet,(false),"Sweep",App::Prop_None,"Frenet"); + ADD_PROPERTY_TYPE(Frenet,(true),"Sweep",App::Prop_None,"Frenet"); ADD_PROPERTY_TYPE(Transition,(long(1)),"Sweep",App::Prop_None,"Transition mode"); Transition.setEnums(TransitionEnums); } diff --git a/src/Mod/Part/Gui/TaskSweep.ui b/src/Mod/Part/Gui/TaskSweep.ui index dc19fdb46051..3b2ee55c376b 100644 --- a/src/Mod/Part/Gui/TaskSweep.ui +++ b/src/Mod/Part/Gui/TaskSweep.ui @@ -59,6 +59,9 @@ Frenet + + true +