mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Pressing the discard button now actually discards the changes
CURA-3221
This commit is contained in:
parent
2462699982
commit
85b58c9296
3 changed files with 19 additions and 48 deletions
|
@ -331,14 +331,17 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
showDiscardOrKeepProfileChanges = pyqtSignal()
|
showDiscardOrKeepProfileChanges = pyqtSignal()
|
||||||
|
|
||||||
def discardOrKeepProfileChanges(self, callback = None, callback_arguments = []):
|
def discardOrKeepProfileChanges(self):
|
||||||
self._discard_or_keep_changes_callback = callback
|
|
||||||
self._discard_or_keep_changes_callback_arguments = callback_arguments
|
|
||||||
self.showDiscardOrKeepProfileChanges.emit()
|
self.showDiscardOrKeepProfileChanges.emit()
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(str)
|
||||||
def discardOrKeepProfileChangesClosed(self, button):
|
def discardOrKeepProfileChangesClosed(self, option):
|
||||||
pass
|
if option == "discard":
|
||||||
|
global_stack = self.getGlobalContainerStack()
|
||||||
|
for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
|
||||||
|
extruder.getTop().clear()
|
||||||
|
|
||||||
|
global_stack.getTop().clear()
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int)
|
||||||
def messageBoxClosed(self, button):
|
def messageBoxClosed(self, button):
|
||||||
|
|
|
@ -939,49 +939,7 @@ class MachineManager(QObject):
|
||||||
container.nameChanged.connect(self._onQualityNameChanged)
|
container.nameChanged.connect(self._onQualityNameChanged)
|
||||||
|
|
||||||
def _askUserToKeepOrClearCurrentSettings(self):
|
def _askUserToKeepOrClearCurrentSettings(self):
|
||||||
# Ask the user if the user profile should be cleared or not (discarding the current settings)
|
|
||||||
# In Simple Mode we assume the user always wants to keep the (limited) current settings
|
|
||||||
details_text = catalog.i18nc("@label", "You made changes to the following setting(s)/override(s):")
|
|
||||||
|
|
||||||
# user changes in global stack
|
|
||||||
details_list = [setting.definition.label for setting in self._global_container_stack.getTop().findInstances(**{})]
|
|
||||||
|
|
||||||
# user changes in extruder stacks
|
|
||||||
stacks = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()))
|
|
||||||
for stack in stacks:
|
|
||||||
details_list.extend([
|
|
||||||
"%s (%s)" % (setting.definition.label, stack.getName())
|
|
||||||
for setting in stack.getTop().findInstances(**{})])
|
|
||||||
|
|
||||||
# Format to output string
|
|
||||||
details = "\n ".join([details_text, ] + details_list)
|
|
||||||
|
|
||||||
num_changed_settings = len(details_list)
|
|
||||||
Application.getInstance().discardOrKeepProfileChanges()
|
Application.getInstance().discardOrKeepProfileChanges()
|
||||||
'''Application.getInstance().messageBox(
|
|
||||||
catalog.i18nc("@window:title", "Switched profiles"),
|
|
||||||
catalog.i18nc(
|
|
||||||
"@label",
|
|
||||||
"Do you want to transfer your %d changed setting(s)/override(s) to this profile?") % num_changed_settings,
|
|
||||||
catalog.i18nc(
|
|
||||||
"@label",
|
|
||||||
"If you transfer your settings they will override settings in the profile. If you don't transfer these settings, they will be lost."),
|
|
||||||
details,
|
|
||||||
buttons=QMessageBox.Yes + QMessageBox.No,
|
|
||||||
icon=QMessageBox.Question,
|
|
||||||
callback=self._keepUserSettingsDialogCallback)'''
|
|
||||||
|
|
||||||
def _keepUserSettingsDialogCallback(self, button):
|
|
||||||
if button == QMessageBox.Yes:
|
|
||||||
# Yes, keep the settings in the user profile with this profile
|
|
||||||
pass
|
|
||||||
elif button == QMessageBox.No:
|
|
||||||
# No, discard the settings in the user profile
|
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
|
||||||
for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
|
|
||||||
extruder.getTop().clear()
|
|
||||||
|
|
||||||
global_stack.getTop().clear()
|
|
||||||
|
|
||||||
@pyqtProperty(str, notify = activeVariantChanged)
|
@pyqtProperty(str, notify = activeVariantChanged)
|
||||||
def activeVariantName(self):
|
def activeVariantName(self):
|
||||||
|
|
|
@ -116,10 +116,20 @@ UM.Dialog
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:button", "Keep");
|
text: catalog.i18nc("@action:button", "Keep");
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
Printer.discardOrKeepProfileChangesClosed("keep")
|
||||||
|
base.hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:button", "Discard");
|
text: catalog.i18nc("@action:button", "Discard");
|
||||||
|
onClicked:
|
||||||
|
{
|
||||||
|
Printer.discardOrKeepProfileChangesClosed("discard")
|
||||||
|
base.hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue