diff --git a/resources/qml/Preferences/MaterialView.qml b/resources/qml/Preferences/MaterialView.qml index 2f705a8b5e..0929f1790a 100644 --- a/resources/qml/Preferences/MaterialView.qml +++ b/resources/qml/Preferences/MaterialView.qml @@ -269,7 +269,7 @@ TabView { id: spoolWeightSpinBox width: scrollView.columnWidth - value: base.getMaterialPreferenceValue(properties.guid, "spool_weight") + value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")) suffix: " g" stepSize: 100 decimals: 0 @@ -466,7 +466,7 @@ TabView } if(!spoolWeight) { - spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight"); + spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight")); } if (diameter == 0 || density == 0 || spoolWeight == 0) @@ -535,18 +535,14 @@ TabView UM.Preferences.setValue("cura/material_settings", JSON.stringify(materialPreferenceValues)); } - function getMaterialPreferenceValue(material_guid, entry_name) + function getMaterialPreferenceValue(material_guid, entry_name, default_value) { if(material_guid in materialPreferenceValues && entry_name in materialPreferenceValues[material_guid]) { return materialPreferenceValues[material_guid][entry_name]; } - 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; + default_value = default_value | 0; + return default_value; } // update the display name of the material diff --git a/resources/qml/Preferences/MaterialsPage.qml b/resources/qml/Preferences/MaterialsPage.qml index fb3623569c..e2e3edec2f 100644 --- a/resources/qml/Preferences/MaterialsPage.qml +++ b/resources/qml/Preferences/MaterialsPage.qml @@ -486,6 +486,7 @@ Item materialProperties.name = currentItem.name ? currentItem.name : "Unknown"; materialProperties.guid = currentItem.guid; + materialProperties.container_id = currentItem.container_id; materialProperties.brand = currentItem.brand ? currentItem.brand : "Unknown"; materialProperties.material = currentItem.material ? currentItem.material : "Unknown"; @@ -543,6 +544,7 @@ Item id: materialProperties property string guid: "00000000-0000-0000-0000-000000000000" + property string container_id: "Unknown"; property string name: "Unknown"; property string profile_type: "Unknown"; property string brand: "Unknown";