It's no longer possible to remove a material that is in use

CURA-2168
This commit is contained in:
Jaime van Kessel 2016-08-24 14:48:20 +02:00
parent a177b61153
commit 17b34fb4e1
2 changed files with 10 additions and 1 deletions

View file

@ -225,6 +225,15 @@ class ContainerManager(QObject):
return result
@pyqtSlot(str, result = bool)
def isContainerUsed(self, container_id):
UM.Logger.log("d", "Checking if container %s is currently used in the active stacks", container_id)
for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks():
if container_id in [child.getId() for child in stack.getContainers()]:
UM.Logger.log("d", "The container is in use by %s", stack.getId())
return True
return False
## Get a list of string that can be used as name filters for a Qt File Dialog
#
# This will go through the list of available container types and generate a list of strings

View file

@ -104,7 +104,7 @@ UM.ManagementPage
{
text: catalog.i18nc("@action:button", "Remove");
iconName: "list-remove";
enabled: base.currentItem != null && !base.currentItem.readOnly
enabled: base.currentItem != null && !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id)
onClicked: confirmDialog.open()
},
Button