diff --git a/cura/Machines/Models/QualityManagementModel.py b/cura/Machines/Models/QualityManagementModel.py index b4fb8b38b5..3c3bc9a6e9 100644 --- a/cura/Machines/Models/QualityManagementModel.py +++ b/cura/Machines/Models/QualityManagementModel.py @@ -184,7 +184,8 @@ class QualityManagementModel(ListModel): container_registry.addContainer(container.duplicate(new_id, new_name)) @pyqtSlot(str) - def createQualityChanges(self, base_name: str) -> None: + @pyqtSlot(str, bool) + def createQualityChanges(self, base_name: str, activate_after_success: bool = False) -> None: """Create quality changes containers from the user containers in the active stacks. This will go through the global and extruder stacks and create quality_changes containers from the user @@ -233,6 +234,14 @@ class QualityManagementModel(ListModel): container_registry.addContainer(new_changes) + if activate_after_success: + # At this point, the QualityChangesGroup object for the new changes may not exist yet. + # This can be forced by asking for all of them. At that point it's just as well to loop. + for quality_changes in ContainerTree.getInstance().getCurrentQualityChangesGroups(): + if quality_changes.name == unique_name: + machine_manager.setQualityChangesGroup(quality_changes) + break + def _createQualityChanges(self, quality_type: str, intent_category: Optional[str], new_name: str, machine: "GlobalStack", extruder_stack: Optional["ExtruderStack"]) -> "InstanceContainer": """Create a quality changes container with the given set-up. diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 55da131df0..e63829936b 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -494,13 +494,7 @@ UM.MainWindow Connections { target: Cura.Actions.addProfile - function onTriggered() - { - preferences.show(); - preferences.setPage(4); - // Create a new profile after a very short delay so the preference page has time to initiate - createProfileTimer.start(); - } + function onTriggered() { createNewQualityDialog.visible = true; } } Connections @@ -547,15 +541,6 @@ UM.MainWindow } } - Timer - { - id: createProfileTimer - repeat: false - interval: 1 - - onTriggered: preferences.getCurrentItem().createProfile() - } - // BlurSettings is a way to force the focus away from any of the setting items. // We need to do this in order to keep the bindings intact. Connections @@ -887,6 +872,15 @@ UM.MainWindow } } + Cura.RenameDialog + { + id: createNewQualityDialog + title: catalog.i18nc("@title:window", "Save Custom Profile") + object: catalog.i18nc("@textfield:placeholder", "") + explanation: catalog.i18nc("@info", "Custom profile name:") + onAccepted: CuraApplication.getQualityManagementModel().createQualityChanges(newName, true); + } + /** * Function to check whether a QML object has a certain type. * Taken from StackOverflow: https://stackoverflow.com/a/28384228 and diff --git a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml index 461765df07..4cae54158b 100644 --- a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml +++ b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml @@ -15,7 +15,7 @@ UM.Dialog property alias state: alternateStates.state onAccepted: alternateStates.state == "" ? CuraApplication.discardOrKeepProfileChangesClosed("discard") : Cura.Actions.addProfile.trigger() - onRejected: alternateStates.state == "" ? CuraApplication.discardOrKeepProfileChangesClosed("keep") : Cura.Actions.addProfile.trigger() + onRejected: alternateStates.state == "" ? CuraApplication.discardOrKeepProfileChangesClosed("keep") : Cura.Actions.updateProfile.trigger() minimumWidth: UM.Theme.getSize("popup_dialog").width minimumHeight: UM.Theme.getSize("popup_dialog").height @@ -160,6 +160,7 @@ UM.Dialog { // Workaround: If this placeholder isn't in here, then on repeated state-changes of the window, the rightButtons will be in the center (despite initially showing up right). visible: alternateStates.state != "" + color: base.backgroundColor implicitHeight: UM.Theme.getSize("combobox").height implicitWidth: UM.Theme.getSize("combobox").width } diff --git a/resources/qml/Preferences/RenameDialog.qml b/resources/qml/Dialogs/RenameDialog.qml similarity index 86% rename from resources/qml/Preferences/RenameDialog.qml rename to resources/qml/Dialogs/RenameDialog.qml index 7bcd65ed5d..bfb75276d4 100644 --- a/resources/qml/Preferences/RenameDialog.qml +++ b/resources/qml/Dialogs/RenameDialog.qml @@ -21,6 +21,9 @@ UM.Dialog property string validationError property string dialogTitle: catalog.i18nc("@title:window", "Rename") property string explanation: catalog.i18nc("@info", "Please provide a new name.") + property string okButtonText: catalog.i18nc("@action:button", "OK") + + property list extraInfo title: dialogTitle backgroundColor: UM.Theme.getColor("main_background") @@ -60,6 +63,11 @@ UM.Dialog onTextChanged: base.textChanged(text) } + Row + { + children: extraInfo + } + UM.Label { visible: !base.validName @@ -67,20 +75,23 @@ UM.Dialog } } - rightButtons: [ - Cura.SecondaryButton + leftButtons: + [ + Cura.TertiaryButton { id: cancelButton text: catalog.i18nc("@action:button","Cancel") onClicked: base.reject() - }, + } + ] + rightButtons: + [ Cura.PrimaryButton { id: okButton - text: catalog.i18nc("@action:button", "OK") + text: base.okButtonText onClicked: base.accept() enabled: base.validName } ] } -