mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Fix default value for getMaterialPreferenceValue other than spool_weight, added cleanup code for saving default values. CURA-5408
This commit is contained in:
parent
e7c1d31bee
commit
5eb2230d82
1 changed files with 21 additions and 4 deletions
|
@ -515,7 +515,21 @@ TabView
|
|||
// value has not changed
|
||||
return;
|
||||
}
|
||||
materialPreferenceValues[material_guid][entry_name] = new_value;
|
||||
if (entry_name in materialPreferenceValues[material_guid] && new_value.toString() == 0)
|
||||
{
|
||||
// no need to store a 0, that's the default, so remove it
|
||||
materialPreferenceValues[material_guid].delete(entry_name);
|
||||
if (!(materialPreferenceValues[material_guid]))
|
||||
{
|
||||
// remove empty map
|
||||
materialPreferenceValues.delete(material_guid);
|
||||
}
|
||||
}
|
||||
if (new_value.toString() != 0)
|
||||
{
|
||||
// store new value
|
||||
materialPreferenceValues[material_guid][entry_name] = new_value;
|
||||
}
|
||||
|
||||
// store preference
|
||||
UM.Preferences.setValue("cura/material_settings", JSON.stringify(materialPreferenceValues));
|
||||
|
@ -527,9 +541,12 @@ TabView
|
|||
{
|
||||
return materialPreferenceValues[material_guid][entry_name];
|
||||
}
|
||||
|
||||
var material_weight = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/weight");
|
||||
return material_weight || 0;
|
||||
if (entry_name === "spool_weight") {
|
||||
// get the default value from the metadata
|
||||
var material_weight = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/weight");
|
||||
return material_weight || 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// update the display name of the material
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue