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
This commit is contained in:
Remco Burema 2022-11-30 18:48:07 +01:00
parent c13deba1ea
commit 8f65af61e5
4 changed files with 38 additions and 23 deletions

View file

@ -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", "<New Custom Profile>")
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

View file

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

View file

@ -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<Item> 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
}
]
}