Browse Source

Add simple mode settings flag for user created profile - CURA-4466

ChrisTerBeke 7 years ago
parent
commit
30281f17f3
2 changed files with 29 additions and 2 deletions
  1. 28 1
      cura/Settings/SimpleModeSettingsManager.py
  2. 1 1
      resources/qml/SidebarSimple.qml

+ 28 - 1
cura/Settings/SimpleModeSettingsManager.py

@@ -12,11 +12,14 @@ class SimpleModeSettingsManager(QObject):
         super().__init__(parent)
 
         self._machine_manager = Application.getInstance().getMachineManager()
-        self._is_profile_customized = False
+        self._is_profile_customized = False  # True when default profile has user changes
+        self._is_profile_user_created = False  # True when profile was custom created by user
 
         self._machine_manager.activeStackValueChanged.connect(self._updateIsProfileCustomized)
+        self._machine_manager.activeStackValueChanged.connect(self._updateIsProfileUserCreated)
 
     isProfileCustomizedChanged = pyqtSignal()
+    isProfileUserCreated = pyqtSignal()
 
     @pyqtProperty(bool, notify = isProfileCustomizedChanged)
     def isProfileCustomized(self):
@@ -32,11 +35,13 @@ class SimpleModeSettingsManager(QObject):
 
         # check user settings in the global stack
         user_setting_keys.update(set(global_stack.userChanges.getAllKeys()))
+
         # check user settings in the extruder stacks
         if global_stack.extruders:
             for extruder_stack in global_stack.extruders.values():
                 user_setting_keys.update(set(extruder_stack.userChanges.getAllKeys()))
 
+        # remove settings that are visible in recommended (we don't show the reset button for those)
         for skip_key in self.__ignored_custom_setting_keys:
             if skip_key in user_setting_keys:
                 user_setting_keys.remove(skip_key)
@@ -47,6 +52,28 @@ class SimpleModeSettingsManager(QObject):
             self._is_profile_customized = has_customized_user_settings
             self.isProfileCustomizedChanged.emit()
 
+    @pyqtProperty(bool, notify = isProfileUserCreated)
+    def isProfileUserCreated(self):
+        return self._is_profile_user_created
+
+    def _updateIsProfileUserCreated(self):
+        if not self._machine_manager.activeMachine:
+            return False
+
+        global_stack = self._machine_manager.activeMachine
+
+        # get all keys present in the quality changes container
+        quality_changes_keys = global_stack.qualityChanges.getAllKeys()
+
+        # check if the qualityChanges container is not empty (meaning there are user changes)
+        is_profile_user_created = len(quality_changes_keys) > 0
+
+        print("is_user_created_profile", global_stack.qualityChanges.getName(), is_profile_user_created)
+
+        if is_profile_user_created != self._is_profile_user_created:
+            self._is_profile_user_created = is_profile_user_created
+            self.isProfileUserCreated.emit()
+
     # These are the settings included in the Simple ("Recommended") Mode, so only when the other settings have been
     # changed, we consider it as a user customized profile in the Simple ("Recommended") Mode.
     __ignored_custom_setting_keys = ["support_enable",

+ 1 - 1
resources/qml/SidebarSimple.qml

@@ -291,7 +291,7 @@ Item
                                     implicitWidth: 10 * screenScaleFactor
                                     implicitHeight: implicitWidth
                                     radius: implicitWidth / 2
-                                    visible: !Cura.SimpleModeSettingsManager.isProfileCustomized;
+                                    visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated
                                 }
                             }
                         }