Hide options for Support, Anti overhang, etc Mesh if their settings are disabled

This commit is contained in:
fieldOfView 2018-01-05 21:38:54 +01:00
parent 8bd6afad1f
commit fbe128bbb7

View file

@ -42,6 +42,13 @@ Item {
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
UM.SettingPropertyProvider
{
id: meshTypePropertyProvider
containerStackId: Cura.MachineManager.activeMachineId
watchedProperties: [ "enabled" ]
}
ComboBox ComboBox
{ {
id: meshTypeSelection id: meshTypeSelection
@ -52,36 +59,55 @@ Item {
model: ListModel model: ListModel
{ {
id: meshTypeModel id: meshTypeModel
Component.onCompleted: Component.onCompleted: meshTypeSelection.populateModel()
}
function populateModel()
{ {
meshTypeModel.append({ meshTypeModel.append({
type: "", type: "",
text: catalog.i18nc("@label", "Normal model") text: catalog.i18nc("@label", "Normal model")
}); });
meshTypePropertyProvider.key = "support_mesh";
if(meshTypePropertyProvider.properties.enabled == "True")
{
meshTypeModel.append({ meshTypeModel.append({
type: "support_mesh", type: "support_mesh",
text: catalog.i18nc("@label", "Print as support") text: catalog.i18nc("@label", "Print as support")
}); });
}
meshTypePropertyProvider.key = "anti_overhang_mesh";
if(meshTypePropertyProvider.properties.enabled == "True")
{
meshTypeModel.append({ meshTypeModel.append({
type: "anti_overhang_mesh", type: "anti_overhang_mesh",
text: catalog.i18nc("@label", "Don't support overlap with other models") text: catalog.i18nc("@label", "Don't support overlap with other models")
}); });
}
meshTypePropertyProvider.key = "cutting_mesh";
if(meshTypePropertyProvider.properties.enabled == "True")
{
meshTypeModel.append({ meshTypeModel.append({
type: "cutting_mesh", type: "cutting_mesh",
text: catalog.i18nc("@label", "Modify settings for overlap with other models") text: catalog.i18nc("@label", "Modify settings for overlap with other models")
}); });
}
meshTypePropertyProvider.key = "infill_mesh";
if(meshTypePropertyProvider.properties.enabled == "True")
{
meshTypeModel.append({ meshTypeModel.append({
type: "infill_mesh", type: "infill_mesh",
text: catalog.i18nc("@label", "Modify settings for infill of other models") text: catalog.i18nc("@label", "Modify settings for infill of other models")
}); });
}
meshTypeSelection.updateCurrentIndex(); meshTypeSelection.updateCurrentIndex();
} }
}
function updateCurrentIndex() function updateCurrentIndex()
{ {
var mesh_type = UM.ActiveTool.properties.getValue("MeshType"); var mesh_type = UM.ActiveTool.properties.getValue("MeshType");
meshTypeSelection.currentIndex = -1;
for(var index=0; index < meshTypeSelection.model.count; index++) for(var index=0; index < meshTypeSelection.model.count; index++)
{ {
if(meshTypeSelection.model.get(index).type == mesh_type) if(meshTypeSelection.model.get(index).type == mesh_type)
@ -94,6 +120,16 @@ Item {
} }
} }
Connections
{
target: Cura.MachineManager
onGlobalContainerChanged:
{
meshTypeSelection.model.clear();
meshTypeSelection.populateModel();
}
}
Connections Connections
{ {
target: UM.Selection target: UM.Selection