mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-23 06:09:38 +08:00
WIP: Fix remove quality
This commit is contained in:
parent
65e01d6203
commit
486bcae677
@ -439,49 +439,14 @@ class ContainerManager(QObject):
|
|||||||
#self._machine_manager.activeQualityGroupChanged.emit()
|
#self._machine_manager.activeQualityGroupChanged.emit()
|
||||||
#self._machine_manager.activeQualityChangesGroupChanged.emit()
|
#self._machine_manager.activeQualityChangesGroupChanged.emit()
|
||||||
|
|
||||||
## Remove all quality changes containers matching a specified name.
|
|
||||||
#
|
#
|
||||||
# This will search for quality_changes containers matching the supplied name and remove them.
|
# Remove the given quality changes group
|
||||||
# Note that if the machine specifies that qualities should be filtered by machine and/or material
|
|
||||||
# only the containers related to the active machine/material are removed.
|
|
||||||
#
|
#
|
||||||
# \param quality_name The name of the quality changes to remove.
|
@pyqtSlot(QObject)
|
||||||
#
|
def removeQualityChangesGroup(self, quality_changes_group):
|
||||||
# \return \type{bool} True if successful, False if not.
|
Logger.log("i", "Removing quality changes group [%s]", quality_changes_group.name)
|
||||||
@pyqtSlot(str, result = bool)
|
for node in quality_changes_group.getAllNodes():
|
||||||
def removeQualityChanges(self, quality_name):
|
self._container_registry.removeContainer(node.metadata["id"])
|
||||||
Logger.log("d", "Attempting to remove the quality change containers with name %s", quality_name)
|
|
||||||
containers_found = False
|
|
||||||
|
|
||||||
if not quality_name:
|
|
||||||
return containers_found # Without a name we will never find a container to remove.
|
|
||||||
|
|
||||||
# If the container that is being removed is the currently active quality, set another quality as the active quality
|
|
||||||
activate_quality = quality_name == self._machine_manager.activeQualityName
|
|
||||||
activate_quality_type = None
|
|
||||||
|
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
|
||||||
if not global_stack or not quality_name:
|
|
||||||
return ""
|
|
||||||
machine_definition = QualityManager.getInstance().getParentMachineDefinition(global_stack.getBottom())
|
|
||||||
|
|
||||||
for container in QualityManager.getInstance().findQualityChangesByName(quality_name, machine_definition):
|
|
||||||
containers_found = True
|
|
||||||
if activate_quality and not activate_quality_type:
|
|
||||||
activate_quality_type = container.getMetaDataEntry("quality")
|
|
||||||
self._container_registry.removeContainer(container.getId())
|
|
||||||
|
|
||||||
if not containers_found:
|
|
||||||
Logger.log("d", "Unable to remove quality containers, as we did not find any by the name of %s", quality_name)
|
|
||||||
|
|
||||||
elif activate_quality:
|
|
||||||
definition_id = "fdmprinter" if not self._machine_manager.filterQualityByMachine else self._machine_manager.activeDefinitionId
|
|
||||||
containers = self._container_registry.findInstanceContainersMetadata(type = "quality", definition = definition_id, quality_type = activate_quality_type)
|
|
||||||
if containers:
|
|
||||||
self._machine_manager.setActiveQuality(containers[0]["id"])
|
|
||||||
self._machine_manager.activeQualityChanged.emit()
|
|
||||||
|
|
||||||
return containers_found
|
|
||||||
|
|
||||||
## Rename a set of quality changes containers.
|
## Rename a set of quality changes containers.
|
||||||
#
|
#
|
||||||
@ -527,7 +492,7 @@ class ContainerManager(QObject):
|
|||||||
self._machine_manager.activeQualityChanged.emit()
|
self._machine_manager.activeQualityChanged.emit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@pyqtSlot(str, dict)
|
@pyqtSlot(str, "QVariantMap")
|
||||||
def duplicateQualityChanges(self, quality_changes_name, quality_model_item):
|
def duplicateQualityChanges(self, quality_changes_name, quality_model_item):
|
||||||
quality_group = quality_model_item["quality_group"]
|
quality_group = quality_model_item["quality_group"]
|
||||||
quality_changes_group = quality_model_item["quality_changes_group"]
|
quality_changes_group = quality_model_item["quality_changes_group"]
|
||||||
|
@ -112,10 +112,10 @@ Item
|
|||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:button", "Remove")
|
text: catalog.i18nc("@action:button", "Remove")
|
||||||
iconName: "list-remove"
|
iconName: "list-remove"
|
||||||
//enabled: base.currentItem != null ? !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id) : false;
|
enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated
|
||||||
enabled: true // TODO
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// TODO
|
forceActiveFocus();
|
||||||
|
confirmRemoveQualityDialog.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ Item
|
|||||||
object: "<new name>"
|
object: "<new name>"
|
||||||
onAccepted:
|
onAccepted:
|
||||||
{
|
{
|
||||||
var selectedContainer = Cura.ContainerManager.createQualityChanges(newName);
|
Cura.ContainerManager.createQualityChanges(newName);
|
||||||
qualityListView.currentIndex = -1 // TODO: Reset selection.
|
qualityListView.currentIndex = -1 // TODO: Reset selection.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,6 +180,25 @@ Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Confirmation dialog for removing a profile
|
||||||
|
MessageDialog
|
||||||
|
{
|
||||||
|
id: confirmRemoveQualityDialog
|
||||||
|
|
||||||
|
icon: StandardIcon.Question;
|
||||||
|
title: catalog.i18nc("@title:window", "Confirm Remove")
|
||||||
|
text: catalog.i18nc("@label (%1 is object name)", "Are you sure you wish to remove %1? This cannot be undone!").arg(base.currentItem.name)
|
||||||
|
standardButtons: StandardButton.Yes | StandardButton.No
|
||||||
|
modality: Qt.ApplicationModal
|
||||||
|
|
||||||
|
onYes:
|
||||||
|
{
|
||||||
|
Cura.ContainerManager.removeQualityChangesGroup(base.currentItem.quality_changes_group);
|
||||||
|
// reset current item to the first if available
|
||||||
|
qualityListView.currentIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: contentsItem
|
id: contentsItem
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user