From 0ea2830108649ea14e5933245f5fee8075f3ceba Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 29 Nov 2022 22:54:30 +0100 Subject: [PATCH] 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 @@ + + + + + +