Browse Source

Small qml speed improvements for setting item

Jaime van Kessel 5 years ago
parent
commit
f090b5898e
2 changed files with 18 additions and 16 deletions
  1. 1 1
      cura/Settings/SettingInheritanceManager.py
  2. 17 15
      resources/qml/Settings/SettingItem.qml

+ 1 - 1
cura/Settings/SettingInheritanceManager.py

@@ -89,7 +89,7 @@ class SettingInheritanceManager(QObject):
 
     @pyqtSlot()
     def forceUpdate(self) -> None:
-        self._update()
+        self._update_timer.start()
 
     def _onActiveExtruderChanged(self) -> None:
         new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()

+ 17 - 15
resources/qml/Settings/SettingItem.qml

@@ -23,17 +23,16 @@ Item
     property alias contents: controlContainer.children
     property alias hovered: mouse.containsMouse
 
-    property var showRevertButton: true
-    property var showInheritButton: true
-    property var showLinkedSettingIcon: true
-    property var doDepthIndentation: true
-    property var doQualityUserSettingEmphasis: true
+    property bool showRevertButton: true
+    property bool showInheritButton: true
+    property bool showLinkedSettingIcon: true
+    property bool doDepthIndentation: true
+    property bool doQualityUserSettingEmphasis: true
     property var settingKey: definition.key //Used to detect each individual setting more easily in Squish GUI tests.
 
     // Create properties to put property provider stuff in (bindings break in qt 5.5.1 otherwise)
     property var state: propertyProvider.properties.state
-    // There is no resolve property if there is only one stack.
-    property var resolve: Cura.MachineManager.activeStackId !== Cura.MachineManager.activeMachine.id ? propertyProvider.properties.resolve : "None"
+    property var resolve: propertyProvider.properties.resolve
     property var stackLevels: propertyProvider.stackLevels
     property var stackLevel: stackLevels[0]
     // A list of stack levels that will trigger to show the revert button
@@ -149,7 +148,7 @@ Item
             color: UM.Theme.getColor("setting_control_text")
             opacity: (definition.visible) ? 1 : 0.5
             // emphasize the setting if it has a value in the user or quality profile
-            font: base.doQualityUserSettingEmphasis && base.stackLevel != undefined && base.stackLevel <= 1 ? UM.Theme.getFont("default_italic") : UM.Theme.getFont("default")
+            font: base.doQualityUserSettingEmphasis && base.stackLevel !== undefined && base.stackLevel <= 1 ? UM.Theme.getFont("default_italic") : UM.Theme.getFont("default")
         }
 
         Row
@@ -170,10 +169,11 @@ Item
             {
                 id: linkedSettingIcon;
 
-                visible: Cura.MachineManager.activeStack != Cura.MachineManager.activeMachine && (!definition.settable_per_extruder || String(globalPropertyProvider.properties.limit_to_extruder) != "-1") && base.showLinkedSettingIcon
+                visible: Cura.MachineManager.activeStack !== Cura.MachineManager.activeMachine && (!definition.settable_per_extruder || String(globalPropertyProvider.properties.limit_to_extruder) != "-1") && base.showLinkedSettingIcon
 
-                height: parent.height;
-                width: height;
+                anchors.top: parent.top
+                anchors.bottom: parent.bottom
+                width: height
 
                 color: UM.Theme.getColor("setting_control_button")
                 hoverColor: UM.Theme.getColor("setting_control_button")
@@ -184,7 +184,7 @@ Item
                 {
                     hoverTimer.stop()
                     var tooltipText = catalog.i18nc("@label", "This setting is always shared between all extruders. Changing it here will change the value for all extruders.")
-                    if ((resolve != "None") && (stackLevel != 0))
+                    if ((resolve !== "None") && (stackLevel !== 0))
                     {
                         // We come here if a setting has a resolve and the setting is not manually edited.
                         tooltipText += " " + catalog.i18nc("@label", "The value is resolved from per-extruder values ") + "[" + Cura.ExtruderManager.getInstanceExtruderValues(definition.key) + "]."
@@ -200,7 +200,8 @@ Item
 
                 visible: base.resetButtonVisible
 
-                height: parent.height
+                anchors.top: parent.top
+                anchors.bottom: parent.bottom
                 width: height
 
                 color: UM.Theme.getColor("setting_control_button")
@@ -278,7 +279,8 @@ Item
                     return Cura.SettingInheritanceManager.getOverridesForExtruder(definition.key, String(globalPropertyProvider.properties.limit_to_extruder)).indexOf(definition.key) >= 0
                 }
 
-                height: parent.height
+                anchors.top: parent.top
+                anchors.bottom: parent.bottom
                 width: height
 
                 onClicked:
@@ -296,7 +298,7 @@ Item
                             break
                         }
                     }
-                    if ((last_entry == 4 || last_entry == 11) && base.stackLevel == 0 && base.stackLevels.length == 2)
+                    if ((last_entry === 4 || last_entry === 11) && base.stackLevel === 0 && base.stackLevels.length === 2)
                     {
                         // Special case of the inherit reset. If only the definition (4th or 11th) container) and the first
                         // entry (user container) are set, we can simply remove the container.