fix bug on reset param

This commit is contained in:
alemuntoni 2020-08-02 21:50:30 +02:00
parent f67548bbc2
commit 9aec093499
5 changed files with 15 additions and 3 deletions

View File

@ -877,7 +877,10 @@ void MainWindow::loadMeshLabSettings()
if (!docElem.isNull())
{
currentGlobalParams.pushFromQDomElement(docElem);
RichParameter* rp = nullptr;
bool b = RichParameterAdapter::create(docElem, &rp);
if (b && defaultGlobalParams.hasParameter(rp->name()))
currentGlobalParams.pushFromQDomElement(docElem);
}
}
@ -897,6 +900,7 @@ void MainWindow::loadMeshLabSettings()
setting.setValue(v->name(), QVariant(docstring));
}
}
assert(currentGlobalParams.size() == defaultGlobalParams.size());
}

View File

@ -60,8 +60,8 @@ MeshLabSettingsDialog::MeshLabSettingsDialog(
void MeshLabSettingsDialog::openSubDialog(QTableWidgetItem* itm)
{
int rprow = tw->row(itm);
const RichParameter *defPar = defParSet.at(rprow);
RichParameter* curPar = curParSet.at(rprow);
const RichParameter *defPar = defParSet.findParameter(curPar->name());
SettingDialog* setdial = new SettingDialog(*curPar,*defPar,this);
connect(
setdial, SIGNAL(applySettingSignal(const RichParameter&)),

View File

@ -57,6 +57,13 @@ void RichParameterWidget::resetValue()
resetWidgetValue();
}
void RichParameterWidget::setValue(const Value& v)
{
rp->setValue(v);
resetWidgetValue();
}
const Value& RichParameterWidget::widgetValue()
{

View File

@ -54,6 +54,7 @@ public:
// called when the user press the 'default' button to reset the parameter values to its default.
// It just set the parameter value and then it calls the specialized resetWidgetValue() to update also the widget.
void resetValue();
void setValue(const Value& v);
// update the parameter with the current widget values and return it.
const Value& widgetValue();
const RichParameter& richParameter() const;

View File

@ -94,7 +94,7 @@ void SettingDialog::reset()
qDebug("resetting the value of param %s to the hardwired default", qUtf8Printable(curPar->name()));
assert(frame.stdfieldwidgets.size() == 1);
frame.stdfieldwidgets.at(0)->resetValue();
frame.stdfieldwidgets.at(0)->setValue(defPar->value());
apply();
}