From d735921d42aa9ee1fdc6a5c8f31e5aae89bbdfc4 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 19 Oct 2017 08:32:26 +0200 Subject: [PATCH] Take into account the keep/discard interaction when emitting signals CURA-4248 When user switches to a different profile, the keep/discard dialog can show up. Don't emit signals immediately if this interaction takes place because it will trigger an unnecessary slice. --- cura/CuraApplication.py | 6 ++++-- cura/Settings/MachineManager.py | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 22fbbafab3..4b4f743a77 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -393,6 +393,7 @@ class CuraApplication(QtApplication): showDiscardOrKeepProfileChanges = pyqtSignal() def discardOrKeepProfileChanges(self): + has_user_interaction = False choice = Preferences.getInstance().getValue("cura/choice_on_profile_override") if choice == "always_discard": # don't show dialog and DISCARD the profile @@ -403,11 +404,12 @@ class CuraApplication(QtApplication): else: # ALWAYS ask whether to keep or discard the profile self.showDiscardOrKeepProfileChanges.emit() - - #sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal() + has_user_interaction = True + return has_user_interaction @pyqtSlot(str) def discardOrKeepProfileChangesClosed(self, option): + self.getMachineManager().activeQualityChanged.emit() if option == "discard": global_stack = self.getGlobalContainerStack() for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()): diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index e89e11898c..0db07485aa 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -858,8 +858,10 @@ class MachineManager(QObject): for stack in name_changed_connect_stacks: stack.nameChanged.connect(self._onQualityNameChanged) + has_user_interaction = False if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1: - self._askUserToKeepOrClearCurrentSettings() + # Show the keep/discard user settings dialog + has_user_interaction = Application.getInstance().discardOrKeepProfileChanges() else: # If the user doesn't have any of adjusted settings then slicing will be triggered by emit() # Send emits that are postponed in replaceContainer. @@ -867,7 +869,8 @@ class MachineManager(QObject): for setting_info in new_quality_settings_list: setting_info["stack"].sendPostponedEmits() - self.activeQualityChanged.emit() + if not has_user_interaction: + self.activeQualityChanged.emit() ## Determine the quality and quality changes settings for the current machine for a quality name. # @@ -986,9 +989,6 @@ class MachineManager(QObject): stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged) self._onQualityNameChanged() - def _askUserToKeepOrClearCurrentSettings(self): - Application.getInstance().discardOrKeepProfileChanges() - @pyqtProperty(str, notify = activeVariantChanged) def activeVariantName(self) -> str: if self._active_container_stack: