Browse Source

Close the expandable panel when it becomes disabled

It happens when it's open and the user loads a GCode.

Contributes to CURA-5941
Diego Prado Gesto 6 years ago
parent
commit
4b6f4af44e
2 changed files with 31 additions and 2 deletions
  1. 17 1
      resources/qml/ExpandableComponent.qml
  2. 14 1
      resources/qml/ExpandablePopup.qml

+ 17 - 1
resources/qml/ExpandableComponent.qml

@@ -88,7 +88,23 @@ Item
     {
         target: background
         property: "color"
-        value: enabled ? (expanded ? headerActiveColor : headerBackgroundColor) : UM.Theme.getColor("disabled")
+        value:
+        {
+            return base.enabled ? (expanded ? headerActiveColor : headerBackgroundColor) : UM.Theme.getColor("disabled")
+        }
+    }
+
+    // The panel needs to close when it becomes disabled
+    Connections
+    {
+        target: base
+        onEnabledChanged:
+        {
+            if (!base.enabled && expanded)
+            {
+                toggleContent()
+            }
+        }
     }
 
     implicitHeight: 100 * screenScaleFactor

+ 14 - 1
resources/qml/ExpandablePopup.qml

@@ -94,7 +94,20 @@ Item
     {
         target: background
         property: "color"
-        value: enabled ? headerBackgroundColor : UM.Theme.getColor("disabled")
+        value: base.enabled ? headerBackgroundColor : UM.Theme.getColor("disabled")
+    }
+
+    // The panel needs to close when it becomes disabled
+    Connections
+    {
+        target: base
+        onEnabledChanged:
+        {
+            if (!base.enabled && expanded)
+            {
+                toggleContent()
+            }
+        }
     }
 
     implicitHeight: 100 * screenScaleFactor