Only changes the ViewSystem if the user confirms

UnitsApi::setSchema() was being called when the user changed the
comboBox item, so the view system was saved if the user later clicked
Cancel.  This call was moved to the saveSettings() method that is called
only if the user clicks Apply or OK.
This commit is contained in:
Silas
2019-01-02 22:26:57 -02:00
committed by wmayer
parent f1c6c549a9
commit 309640eb7f

View File

@@ -78,8 +78,6 @@ void DlgSettingsUnitsImp::on_comboBox_ViewSystem_currentIndexChanged(int index)
if (index < 0)
return; // happens when clearing the combo box in retranslateUi()
UnitsApi::setSchema((UnitSystem)index);
// Enable/disable the fractional inch option depending on system
if( (UnitSystem)index == ImperialBuilding )
{
@@ -96,6 +94,7 @@ void DlgSettingsUnitsImp::saveSettings()
// must be done as very first because we create a new instance of NavigatorStyle
// where we set some attributes afterwards
int FracInch; // minimum fractional inch to display
int viewSystemIndex; // currently selected View System (unit system)
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Units");
@@ -116,6 +115,10 @@ void DlgSettingsUnitsImp::saveSettings()
// Set the actual format value
Base::QuantityFormat::setDefaultDenominator(FracInch);
// Set and save the Unit System
viewSystemIndex = ui->comboBox_ViewSystem->currentIndex();
UnitsApi::setSchema((UnitSystem)viewSystemIndex);
}
void DlgSettingsUnitsImp::loadSettings()