mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
CURA-4606 CURA-5003 select and activate material after create, duplicate
This commit is contained in:
parent
68b1a374e0
commit
cad6a3bb3d
2 changed files with 29 additions and 2 deletions
|
@ -518,7 +518,7 @@ class ContainerManager(QObject):
|
||||||
## Create a new material by cloning Generic PLA for the current material diameter and setting the GUID to something unqiue
|
## Create a new material by cloning Generic PLA for the current material diameter and setting the GUID to something unqiue
|
||||||
#
|
#
|
||||||
# \return \type{str} the id of the newly created container.
|
# \return \type{str} the id of the newly created container.
|
||||||
@pyqtSlot()
|
@pyqtSlot(result = str)
|
||||||
def createMaterial(self):
|
def createMaterial(self):
|
||||||
# Ensure all settings are saved.
|
# Ensure all settings are saved.
|
||||||
Application.getInstance().saveSettings()
|
Application.getInstance().saveSettings()
|
||||||
|
@ -539,6 +539,7 @@ class ContainerManager(QObject):
|
||||||
self.duplicateMaterial(material_group.root_material_node,
|
self.duplicateMaterial(material_group.root_material_node,
|
||||||
new_base_id = new_id,
|
new_base_id = new_id,
|
||||||
new_metadata = new_metadata)
|
new_metadata = new_metadata)
|
||||||
|
return new_id
|
||||||
|
|
||||||
## Get a list of materials that have the same GUID as the reference material
|
## Get a list of materials that have the same GUID as the reference material
|
||||||
#
|
#
|
||||||
|
|
|
@ -77,7 +77,7 @@ Item
|
||||||
iconName: "list-add"
|
iconName: "list-add"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
Cura.ContainerManager.createMaterial();
|
base.newRootMaterialIdToSwitchTo = Cura.ContainerManager.createMaterial();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ Item
|
||||||
enabled: base.hasCurrentItem
|
enabled: base.hasCurrentItem
|
||||||
onClicked: {
|
onClicked: {
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
|
base.newRootMaterialIdToSwitchTo = base.currentItem.root_material_id;
|
||||||
Cura.ContainerManager.duplicateMaterial(base.currentItem.container_node);
|
Cura.ContainerManager.duplicateMaterial(base.currentItem.container_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,6 +127,31 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property string newRootMaterialIdToSwitchTo: ""
|
||||||
|
|
||||||
|
// This connection makes sure that we will switch to the new
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: materialsModel
|
||||||
|
onItemsChanged: {
|
||||||
|
var currentItemName = base.currentItem == null ? "" : base.currentItem.name;
|
||||||
|
var position = Cura.ExtruderManager.activeExtruderIndex;
|
||||||
|
|
||||||
|
if (base.newRootMaterialIdToSwitchTo != "") {
|
||||||
|
for (var idx = 0; idx < materialsModel.rowCount(); ++idx) {
|
||||||
|
var item = materialsModel.getItem(idx);
|
||||||
|
if (item.root_material_id == base.newRootMaterialIdToSwitchTo) {
|
||||||
|
// Switch to the newly created profile if needed
|
||||||
|
materialListView.currentIndex = idx;
|
||||||
|
Cura.MachineManager.setMaterial(position, item.container_node);
|
||||||
|
base.newRootMaterialIdToSwitchTo = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MessageDialog
|
MessageDialog
|
||||||
{
|
{
|
||||||
id: confirmRemoveMaterialDialog
|
id: confirmRemoveMaterialDialog
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue