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.
This commit is contained in:
Lipu Fei 2017-10-19 08:32:26 +02:00
parent 85f2a7c385
commit d735921d42
2 changed files with 9 additions and 7 deletions

View file

@ -393,6 +393,7 @@ class CuraApplication(QtApplication):
showDiscardOrKeepProfileChanges = pyqtSignal() showDiscardOrKeepProfileChanges = pyqtSignal()
def discardOrKeepProfileChanges(self): def discardOrKeepProfileChanges(self):
has_user_interaction = False
choice = Preferences.getInstance().getValue("cura/choice_on_profile_override") choice = Preferences.getInstance().getValue("cura/choice_on_profile_override")
if choice == "always_discard": if choice == "always_discard":
# don't show dialog and DISCARD the profile # don't show dialog and DISCARD the profile
@ -403,11 +404,12 @@ class CuraApplication(QtApplication):
else: else:
# ALWAYS ask whether to keep or discard the profile # ALWAYS ask whether to keep or discard the profile
self.showDiscardOrKeepProfileChanges.emit() self.showDiscardOrKeepProfileChanges.emit()
has_user_interaction = True
#sidebarSimpleDiscardOrKeepProfileChanges = pyqtSignal() return has_user_interaction
@pyqtSlot(str) @pyqtSlot(str)
def discardOrKeepProfileChangesClosed(self, option): def discardOrKeepProfileChangesClosed(self, option):
self.getMachineManager().activeQualityChanged.emit()
if option == "discard": if option == "discard":
global_stack = self.getGlobalContainerStack() global_stack = self.getGlobalContainerStack()
for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()): for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):

View file

@ -858,8 +858,10 @@ class MachineManager(QObject):
for stack in name_changed_connect_stacks: for stack in name_changed_connect_stacks:
stack.nameChanged.connect(self._onQualityNameChanged) stack.nameChanged.connect(self._onQualityNameChanged)
has_user_interaction = False
if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1: 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: else:
# If the user doesn't have any of adjusted settings then slicing will be triggered by emit() # If the user doesn't have any of adjusted settings then slicing will be triggered by emit()
# Send emits that are postponed in replaceContainer. # Send emits that are postponed in replaceContainer.
@ -867,7 +869,8 @@ class MachineManager(QObject):
for setting_info in new_quality_settings_list: for setting_info in new_quality_settings_list:
setting_info["stack"].sendPostponedEmits() 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. ## 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) stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged)
self._onQualityNameChanged() self._onQualityNameChanged()
def _askUserToKeepOrClearCurrentSettings(self):
Application.getInstance().discardOrKeepProfileChanges()
@pyqtProperty(str, notify = activeVariantChanged) @pyqtProperty(str, notify = activeVariantChanged)
def activeVariantName(self) -> str: def activeVariantName(self) -> str:
if self._active_container_stack: if self._active_container_stack: