Browse Source

Fix PerObjectSettingsPanel.qml

CURA-4186

- The UI shouldn't be bound to the limit_to_extruder stack, it should
  always be bound to the per-object stack.
- The ActiveTool.getValue() calls cannot be bound in QML, so use a
  Connections to update the values based on signals.
Lipu Fei 7 years ago
parent
commit
2ec7c14422
1 changed files with 12 additions and 26 deletions
  1. 12 26
      plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml

+ 12 - 26
plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml

@@ -135,6 +135,8 @@ Item {
                             }
                         }
 
+                        // 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: provider
@@ -146,8 +148,6 @@ Item {
                             removeUnusedValue: false
                         }
 
-                        // 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
@@ -156,36 +156,22 @@ Item {
                             watchedProperties: [ "limit_to_extruder" ]
                         }
 
-                        Binding
+                        Connections
                         {
-                            target: provider
-                            property: "containerStackId"
-                            when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0);
-                            value:
+                            target: UM.ActiveTool
+                            onPropertiesChanged:
                             {
-                                // associate this binding with Cura.MachineManager.activeMachineId in the beginning so this
-                                // binding will be triggered when activeMachineId is changed too.
-                                // Otherwise, if this value only depends on the extruderIds, it won't get updated when the
-                                // machine gets changed.
-                                var activeMachineId = Cura.MachineManager.activeMachineId;
-
-                                if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1)
-                                {
-                                    //Not settable per extruder or there only is global, so we must pick global.
-                                    return activeMachineId;
-                                }
-                                if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0)
+                                // the values cannot be bound with UM.ActiveTool.properties.getValue() calls,
+                                // so here we connect to the signal and update the those values.
+                                if (typeof UM.ActiveTool.properties.getValue("SelectedObjectId") !== "undefined")
                                 {
-                                    //We have limit_to_extruder, so pick that stack.
-                                    return ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)];
+                                    addedSettingsModel.visibilityHandler.selectedObjectId = UM.ActiveTool.properties.getValue("SelectedObjectId");
                                 }
-                                if(UM.ActiveTool.properties.getValue("ContainerID"))
+                                if (typeof UM.ActiveTool.properties.getValue("ContainerID") !== "undefined")
                                 {
-                                    //We're on an extruder tab. Pick the current extruder.
-                                    return UM.ActiveTool.properties.getValue("ContainerID");
+                                    provider.containerStackId = UM.ActiveTool.properties.getValue("ContainerID");
+                                    inheritStackProvider.containerStackId = UM.ActiveTool.properties.getValue("ContainerID");
                                 }
-                                //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab.
-                                return activeMachineId;
                             }
                         }
                     }