Просмотр исходного кода

CURA-4400 optional_extruders cannot be set to disabled extruders anymore

Jack Ha 7 лет назад
Родитель
Сommit
05cd937df3

+ 1 - 0
cura/Settings/ExtrudersModel.py

@@ -210,6 +210,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
                 item = {
                     "id": "",
                     "name": catalog.i18nc("@menuitem", "Not overridden"),
+                    "enabled": True,
                     "color": "#ffffff",
                     "index": -1,
                     "definition": ""

+ 2 - 1
resources/qml/Settings/SettingExtruder.qml

@@ -215,7 +215,8 @@ SettingItem
             {
                 text: model.name
                 renderType: Text.NativeRendering
-                color: {
+                color:
+                {
                     if (model.enabled) {
                         UM.Theme.getColor("setting_control_text")
                     } else {

+ 21 - 3
resources/qml/Settings/SettingOptionalExtruder.qml

@@ -27,8 +27,19 @@ SettingItem
 
         onActivated:
         {
-            forceActiveFocus();
-            propertyProvider.setPropertyValue("value", model.getItem(index).index);
+            if (model.getItem(index).enabled)
+            {
+                forceActiveFocus();
+                propertyProvider.setPropertyValue("value", model.getItem(index).index);
+            } else
+            {
+                if (propertyProvider.properties.value == -1)
+                {
+                    control.currentIndex = model.rowCount() - 1;  // we know the last item is "Not overriden"
+                } else {
+                    control.currentIndex = propertyProvider.properties.value;  // revert to the old value
+                }
+            }
         }
 
         onActiveFocusChanged:
@@ -192,7 +203,14 @@ SettingItem
             {
                 text: model.name
                 renderType: Text.NativeRendering
-                color: UM.Theme.getColor("setting_control_text")
+                color:
+                {
+                    if (model.enabled) {
+                        UM.Theme.getColor("setting_control_text")
+                    } else {
+                        UM.Theme.getColor("action_button_disabled_text");
+                    }
+                }
                 font: UM.Theme.getFont("default")
                 elide: Text.ElideRight
                 verticalAlignment: Text.AlignVCenter