mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 06:23:59 -06:00
WIP Fix an error in which the current selected material was not
correctly selected when there is more than one brand (stupid mistake). Also fix problems when the user changes some material information. Contributes to CURA-5682.
This commit is contained in:
parent
6dc53cc60a
commit
972f0bef43
3 changed files with 53 additions and 25 deletions
|
@ -13,16 +13,17 @@ Item
|
|||
{
|
||||
id: detailsPanel
|
||||
|
||||
property var currentItem: base.currentItem
|
||||
property var currentItem: null
|
||||
|
||||
onCurrentItemChanged: updateMaterialPropertiesObject()
|
||||
onCurrentItemChanged:
|
||||
{
|
||||
// When the current item changes, the detail view needs to be updated
|
||||
updateMaterialPropertiesObject()
|
||||
materialDetailsView.currentMaterialNode = currentItem.container_node
|
||||
}
|
||||
|
||||
function updateMaterialPropertiesObject()
|
||||
{
|
||||
if (currentItem === null)
|
||||
{
|
||||
return
|
||||
}
|
||||
materialProperties.name = currentItem.name || "Unknown"
|
||||
materialProperties.guid = currentItem.GUID
|
||||
materialProperties.container_id = currentItem.id
|
||||
|
@ -71,8 +72,6 @@ Item
|
|||
properties: materialProperties
|
||||
containerId: currentItem != null ? currentItem.id : ""
|
||||
currentMaterialNode: currentItem.container_node
|
||||
|
||||
|
||||
}
|
||||
|
||||
QtObject
|
||||
|
|
|
@ -37,6 +37,13 @@ Item
|
|||
// Expand the list of materials in order to select the current material
|
||||
function expandActiveMaterial(search_root_id)
|
||||
{
|
||||
if (search_root_id == "")
|
||||
{
|
||||
// When this happens it means that the information of one of the materials has changed, so the model
|
||||
// was updated and the list has to highlight the current item.
|
||||
var currentItemId = base.currentItem == null ? "" : base.currentItem.root_material_id
|
||||
search_root_id = currentItemId
|
||||
}
|
||||
for (var material_idx = 0; material_idx < genericMaterialsModel.rowCount(); material_idx++)
|
||||
{
|
||||
var material = genericMaterialsModel.getItem(material_idx)
|
||||
|
@ -44,9 +51,9 @@ Item
|
|||
{
|
||||
if (materialList.expandedBrands.indexOf("Generic") == -1)
|
||||
{
|
||||
materialList.expandedBrands.push("Generic");
|
||||
materialList.currentBrand = "Generic"
|
||||
materialList.expandedBrands.push("Generic")
|
||||
}
|
||||
materialList.currentBrand = "Generic"
|
||||
base.currentItem = material
|
||||
persistExpandedCategories()
|
||||
return true
|
||||
|
@ -67,22 +74,22 @@ Item
|
|||
{
|
||||
if (materialList.expandedBrands.indexOf(brand.name) == -1)
|
||||
{
|
||||
materialList.expandedBrands.push(brand.name);
|
||||
materialList.currentBrand = brand.name
|
||||
materialList.expandedBrands.push(brand.name)
|
||||
}
|
||||
materialList.currentBrand = brand.name
|
||||
if (materialList.expandedTypes.indexOf(brand.name + "_" + type.name) == -1)
|
||||
{
|
||||
materialList.expandedTypes.push(brand.name + "_" + type.name)
|
||||
materialList.currentType = brand.name + "_" + type.name
|
||||
}
|
||||
materialList.currentType = brand.name + "_" + type.name
|
||||
base.currentItem = material
|
||||
persistExpandedCategories()
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Connections
|
||||
|
@ -91,13 +98,35 @@ Item
|
|||
onItemsChanged:
|
||||
{
|
||||
var correctlyExpanded = materialList.expandActiveMaterial(base.newRootMaterialIdToSwitchTo)
|
||||
if (base.toActivateNewMaterial)
|
||||
if (correctlyExpanded)
|
||||
{
|
||||
var position = Cura.ExtruderManager.activeExtruderIndex
|
||||
Cura.MachineManager.setMaterial(position, base.currentItem.container_node)
|
||||
if (base.toActivateNewMaterial)
|
||||
{
|
||||
var position = Cura.ExtruderManager.activeExtruderIndex
|
||||
Cura.MachineManager.setMaterial(position, base.currentItem.container_node)
|
||||
}
|
||||
base.newRootMaterialIdToSwitchTo = ""
|
||||
base.toActivateNewMaterial = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections
|
||||
{
|
||||
target: genericMaterialsModel
|
||||
onItemsChanged:
|
||||
{
|
||||
var correctlyExpanded = materialList.expandActiveMaterial(base.newRootMaterialIdToSwitchTo)
|
||||
if (correctlyExpanded)
|
||||
{
|
||||
if (base.toActivateNewMaterial)
|
||||
{
|
||||
var position = Cura.ExtruderManager.activeExtruderIndex
|
||||
Cura.MachineManager.setMaterial(position, base.currentItem.container_node)
|
||||
}
|
||||
base.newRootMaterialIdToSwitchTo = ""
|
||||
base.toActivateNewMaterial = false
|
||||
}
|
||||
base.newRootMaterialIdToSwitchTo = ""
|
||||
base.toActivateNewMaterial = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -572,21 +572,21 @@ TabView
|
|||
}
|
||||
|
||||
// update the values
|
||||
base.materialManager.setMaterialName(base.currentMaterialNode, new_name);
|
||||
materialProperties.name = new_name;
|
||||
base.materialManager.setMaterialName(base.currentMaterialNode, new_name)
|
||||
properties.name = new_name
|
||||
}
|
||||
|
||||
// update the type of the material
|
||||
function updateMaterialType(old_type, new_type)
|
||||
{
|
||||
base.setMetaDataEntry("material", old_type, new_type);
|
||||
materialProperties.material = new_type;
|
||||
base.setMetaDataEntry("material", old_type, new_type)
|
||||
properties.material = new_type
|
||||
}
|
||||
|
||||
// update the brand of the material
|
||||
function updateMaterialBrand(old_brand, new_brand)
|
||||
{
|
||||
base.setMetaDataEntry("brand", old_brand, new_brand);
|
||||
materialProperties.brand = new_brand;
|
||||
base.setMetaDataEntry("brand", old_brand, new_brand)
|
||||
properties.brand = new_brand
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue