Browse Source

Appease reviewers.

- Ditch state in favour of enum.
- Comment explaining 'extraInfo'.

part of CURA-9347
Remco Burema 2 years ago
parent
commit
c74e7be602

+ 1 - 1
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

+ 5 - 2
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

+ 11 - 22
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()
         }
     ]

+ 2 - 0
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<Item> extraInfo
 
     title: dialogTitle

+ 8 - 1
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
         {