Browse Source

Settings now point to the right extruder stack

CURA-1758
Jaime van Kessel 8 years ago
parent
commit
4346d5a233
2 changed files with 41 additions and 1 deletions
  1. 4 0
      cura/Settings/ExtruderManager.py
  2. 37 1
      resources/qml/Settings/SettingView.qml

+ 4 - 0
cura/Settings/ExtruderManager.py

@@ -47,6 +47,10 @@ class ExtruderManager(QObject):
             return 0 # No active machine, so no extruders.
         return len(self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getId()])
 
+    @pyqtProperty("QVariantList", notify=extrudersChanged)
+    def extruderIds(self):
+        return [self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getId()][extruder].getId() for extruder in self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getId()]]
+
     ##  The instance of the singleton pattern.
     #
     #   It's None if the extruder manager hasn't been created yet.

+ 37 - 1
resources/qml/Settings/SettingView.qml

@@ -60,6 +60,8 @@ ScrollView
             property var settingDefinitionsModel: definitionsModel
             property var propertyProvider: provider
 
+            property var stackId: ExtruderManager.activeExtruderStackId ? ExtruderManager.activeExtruderStackId : Cura.MachineManager.activeMachineId
+
             //Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989
             //In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes,
             //causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely.
@@ -89,11 +91,45 @@ ScrollView
                 }
             }
 
+            // Binding to ensure that the right containerstack ID is set for the provider.
+            // This ensures that if a setting has a global_inherits_stack id (for instance; Support speed points to the
+            // extruder that actually prints the support, as that is the setting we need to use to calculate the value)
+            Binding
+            {
+                target: provider
+                property: "containerStackId"
+                value:
+                {
+                    if(inheritStackProvider.properties.global_inherits_stack == -1 || inheritStackProvider.properties.global_inherits_stack == null)
+                    {
+                        if( ExtruderManager.activeExtruderStackId)
+                        {
+                            return ExtruderManager.activeExtruderStackId
+                        }
+                        else
+                        {
+                            return Cura.MachineManager.activeMachineId
+                        }
+                    }
+                    return ExtruderManager.extruderIds[inheritStackProvider.properties.global_inherits_stack]
+                }
+            }
+
+            // Specialty provider that only watches global_inherits (we cant filter on what property changed we get events
+            // so we bypass that to make a dedicated provider.
+            UM.SettingPropertyProvider
+            {
+                id: inheritStackProvider
+                containerStackId: Cura.MachineManager.activeMachineId
+                key: model.key
+                watchedProperties: [ "global_inherits_stack"]
+            }
+
             UM.SettingPropertyProvider
             {
                 id: provider
 
-                containerStackId: ExtruderManager.activeExtruderStackId ? ExtruderManager.activeExtruderStackId : Cura.MachineManager.activeMachineId
+                containerStackId: delegate.stackId
                 key: model.key ? model.key : ""
                 watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder" ]
                 storeIndex: 0