Appease reviewers.

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

part of CURA-9347
This commit is contained in:
Remco Burema 2022-12-02 19:52:37 +01:00
parent 9fe261ff58
commit c74e7be602
5 changed files with 27 additions and 26 deletions

View file

@ -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

View file

@ -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

View file

@ -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()
}
]

View file

@ -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

View file

@ -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
{