From 0ea2830108649ea14e5933245f5fee8075f3ceba Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 29 Nov 2022 22:54:30 +0100 Subject: [PATCH 01/10] Add the 'safe to profile' button itself. Currently only works for creating a new profile from current changes (when on top of a built-in profile). Only does the compare (not the safe yet) in the other circumstance. Also already anticipate the next commits by being able to hide the text and icon (because this will be added to the custom mode view as well). part of CURA-9347 --- cura/CuraApplication.py | 1 + .../Recommended/ProfileWarningReset.qml | 49 +++++++++++++++---- .../themes/cura-light/icons/default/Save.svg | 6 +++ 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 resources/themes/cura-light/icons/default/Save.svg diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 74811e724f..f2d945ba26 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -710,6 +710,7 @@ class CuraApplication(QtApplication): showDiscardOrKeepProfileChanges = pyqtSignal() + @pyqtSlot() def discardOrKeepProfileChanges(self) -> bool: has_user_interaction = False choice = self.getPreferences().getValue("cura/choice_on_profile_override") diff --git a/resources/qml/PrintSetupSelector/Recommended/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/Recommended/ProfileWarningReset.qml index 10f006538b..db1fbd3cd5 100644 --- a/resources/qml/PrintSetupSelector/Recommended/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/Recommended/ProfileWarningReset.qml @@ -1,3 +1,6 @@ +//Copyright (C) 2022 UltiMaker B.V. +//Cura is released under the terms of the LGPLv3 or higher. + import QtQuick 2.10 import UM 1.6 as UM @@ -5,15 +8,18 @@ import Cura 1.6 as Cura Item { + property bool fullWarning: true // <- Can you see the warning icon and the text, or is it just the buttons? + height: visible ? UM.Theme.getSize("action_button_icon").height : 0 visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.MachineManager.hasCustomQuality Rectangle { id: warningIcon + visible: fullWarning color: UM.Theme.getColor("um_yellow_5") height: UM.Theme.getSize("action_button_icon").height - width: height + width: visible ? height : 0 radius: width anchors { @@ -31,7 +37,8 @@ Item UM.Label { id: warning - width: parent.width - warningIcon.width - resetToDefaultQualityButton.width + visible: fullWarning + width: visible ? parent.width - warningIcon.width - (compareAndSaveButton.width + resetToDefaultQualityButton.width) : 0 anchors { left: warningIcon.right @@ -80,7 +87,33 @@ Item } } ] + } + UM.SimpleButton + { + id: compareAndSaveButton + height: UM.Theme.getSize("action_button_icon").height + width: height + iconSource: UM.Theme.getIcon("Save") + anchors + { + right: buttonsSpacer.left + verticalCenter: parent.verticalCenter + } + + color: enabled ? UM.Theme.getColor("accent_1") : UM.Theme.getColor("disabled") + hoverColor: UM.Theme.getColor("primary_hover") + + enabled: Cura.SimpleModeSettingsManager.isProfileCustomized + onClicked: Cura.MachineManager.hasCustomQuality ? CuraApplication.discardOrKeepProfileChanges() : Cura.Actions.addProfile.trigger() + } + + // Spacer + Item + { + id: buttonsSpacer + width: UM.Theme.getSize("action_button_icon").height + anchors.right: resetToDefaultQualityButton.left } UM.SimpleButton @@ -95,12 +128,10 @@ Item verticalCenter: parent.verticalCenter } - color: UM.Theme.getColor("accent_1") + color: enabled ? UM.Theme.getColor("accent_1") : UM.Theme.getColor("disabled") + hoverColor: UM.Theme.getColor("primary_hover") - onClicked: - { - Cura.MachineManager.resetToUseDefaultQuality() - } + enabled: Cura.MachineManager.hasCustomQuality || Cura.SimpleModeSettingsManager.isProfileCustomized + onClicked: Cura.MachineManager.resetToUseDefaultQuality() } - -} \ No newline at end of file +} diff --git a/resources/themes/cura-light/icons/default/Save.svg b/resources/themes/cura-light/icons/default/Save.svg new file mode 100644 index 0000000000..61887b084c --- /dev/null +++ b/resources/themes/cura-light/icons/default/Save.svg @@ -0,0 +1,6 @@ + + + + + + From 40b7233125aa0a8846784eeeaa0e0d6290012655 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 29 Nov 2022 23:18:15 +0100 Subject: [PATCH 02/10] Also add save/reset buttons to custom profile. part of CURA-9347 --- .../PrintSetupSelector/Custom/CustomPrintSetup.qml | 12 ++++++++++-- .../{Recommended => }/ProfileWarningReset.qml | 0 .../Recommended/RecommendedPrintSetup.qml | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) rename resources/qml/PrintSetupSelector/{Recommended => }/ProfileWarningReset.qml (100%) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index e64f211cd1..4453e0666c 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -52,8 +52,8 @@ Item id: intentSelection onClicked: menu.opened ? menu.close() : menu.open() - anchors.right: parent.right - width: UM.Theme.getSize("print_setup_big_item").width + anchors.right: profileWarningReset.left + width: UM.Theme.getSize("print_setup_big_item").width - profileWarningReset.width height: textLabel.contentHeight + 2 * UM.Theme.getSize("narrow_margin").height hoverEnabled: true @@ -152,6 +152,14 @@ Item } } + ProfileWarningReset + { + id: profileWarningReset + fullWarning: false + anchors.right: parent.right + width: childrenRect.width + } + QualitiesWithIntentMenu { id: menu diff --git a/resources/qml/PrintSetupSelector/Recommended/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml similarity index 100% rename from resources/qml/PrintSetupSelector/Recommended/ProfileWarningReset.qml rename to resources/qml/PrintSetupSelector/ProfileWarningReset.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 94de16141f..37517709a9 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -6,6 +6,7 @@ import QtQuick.Layouts 1.1 import UM 1.6 as UM import Cura 1.6 as Cura +import ".." Item { From 79629e477d639cc5e8b7b366b0dccc4f49ee064e Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 29 Nov 2022 23:39:24 +0100 Subject: [PATCH 03/10] Small stuff: Swap Icons. Tooltips. Remove reduntant entries. part of CURA-9347 --- .../Custom/QualitiesWithIntentMenu.qml | 52 ------------------- .../ProfileWarningReset.qml | 32 ++++++++---- 2 files changed, 23 insertions(+), 61 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml index a2624dbf14..1aa10a9b42 100644 --- a/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml +++ b/resources/qml/PrintSetupSelector/Custom/QualitiesWithIntentMenu.qml @@ -223,58 +223,6 @@ Popup color: borderColor } - MenuButton - { - labelText: Cura.Actions.addProfile.text - - anchors.left: parent.left - anchors.right: parent.right - - enabled: Cura.Actions.addProfile.enabled - onClicked: - { - Cura.Actions.addProfile.trigger() - popup.visible = false - } - } - MenuButton - { - labelText: Cura.Actions.updateProfile.text - anchors.left: parent.left - anchors.right: parent.right - - enabled: Cura.Actions.updateProfile.enabled - - onClicked: - { - popup.visible = false - Cura.Actions.updateProfile.trigger() - } - } - MenuButton - { - text: catalog.i18nc("@action:button", "Discard current changes") - - anchors.left: parent.left - anchors.right: parent.right - - enabled: Cura.MachineManager.hasUserSettings - - onClicked: - { - popup.visible = false - Cura.ContainerManager.clearUserContainers() - } - } - - Rectangle - { - height: UM.Theme.getSize("default_lining").width - anchors.left: parent.left - anchors.right: parent.right - color: borderColor - } - MenuButton { id: manageProfilesButton diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index db1fbd3cd5..4702f3dba8 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -91,10 +91,10 @@ Item UM.SimpleButton { - id: compareAndSaveButton + id: resetToDefaultQualityButton height: UM.Theme.getSize("action_button_icon").height width: height - iconSource: UM.Theme.getIcon("Save") + iconSource: UM.Theme.getIcon("ArrowReset") anchors { right: buttonsSpacer.left @@ -104,8 +104,15 @@ Item color: enabled ? UM.Theme.getColor("accent_1") : UM.Theme.getColor("disabled") hoverColor: UM.Theme.getColor("primary_hover") - enabled: Cura.SimpleModeSettingsManager.isProfileCustomized - onClicked: Cura.MachineManager.hasCustomQuality ? CuraApplication.discardOrKeepProfileChanges() : Cura.Actions.addProfile.trigger() + enabled: Cura.MachineManager.hasCustomQuality || Cura.SimpleModeSettingsManager.isProfileCustomized + onClicked: Cura.MachineManager.resetToUseDefaultQuality() + + UM.ToolTip + { + visible: parent.hovered + targetPoint: Qt.point(parent.x - width, Math.round(parent.y + parent.height / 2)) + tooltipText: catalog.i18nc("@info", "Reset to defaults.") + } } // Spacer @@ -113,15 +120,15 @@ Item { id: buttonsSpacer width: UM.Theme.getSize("action_button_icon").height - anchors.right: resetToDefaultQualityButton.left + anchors.right: compareAndSaveButton.left } UM.SimpleButton { - id: resetToDefaultQualityButton + id: compareAndSaveButton height: UM.Theme.getSize("action_button_icon").height width: height - iconSource: UM.Theme.getIcon("ArrowReset") + iconSource: UM.Theme.getIcon("Save") anchors { right: parent.right @@ -131,7 +138,14 @@ Item color: enabled ? UM.Theme.getColor("accent_1") : UM.Theme.getColor("disabled") hoverColor: UM.Theme.getColor("primary_hover") - enabled: Cura.MachineManager.hasCustomQuality || Cura.SimpleModeSettingsManager.isProfileCustomized - onClicked: Cura.MachineManager.resetToUseDefaultQuality() + enabled: Cura.SimpleModeSettingsManager.isProfileCustomized + onClicked: Cura.MachineManager.hasCustomQuality ? CuraApplication.discardOrKeepProfileChanges() : Cura.Actions.addProfile.trigger() + + UM.ToolTip + { + visible: parent.hovered + targetPoint: Qt.point(parent.x - width, Math.round(parent.y + parent.height / 2)) + tooltipText: catalog.i18nc("@info", "Compare and safe.") + } } } From c13deba1ea080946e1e62ed9d4c76eb0ad89b142 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 30 Nov 2022 12:40:07 +0100 Subject: [PATCH 04/10] Build correct states for safe profiles flow (except actual safe). Re-use Discard Or Keep dialogue, but have different buttons. (Safe to New/Override instead of Keep/Discard.) The actual safa action is still the old one though (for either new button, it still goes to the old 'make a new profile' action). Besides that, some cosmetics have to be done to the texts as well still. part of CURA-9347 --- cura/CuraApplication.py | 2 +- resources/qml/Cura.qml | 4 +- .../DiscardOrKeepProfileChangesDialog.qml | 48 +++++++++++++++++-- .../ProfileWarningReset.qml | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index f2d945ba26..8939aec07a 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -709,8 +709,8 @@ class CuraApplication(QtApplication): self.showMessageBox.emit(title, text, informativeText, detailedText, buttons, icon) showDiscardOrKeepProfileChanges = pyqtSignal() + showCompareAndSaveProfileChanges = pyqtSignal(str) - @pyqtSlot() def discardOrKeepProfileChanges(self) -> bool: has_user_interaction = False choice = self.getPreferences().getValue("cura/choice_on_profile_override") diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 2ec342f502..55da131df0 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -816,11 +816,13 @@ UM.MainWindow Connections { target: CuraApplication - function onShowDiscardOrKeepProfileChanges() + function onShowCompareAndSaveProfileChanges(profileState) { discardOrKeepProfileChangesDialogLoader.sourceComponent = discardOrKeepProfileChangesDialogComponent + discardOrKeepProfileChangesDialogLoader.item.state = profileState discardOrKeepProfileChangesDialogLoader.item.show() } + function onShowDiscardOrKeepProfileChanges() { onShowCompareAndSaveProfileChanges("") } } Cura.WizardDialog diff --git a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml index 0fecb6b662..461765df07 100644 --- a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml +++ b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml @@ -12,8 +12,10 @@ UM.Dialog id: base title: catalog.i18nc("@title:window", "Discard or Keep changes") - onAccepted: CuraApplication.discardOrKeepProfileChangesClosed("discard") - onRejected: CuraApplication.discardOrKeepProfileChangesClosed("keep") + 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() minimumWidth: UM.Theme.getSize("popup_dialog").width minimumHeight: UM.Theme.getSize("popup_dialog").height @@ -98,9 +100,26 @@ UM.Dialog buttonSpacing: UM.Theme.getSize("thin_margin").width - leftButtons: [ + Rectangle + { + // Use a rectangle to get access to states. For some reason top-levels like Dialog/Window ect. don't have them. + // NOTE: The default state is 'switch profiles', alternate states are used for 'save from [built-in|custom]'. + id: alternateStates + width: 0 + height: 0 + states: + [ + State { name: "saveFromBuiltIn" }, + State { name: "saveFromCustom" } + ] + } + + leftButtons: + [ Cura.ComboBox { + visible: alternateStates.state == "" + implicitHeight: UM.Theme.getSize("combobox").height implicitWidth: UM.Theme.getSize("combobox").width @@ -136,6 +155,13 @@ UM.Dialog discardButton.enabled = true; } } + }, + Rectangle + { + // 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 != "" + implicitHeight: UM.Theme.getSize("combobox").height + implicitWidth: UM.Theme.getSize("combobox").width } ] @@ -146,12 +172,28 @@ UM.Dialog id: discardButton text: catalog.i18nc("@action:button", "Discard changes") onClicked: base.accept() + visible: alternateStates.state == "" }, Cura.SecondaryButton { id: keepButton text: catalog.i18nc("@action:button", "Keep changes") onClicked: base.reject() + visible: alternateStates.state == "" + }, + Cura.SecondaryButton + { + id: overwriteButton + text: catalog.i18nc("@action:button", "Save as new custom profile") + onClicked: base.accept() + visible: alternateStates.state != "" + }, + Cura.PrimaryButton + { + id: saveButton + text: catalog.i18nc("@action:button", "Save changes") + onClicked: base.reject() + visible: alternateStates.state == "saveFromCustom" } ] } diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index 4702f3dba8..17d59981fa 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -139,7 +139,7 @@ Item hoverColor: UM.Theme.getColor("primary_hover") enabled: Cura.SimpleModeSettingsManager.isProfileCustomized - onClicked: Cura.MachineManager.hasCustomQuality ? CuraApplication.discardOrKeepProfileChanges() : Cura.Actions.addProfile.trigger() + onClicked: CuraApplication.showCompareAndSaveProfileChanges(Cura.MachineManager.hasCustomQuality ? "saveFromCustom" : "saveFromBuiltIn") UM.ToolTip { From 8f65af61e57b9daaf8366374f2d440975fb97ea3 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 30 Nov 2022 18:48:07 +0100 Subject: [PATCH 05/10] Connect compare-and-safe profile dialog buttons to actions. Some rework was needed as to not get the entire Preferences window to show up, which previously came along with the add profile action. part of CURA-9347 --- .../Machines/Models/QualityManagementModel.py | 11 +++++++- resources/qml/Cura.qml | 26 +++++++------------ .../DiscardOrKeepProfileChangesDialog.qml | 3 ++- .../{Preferences => Dialogs}/RenameDialog.qml | 21 +++++++++++---- 4 files changed, 38 insertions(+), 23 deletions(-) rename resources/qml/{Preferences => Dialogs}/RenameDialog.qml (86%) 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 } ] } - From 6f651b922a6852acdf59cf3ec24c8e74d1abf95f Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 30 Nov 2022 19:54:41 +0100 Subject: [PATCH 06/10] Profile compare-and-save: Add (more) explanatory text(s). part of CURA-9347 --- resources/qml/Cura.qml | 23 +++++++++++++++++++ resources/qml/Dialogs/RenameDialog.qml | 18 ++++++++++++++- .../ProfileWarningReset.qml | 6 ++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index e63829936b..2ba14a2d95 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -878,6 +878,29 @@ UM.MainWindow title: catalog.i18nc("@title:window", "Save Custom Profile") object: catalog.i18nc("@textfield:placeholder", "") explanation: catalog.i18nc("@info", "Custom profile name:") + extraInfo: + [ + UM.ColorImage + { + width: UM.Theme.getSize("message_type_icon").width + height: UM.Theme.getSize("message_type_icon").height + source: UM.Theme.getIcon("Information") + color: UM.Theme.getColor("text") + }, + UM.Label + { + text: catalog.i18nc + ( + "@label %i will be replaced with a profile name", + "Only user changed settings will be saved in the custom profile.
" + + "The new custom profile will inherit properties from %1,
" + + "for materials that support it.
" + + "Learn more about Cura print profiles" + ).arg(Cura.MachineManager.activeQualityOrQualityChangesName).arg("https://support.ultimaker.com/s/article/1667337576882") + wrapMode: Text.WordWrap + } + ] + okButtonText: catalog.i18nc("@button", "Save new profile") onAccepted: CuraApplication.getQualityManagementModel().createQualityChanges(newName, true); } diff --git a/resources/qml/Dialogs/RenameDialog.qml b/resources/qml/Dialogs/RenameDialog.qml index bfb75276d4..cbc8ad8224 100644 --- a/resources/qml/Dialogs/RenameDialog.qml +++ b/resources/qml/Dialogs/RenameDialog.qml @@ -28,7 +28,7 @@ UM.Dialog title: dialogTitle backgroundColor: UM.Theme.getColor("main_background") minimumWidth: UM.Theme.getSize("small_popup_dialog").width - minimumHeight: UM.Theme.getSize("small_popup_dialog").height + minimumHeight: UM.Theme.getSize("small_popup_dialog").height + extraInfoHolder.height width: minimumWidth height: minimumHeight @@ -63,8 +63,24 @@ UM.Dialog onTextChanged: base.textChanged(text) } + // spacer + Rectangle + { + color: base.backgroundColor + height: UM.Theme.getSize("wide_margin").height + width: height + } + Row { + id: extraInfoHolder + anchors + { + left: parent.left + right: parent.right + margins: UM.Theme.getSize("default_margin").height + } + spacing: UM.Theme.getSize("default_margin").height children: extraInfo } diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index 17d59981fa..d703296181 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -83,7 +83,11 @@ Item PropertyChanges { target: warning - text: catalog.i18nc("@info", "Some settings were changed.") + text: + { + var profile_name = Cura.MachineManager.activeQualityOrQualityChangesName; + return catalog.i18nc("@info %1 is the name of a profile", "Some setting-values defined in %1 were overridden.").arg(profile_name); + } } } ] From 3bc955fe8fb0926744448dfdc47dcace276cb7c9 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Thu, 1 Dec 2022 14:57:05 +0100 Subject: [PATCH 07/10] Fix review comments. - Text was cutoff instead of wrapped in Save Custom Profile (Rename Dialog). - Make the placeholder into a proper placeholder text. - Fix spelling (save -> safe). - Link didn't work as a link. - Slightly better tooltips. part of CURA-9347 --- resources/qml/Cura.qml | 33 ++++++++++++------- .../DiscardOrKeepProfileChangesDialog.qml | 8 ----- resources/qml/Dialogs/RenameDialog.qml | 3 ++ .../ProfileWarningReset.qml | 8 +++-- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 2ba14a2d95..b70fc087ed 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -876,7 +876,7 @@ UM.MainWindow { id: createNewQualityDialog title: catalog.i18nc("@title:window", "Save Custom Profile") - object: catalog.i18nc("@textfield:placeholder", "") + objectPlaceholder: catalog.i18nc("@textfield:placeholder", "New Custom Profile") explanation: catalog.i18nc("@info", "Custom profile name:") extraInfo: [ @@ -887,17 +887,28 @@ UM.MainWindow source: UM.Theme.getIcon("Information") color: UM.Theme.getColor("text") }, - UM.Label + Column { - text: catalog.i18nc - ( - "@label %i will be replaced with a profile name", - "Only user changed settings will be saved in the custom profile.
" + - "The new custom profile will inherit properties from %1,
" + - "for materials that support it.
" + - "Learn more about Cura print profiles" - ).arg(Cura.MachineManager.activeQualityOrQualityChangesName).arg("https://support.ultimaker.com/s/article/1667337576882") - wrapMode: Text.WordWrap + UM.Label + { + text: catalog.i18nc + ( + "@label %i will be replaced with a profile name", + "Only user changed settings will be saved in the custom profile.
" + + "For materials that support it, the new custom profile will inherit properties from %1." + ).arg(Cura.MachineManager.activeQualityOrQualityChangesName) + wrapMode: Text.WordWrap + width: parent.parent.width - 2 * UM.Theme.getSize("message_type_icon").width + } + Cura.TertiaryButton + { + text: "Learn more about Cura print profiles" + iconSource: UM.Theme.getIcon("LinkExternal") + isIconOnRightSide: true + leftPadding: 0 + rightPadding: 0 + onClicked: Qt.openUrlExternally("https://support.ultimaker.com/s/article/1667337576882") + } } ] okButtonText: catalog.i18nc("@button", "Save new profile") diff --git a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml index 4cae54158b..ea2a690321 100644 --- a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml +++ b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml @@ -155,14 +155,6 @@ UM.Dialog discardButton.enabled = true; } } - }, - Rectangle - { - // 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/Dialogs/RenameDialog.qml b/resources/qml/Dialogs/RenameDialog.qml index cbc8ad8224..1b3fd7f8e8 100644 --- a/resources/qml/Dialogs/RenameDialog.qml +++ b/resources/qml/Dialogs/RenameDialog.qml @@ -15,6 +15,7 @@ UM.Dialog buttonSpacing: UM.Theme.getSize("default_margin").width property string object: "" + property string objectPlaceholder: "" property alias newName: nameField.text property bool validName: true @@ -58,6 +59,8 @@ UM.Dialog id: nameField width: parent.width text: base.object + placeholderText: base.objectPlaceholder + placeholderTextColor: UM.Theme.getColor("text_field_text_disabled") maximumLength: 40 selectByMouse: true onTextChanged: base.textChanged(text) diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index d703296181..bd85f2dac6 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -114,7 +114,8 @@ Item UM.ToolTip { visible: parent.hovered - targetPoint: Qt.point(parent.x - width, Math.round(parent.y + parent.height / 2)) + y: parent.y + parent.height + UM.Theme.getSize("default_margin").height + targetPoint: Qt.point(parent.x, Math.round(parent.y + parent.height / 2)) tooltipText: catalog.i18nc("@info", "Reset to defaults.") } } @@ -148,8 +149,9 @@ Item UM.ToolTip { visible: parent.hovered - targetPoint: Qt.point(parent.x - width, Math.round(parent.y + parent.height / 2)) - tooltipText: catalog.i18nc("@info", "Compare and safe.") + y: parent.y + parent.height + UM.Theme.getSize("default_margin").height + targetPoint: Qt.point(parent.x, Math.round(parent.y + parent.height / 2)) + tooltipText: catalog.i18nc("@info", "Compare and save.") } } } From 9fe261ff58742726e984e7af07669c2f5f880ee2 Mon Sep 17 00:00:00 2001 From: Remco Burema <41987080+rburema@users.noreply.github.com> Date: Fri, 2 Dec 2022 19:07:41 +0100 Subject: [PATCH 08/10] Apply suggestions from code review. part of CURA-9347 Co-authored-by: Joey de l'Arago --- resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml | 4 ++-- resources/qml/Dialogs/RenameDialog.qml | 3 +-- resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml index ea2a690321..1876f926a7 100644 --- a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml +++ b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml @@ -178,15 +178,15 @@ UM.Dialog { id: overwriteButton text: catalog.i18nc("@action:button", "Save as new custom profile") - onClicked: base.accept() visible: alternateStates.state != "" + onClicked: base.accept() }, Cura.PrimaryButton { id: saveButton text: catalog.i18nc("@action:button", "Save changes") - onClicked: base.reject() visible: alternateStates.state == "saveFromCustom" + onClicked: base.reject() } ] } diff --git a/resources/qml/Dialogs/RenameDialog.qml b/resources/qml/Dialogs/RenameDialog.qml index 1b3fd7f8e8..eae3bff098 100644 --- a/resources/qml/Dialogs/RenameDialog.qml +++ b/resources/qml/Dialogs/RenameDialog.qml @@ -67,9 +67,8 @@ UM.Dialog } // spacer - Rectangle + Item { - color: base.backgroundColor height: UM.Theme.getSize("wide_margin").height width: height } diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 4453e0666c..5742e12a3c 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -155,9 +155,9 @@ Item ProfileWarningReset { id: profileWarningReset - fullWarning: false - anchors.right: parent.right width: childrenRect.width + anchors.right: parent.right + fullWarning: false } QualitiesWithIntentMenu From c74e7be60271f09fe1577e766137f7b4a45bf9a0 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Fri, 2 Dec 2022 19:52:37 +0100 Subject: [PATCH 09/10] Appease reviewers. - Ditch state in favour of enum. - Comment explaining 'extraInfo'. part of CURA-9347 --- cura/CuraApplication.py | 2 +- resources/qml/Cura.qml | 7 ++-- .../DiscardOrKeepProfileChangesDialog.qml | 33 +++++++------------ resources/qml/Dialogs/RenameDialog.qml | 2 ++ .../ProfileWarningReset.qml | 9 ++++- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 8939aec07a..7f9f0ef68d 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -709,7 +709,7 @@ class CuraApplication(QtApplication): self.showMessageBox.emit(title, text, informativeText, detailedText, buttons, icon) showDiscardOrKeepProfileChanges = pyqtSignal() - showCompareAndSaveProfileChanges = pyqtSignal(str) + showCompareAndSaveProfileChanges = pyqtSignal(int) def discardOrKeepProfileChanges(self) -> bool: has_user_interaction = False diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index b70fc087ed..8ae3c01c71 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -804,10 +804,13 @@ UM.MainWindow function onShowCompareAndSaveProfileChanges(profileState) { discardOrKeepProfileChangesDialogLoader.sourceComponent = discardOrKeepProfileChangesDialogComponent - discardOrKeepProfileChangesDialogLoader.item.state = profileState + discardOrKeepProfileChangesDialogLoader.item.buttonState = profileState discardOrKeepProfileChangesDialogLoader.item.show() } - function onShowDiscardOrKeepProfileChanges() { onShowCompareAndSaveProfileChanges("") } + function onShowDiscardOrKeepProfileChanges() + { + onShowCompareAndSaveProfileChanges(DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep) + } } Cura.WizardDialog diff --git a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml index 1876f926a7..8dbe18ccff 100644 --- a/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml +++ b/resources/qml/Dialogs/DiscardOrKeepProfileChangesDialog.qml @@ -12,10 +12,13 @@ UM.Dialog id: base title: catalog.i18nc("@title:window", "Discard or Keep changes") - property alias state: alternateStates.state + enum ButtonsType { DiscardOrKeep, SaveFromBuiltIn, SaveFromCustom} + property int buttonState: DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep - onAccepted: alternateStates.state == "" ? CuraApplication.discardOrKeepProfileChangesClosed("discard") : Cura.Actions.addProfile.trigger() - onRejected: alternateStates.state == "" ? CuraApplication.discardOrKeepProfileChangesClosed("keep") : Cura.Actions.updateProfile.trigger() + onAccepted: buttonState == DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep ? + CuraApplication.discardOrKeepProfileChangesClosed("discard") : Cura.Actions.addProfile.trigger() + onRejected: buttonState == DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep ? + CuraApplication.discardOrKeepProfileChangesClosed("keep") : Cura.Actions.updateProfile.trigger() minimumWidth: UM.Theme.getSize("popup_dialog").width minimumHeight: UM.Theme.getSize("popup_dialog").height @@ -100,25 +103,11 @@ UM.Dialog buttonSpacing: UM.Theme.getSize("thin_margin").width - Rectangle - { - // Use a rectangle to get access to states. For some reason top-levels like Dialog/Window ect. don't have them. - // NOTE: The default state is 'switch profiles', alternate states are used for 'save from [built-in|custom]'. - id: alternateStates - width: 0 - height: 0 - states: - [ - State { name: "saveFromBuiltIn" }, - State { name: "saveFromCustom" } - ] - } - leftButtons: [ Cura.ComboBox { - visible: alternateStates.state == "" + visible: buttonState == DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep implicitHeight: UM.Theme.getSize("combobox").height implicitWidth: UM.Theme.getSize("combobox").width @@ -165,27 +154,27 @@ UM.Dialog id: discardButton text: catalog.i18nc("@action:button", "Discard changes") onClicked: base.accept() - visible: alternateStates.state == "" + visible: buttonState == DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep }, Cura.SecondaryButton { id: keepButton text: catalog.i18nc("@action:button", "Keep changes") onClicked: base.reject() - visible: alternateStates.state == "" + visible: buttonState == DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep }, Cura.SecondaryButton { id: overwriteButton text: catalog.i18nc("@action:button", "Save as new custom profile") - visible: alternateStates.state != "" + visible: buttonState != DiscardOrKeepProfileChangesDialog.ButtonsType.DiscardOrKeep onClicked: base.accept() }, Cura.PrimaryButton { id: saveButton text: catalog.i18nc("@action:button", "Save changes") - visible: alternateStates.state == "saveFromCustom" + visible: buttonState == DiscardOrKeepProfileChangesDialog.ButtonsType.SaveFromCustom onClicked: base.reject() } ] diff --git a/resources/qml/Dialogs/RenameDialog.qml b/resources/qml/Dialogs/RenameDialog.qml index eae3bff098..52cfe3a26e 100644 --- a/resources/qml/Dialogs/RenameDialog.qml +++ b/resources/qml/Dialogs/RenameDialog.qml @@ -24,6 +24,8 @@ UM.Dialog property string explanation: catalog.i18nc("@info", "Please provide a new name.") property string okButtonText: catalog.i18nc("@action:button", "OK") + // Extra Information for the user about the current rename can go here, can be left alone if not needed. + // For example; An icon and a text-field and a tertiary button providing a link. property list extraInfo title: dialogTitle diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index bd85f2dac6..6c498cbb3c 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -6,6 +6,8 @@ import QtQuick 2.10 import UM 1.6 as UM import Cura 1.6 as Cura +import "../Dialogs" + Item { property bool fullWarning: true // <- Can you see the warning icon and the text, or is it just the buttons? @@ -144,7 +146,12 @@ Item hoverColor: UM.Theme.getColor("primary_hover") enabled: Cura.SimpleModeSettingsManager.isProfileCustomized - onClicked: CuraApplication.showCompareAndSaveProfileChanges(Cura.MachineManager.hasCustomQuality ? "saveFromCustom" : "saveFromBuiltIn") + onClicked: CuraApplication.showCompareAndSaveProfileChanges + ( + Cura.MachineManager.hasCustomQuality ? + DiscardOrKeepProfileChangesDialog.ButtonsType.SaveFromCustom : + DiscardOrKeepProfileChangesDialog.ButtonsType.SaveFromBuiltIn + ) UM.ToolTip { From e91d5df3a37f092eb243507ec203f96d0f89a161 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Mon, 5 Dec 2022 10:39:20 +0100 Subject: [PATCH 10/10] Apply suggestions from code review --- resources/qml/Cura.qml | 7 +++++-- resources/qml/PrintSetupSelector/ProfileWarningReset.qml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 8ae3c01c71..6e36587b23 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -494,7 +494,10 @@ UM.MainWindow Connections { target: Cura.Actions.addProfile - function onTriggered() { createNewQualityDialog.visible = true; } + function onTriggered() + { + createNewQualityDialog.visible = true; + } } Connections @@ -905,7 +908,7 @@ UM.MainWindow } Cura.TertiaryButton { - text: "Learn more about Cura print profiles" + text: catalog.i18nc("@action:button", "Learn more about Cura print profiles") iconSource: UM.Theme.getIcon("LinkExternal") isIconOnRightSide: true leftPadding: 0 diff --git a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml index 6c498cbb3c..5e6a3d8157 100644 --- a/resources/qml/PrintSetupSelector/ProfileWarningReset.qml +++ b/resources/qml/PrintSetupSelector/ProfileWarningReset.qml @@ -1,5 +1,5 @@ -//Copyright (C) 2022 UltiMaker B.V. -//Cura is released under the terms of the LGPLv3 or higher. +// Copyright (C) 2022 UltiMaker +// Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.10