mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 05:37:50 -06:00
WIP: Fix quality renaming
This commit is contained in:
parent
486bcae677
commit
5b37de8adb
2 changed files with 38 additions and 42 deletions
|
@ -458,39 +458,21 @@ class ContainerManager(QObject):
|
|||
# \param new_name The new name of the quality changes.
|
||||
#
|
||||
# \return True if successful, False if not.
|
||||
@pyqtSlot(str, str, result = bool)
|
||||
def renameQualityChanges(self, quality_name, new_name):
|
||||
Logger.log("d", "User requested QualityChanges container rename of %s to %s", quality_name, new_name)
|
||||
if not quality_name or not new_name:
|
||||
return False
|
||||
|
||||
if quality_name == new_name:
|
||||
Logger.log("w", "Unable to rename %s to %s, because they are the same.", quality_name, new_name)
|
||||
return True
|
||||
|
||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||
if not global_stack:
|
||||
return False
|
||||
|
||||
@pyqtSlot(QObject, str)
|
||||
def renameQualityChangesGroup(self, quality_changes_group, new_name):
|
||||
Logger.log("i", "Renaming QualityChangesGroup[%s] to [%s]", quality_changes_group.name, new_name)
|
||||
self._machine_manager.blurSettings.emit()
|
||||
|
||||
if new_name == quality_changes_group.name:
|
||||
Logger.log("i", "QualityChangesGroup name [%s] unchanged.", quality_changes_group.name)
|
||||
return
|
||||
|
||||
new_name = self._container_registry.uniqueName(new_name)
|
||||
|
||||
container_registry = self._container_registry
|
||||
|
||||
containers_to_rename = self._container_registry.findInstanceContainersMetadata(type = "quality_changes", name = quality_name)
|
||||
|
||||
for container in containers_to_rename:
|
||||
stack_id = global_stack.getId()
|
||||
if "extruder" in container:
|
||||
stack_id = container["extruder"]
|
||||
container_registry.renameContainer(container["id"], new_name, self._createUniqueId(stack_id, new_name))
|
||||
|
||||
if not containers_to_rename:
|
||||
Logger.log("e", "Unable to rename %s, because we could not find the profile", quality_name)
|
||||
for node in quality_changes_group.getAllNodes():
|
||||
node.getContainer().setName(new_name)
|
||||
|
||||
self._machine_manager.activeQualityChanged.emit()
|
||||
return True
|
||||
self._machine_manager.activeQualityGroupChanged.emit()
|
||||
|
||||
@pyqtSlot(str, "QVariantMap")
|
||||
def duplicateQualityChanges(self, quality_changes_name, quality_model_item):
|
||||
|
|
|
@ -86,9 +86,9 @@ Item
|
|||
visible: base.canCreateProfile
|
||||
|
||||
onClicked: {
|
||||
newNameDialog.object = base.currentItem != null ? Cura.ContainerManager.makeUniqueName(Cura.MachineManager.activeQualityOrQualityChangesName) : "";
|
||||
newNameDialog.open();
|
||||
newNameDialog.selectText();
|
||||
createQualityDialog.object = Cura.ContainerManager.makeUniqueName(base.currentItem.name);
|
||||
createQualityDialog.open();
|
||||
createQualityDialog.selectText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,9 +101,9 @@ Item
|
|||
visible: !base.canCreateProfile
|
||||
|
||||
onClicked: {
|
||||
newDuplicateNameDialog.object = Cura.ContainerManager.makeUniqueName(base.currentItem.name);
|
||||
newDuplicateNameDialog.open();
|
||||
newDuplicateNameDialog.selectText();
|
||||
duplicateQualityDialog.object = Cura.ContainerManager.makeUniqueName(base.currentItem.name);
|
||||
duplicateQualityDialog.open();
|
||||
duplicateQualityDialog.selectText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,11 @@ Item
|
|||
{
|
||||
text: catalog.i18nc("@action:button", "Rename")
|
||||
iconName: "edit-rename"
|
||||
//enabled: base.currentItem != null ? !base.currentItem.readOnly : false;
|
||||
enabled: true // TODO
|
||||
enabled: base.hasCurrentItem && !base.currentItem.is_read_only
|
||||
onClicked: {
|
||||
// TODO
|
||||
renameQualityDialog.object = base.currentItem.name;
|
||||
renameQualityDialog.open();
|
||||
renameQualityDialog.selectText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,26 +158,26 @@ Item
|
|||
// Dialog to request a name when creating a new profile
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: createQualityDialog
|
||||
title: catalog.i18nc("@title:window", "Create Profile")
|
||||
id: newNameDialog
|
||||
object: "<new name>"
|
||||
onAccepted:
|
||||
{
|
||||
Cura.ContainerManager.createQualityChanges(newName);
|
||||
qualityListView.currentIndex = -1 // TODO: Reset selection.
|
||||
qualityListView.currentIndex = -1; // TODO: Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
// Dialog to request a name when duplicating a new profile
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: duplicateQualityDialog
|
||||
title: catalog.i18nc("@title:window", "Duplicate Profile")
|
||||
id: newDuplicateNameDialog
|
||||
object: "<new name>"
|
||||
onAccepted:
|
||||
{
|
||||
Cura.ContainerManager.duplicateQualityChanges(newName, base.currentItem);
|
||||
qualityListView.currentIndex = -1; // TODO: Reset selection.
|
||||
qualityListView.currentIndex = -1; // TODO: Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +196,20 @@ Item
|
|||
{
|
||||
Cura.ContainerManager.removeQualityChangesGroup(base.currentItem.quality_changes_group);
|
||||
// reset current item to the first if available
|
||||
qualityListView.currentIndex = -1;
|
||||
qualityListView.currentIndex = -1; // TODO: Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
// Dialog to rename a quality profile
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: renameQualityDialog
|
||||
title: catalog.i18nc("@title:window", "Rename Profile")
|
||||
object: "<new name>"
|
||||
onAccepted:
|
||||
{
|
||||
Cura.ContainerManager.renameQualityChangesGroup(base.currentItem.quality_changes_group, newName);
|
||||
qualityListView.currentIndex = -1; // TODO: Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue