CAM: Fix expression editor so that widgets refresh after closing

src/Gui/QuantitySpinBox.cpp:
- Call updateExpression() after setExpression() in QuantitySpinBox

src/Gui/SpinBox.cpp:
- Call updateExpression() after setExpression() in ExpressionSpinBox

src/Gui/Widgets.cpp:
- Call onChange() after setExpression() in ExpLineEdit

src/Mod/CAM/Path/Base/Gui/Util.py:
- Connect to showFormulaDialog signal and refresh CAM QuantitySpinBox Python wrapper when dialog closes
This commit is contained in:
Billy Huddleston
2025-10-24 15:08:57 -04:00
committed by Chris Hennes
parent bba37208cc
commit db40eb1478
5 changed files with 19 additions and 0 deletions

View File

@@ -659,6 +659,7 @@ static App::Document* getPreselectedDocument()
return doc;
}
int DlgExpressionInput::getVarSetIndex(const App::Document* doc) const
{
auto paramExpressionEditor = App::GetApplication().GetParameterGroupByPath(

View File

@@ -607,6 +607,7 @@ void QuantitySpinBox::openFormulaDialog()
else if (box->discardedFormula())
setExpression(std::shared_ptr<Expression>());
updateExpression();
box->deleteLater();
Q_EMIT showFormulaDialog(false);
});

View File

@@ -196,6 +196,7 @@ void ExpressionSpinBox::openFormulaDialog()
else if (box->discardedFormula())
setExpression(std::shared_ptr<Expression>());
updateExpression();
box->deleteLater();
});
box->show();

View File

@@ -1621,6 +1621,7 @@ void ExpLineEdit::finishFormulaDialog()
else if (box->discardedFormula())
setExpression(std::shared_ptr<Expression>());
onChange();
box->deleteLater();
if(autoClose)

View File

@@ -131,6 +131,21 @@ class QuantitySpinBox(QtCore.QObject):
self.widget.installEventFilter(self)
# Connect local class method as slot
self.widget.textChanged.connect(self.onWidgetValueChanged)
# Connect to showFormulaDialog signal to track dialog open/close
try:
self.widget.showFormulaDialog.connect(self.onFormulaDialogStateChanged)
except AttributeError:
# Widget may not have this signal
pass
def onFormulaDialogStateChanged(self, isOpen):
"""
Slot called when the formula dialog is opened or closed.
When the dialog closes (isOpen=False), refresh the widget.
"""
if not isOpen:
# Dialog has closed, update the widget to reflect any changes
self.updateWidget()
def eventFilter(self, obj, event):
if event.type() == QtCore.QEvent.Type.FocusIn: