mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 17:27:51 -06:00
Fix for "Creating two profiles causes the names to become messed up"
CURA-2220
This commit is contained in:
parent
aa689dc2fb
commit
a2f478f2ad
3 changed files with 67 additions and 26 deletions
|
@ -423,8 +423,8 @@ class ContainerManager(QObject):
|
|||
# stack and clear the user settings.
|
||||
#
|
||||
# \return \type{bool} True if the operation was successfully, False if not.
|
||||
@pyqtSlot(result = bool)
|
||||
def createQualityChanges(self):
|
||||
@pyqtSlot(str, result = bool)
|
||||
def createQualityChanges(self, base_name):
|
||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
if not global_stack:
|
||||
return False
|
||||
|
@ -436,7 +436,9 @@ class ContainerManager(QObject):
|
|||
|
||||
self._machine_manager.blurSettings.emit()
|
||||
|
||||
unique_name = self._container_registry.uniqueName(active_quality_name)
|
||||
if base_name is None:
|
||||
base_name = active_quality_name
|
||||
unique_name = self._container_registry.uniqueName(base_name)
|
||||
|
||||
# Go through the active stacks and create quality_changes containers from the user containers.
|
||||
for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks():
|
||||
|
@ -540,8 +542,8 @@ class ContainerManager(QObject):
|
|||
# \param quality_name The name of the quality to duplicate.
|
||||
#
|
||||
# \return A string containing the name of the duplicated containers, or an empty string if it failed.
|
||||
@pyqtSlot(str, result = str)
|
||||
def duplicateQualityOrQualityChanges(self, quality_name):
|
||||
@pyqtSlot(str, str, result = str)
|
||||
def duplicateQualityOrQualityChanges(self, quality_name, base_name):
|
||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
if not global_stack or not quality_name:
|
||||
return ""
|
||||
|
@ -551,7 +553,10 @@ class ContainerManager(QObject):
|
|||
UM.Logger.log("d", "Unable to duplicate the quality %s, because it doesn't exist.", quality_name)
|
||||
return ""
|
||||
|
||||
new_name = self._container_registry.uniqueName(quality_name)
|
||||
if base_name is None:
|
||||
base_name = quality_name
|
||||
|
||||
new_name = self._container_registry.uniqueName(base_name)
|
||||
|
||||
container_type = containers[0].getMetaDataEntry("type")
|
||||
if container_type == "quality":
|
||||
|
|
|
@ -463,7 +463,7 @@ UM.MainWindow
|
|||
target: Cura.Actions.addProfile
|
||||
onTriggered:
|
||||
{
|
||||
Cura.ContainerManager.createQualityChanges();
|
||||
Cura.ContainerManager.createQualityChanges(null);
|
||||
preferences.setPage(4);
|
||||
preferences.show();
|
||||
|
||||
|
|
|
@ -61,6 +61,10 @@ UM.ManagementPage
|
|||
return -1;
|
||||
}
|
||||
|
||||
function canCreateProfile() {
|
||||
return base.currentItem && (base.currentItem.id == Cura.MachineManager.activeQualityId) && Cura.MachineManager.hasUserSettings;
|
||||
}
|
||||
|
||||
buttons: [
|
||||
Button
|
||||
{
|
||||
|
@ -69,26 +73,39 @@ UM.ManagementPage
|
|||
enabled: base.currentItem != null ? base.currentItem.id != Cura.MachineManager.activeQualityId : false;
|
||||
onClicked: Cura.MachineManager.setActiveQuality(base.currentItem.id)
|
||||
},
|
||||
|
||||
// Create button
|
||||
Button
|
||||
{
|
||||
text: base.currentItem && (base.currentItem.id == Cura.MachineManager.activeQualityId) && Cura.MachineManager.hasUserSettings ? catalog.i18nc("@label", "Create") : catalog.i18nc("@label", "Duplicate")
|
||||
text: catalog.i18nc("@label", "Create")
|
||||
enabled: base.canCreateProfile()
|
||||
visible: base.canCreateProfile()
|
||||
iconName: "list-add";
|
||||
|
||||
onClicked:
|
||||
{
|
||||
var selectedContainer;
|
||||
if (base.currentItem.id == Cura.MachineManager.activeQualityId && Cura.MachineManager.hasUserSettings) {
|
||||
selectedContainer = Cura.ContainerManager.createQualityChanges();
|
||||
} else {
|
||||
selectedContainer = Cura.ContainerManager.duplicateQualityOrQualityChanges(base.currentItem.name);
|
||||
}
|
||||
base.selectContainer(selectedContainer);
|
||||
|
||||
renameDialog.removeWhenRejected = true;
|
||||
renameDialog.open();
|
||||
renameDialog.selectText();
|
||||
newNameDialog.object = base.currentItem != null ? base.currentItem.name : "";
|
||||
newNameDialog.open();
|
||||
newNameDialog.selectText();
|
||||
}
|
||||
},
|
||||
|
||||
// Duplicate button
|
||||
Button
|
||||
{
|
||||
text: catalog.i18nc("@label", "Duplicate")
|
||||
enabled: ! base.canCreateProfile()
|
||||
visible: ! base.canCreateProfile()
|
||||
iconName: "list-add";
|
||||
|
||||
onClicked:
|
||||
{
|
||||
newDuplicateNameDialog.object = base.currentItem.name;
|
||||
newDuplicateNameDialog.open();
|
||||
newDuplicateNameDialog.selectText();
|
||||
}
|
||||
},
|
||||
|
||||
Button
|
||||
{
|
||||
text: catalog.i18nc("@action:button", "Remove");
|
||||
|
@ -103,7 +120,6 @@ UM.ManagementPage
|
|||
enabled: base.currentItem != null ? !base.currentItem.readOnly : false;
|
||||
onClicked:
|
||||
{
|
||||
renameDialog.removeWhenRejected = false;
|
||||
renameDialog.open();
|
||||
renameDialog.selectText();
|
||||
}
|
||||
|
@ -249,24 +265,44 @@ UM.ManagementPage
|
|||
objectList.currentIndex = -1 //Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: renameDialog;
|
||||
object: base.currentItem != null ? base.currentItem.name : ""
|
||||
property bool removeWhenRejected: false
|
||||
onAccepted:
|
||||
{
|
||||
Cura.ContainerManager.renameQualityChanges(base.currentItem.name, newName)
|
||||
objectList.currentIndex = -1 //Reset selection.
|
||||
}
|
||||
onRejected:
|
||||
}
|
||||
|
||||
// Dialog to request a name when creating a new profile
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: newNameDialog;
|
||||
object: "<new name>";
|
||||
onAccepted:
|
||||
{
|
||||
if(removeWhenRejected)
|
||||
{
|
||||
Cura.ContainerManager.removeQualityChanges(base.currentItem.name)
|
||||
}
|
||||
var selectedContainer = Cura.ContainerManager.createQualityChanges(newName);
|
||||
base.selectContainer(selectedContainer);
|
||||
objectList.currentIndex = -1 //Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
// Dialog to request a name when duplicating a new profile
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: newDuplicateNameDialog;
|
||||
object: "<new name>";
|
||||
onAccepted:
|
||||
{
|
||||
var selectedContainer = Cura.ContainerManager.duplicateQualityOrQualityChanges(base.currentItem.name, newName);
|
||||
base.selectContainer(selectedContainer);
|
||||
objectList.currentIndex = -1 //Reset selection.
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: messageDialog
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue