diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-05-21 09:09:53 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-05-21 09:10:49 +0300 |
commit | 80827bdf70490bc1f902bebc6970270716e7dca9 (patch) | |
tree | ecdcdfbf25a648d5b4a8feb23943c65847e17b06 /cura/UI | |
parent | 0dc49a66f1f757075196e10810b4db40d8482469 (diff) |
Fix adhesion checkbox in recommended mode
CURA-6182
Move complex logic to Python.
Diffstat (limited to 'cura/UI')
-rw-r--r-- | cura/UI/RecommendedMode.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/cura/UI/RecommendedMode.py b/cura/UI/RecommendedMode.py new file mode 100644 index 0000000000..6f5db27da2 --- /dev/null +++ b/cura/UI/RecommendedMode.py @@ -0,0 +1,50 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +from PyQt5.QtCore import QObject, pyqtSlot + + +# +# This object contains helper/convenience functions for Recommended mode. +# +class RecommendedMode(QObject): + + # Sets to use the adhesion or not for the "Adhesion" CheckBox in Recommended mode. + @pyqtSlot(bool) + def setAdhesion(self, checked: bool) -> None: + from cura.CuraApplication import CuraApplication + + application = CuraApplication.getInstance() + global_stack = application.getMachineManager().activeMachine + if global_stack is None: + return + + # Remove the adhesion type value set by the user. + adhesion_type_key = "adhesion_type" + user_changes_container = global_stack.userChanges + if adhesion_type_key in user_changes_container.getAllKeys(): + user_changes_container.removeInstance(adhesion_type_key) + + # Get the default value of adhesion type after user's value has been removed. + # skirt and none are counted as "no adhesion", the others are considered as "with adhesion". The conditions are + # as the following: + # - if the user checks the adhesion checkbox, get the default value (including the custom quality) for adhesion + # type. + # (1) If the default value is "skirt" or "none" (no adhesion), set adhesion_type to "brim". + # (2) If the default value is "with adhesion", do nothing. + # - if the user unchecks the adhesion checkbox, get the default value (including the custom quality) for + # adhesion type. + # (1) If the default value is "skirt" or "none" (no adhesion), do nothing. + # (2) Otherwise, set adhesion_type to "skirt". + value = global_stack.getProperty(adhesion_type_key, "value") + if checked: + if value in ("skirt", "none"): + value = "brim" + else: + if value not in ("skirt", "none"): + value = "skirt" + + user_changes_container.setProperty(adhesion_type_key, "value", value) + + +__all__ = ["RecommendedMode"] |