Prevent type coercion in qml

This should speed things up a tiny bit
This commit is contained in:
Jaime van Kessel 2019-10-25 13:52:45 +02:00
parent 98275d2da0
commit 11bf91ae38
No known key found for this signature in database
GPG key ID: 3710727397403C91

View file

@ -228,7 +228,7 @@ Item
model: UM.SettingDefinitionsModel model: UM.SettingDefinitionsModel
{ {
id: definitionsModel id: definitionsModel
containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: "" containerId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.definition.id: ""
visibilityHandler: UM.SettingPreferenceVisibilityHandler { } visibilityHandler: UM.SettingPreferenceVisibilityHandler { }
exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order", "cutting_mesh", "support_mesh", "anti_overhang_mesh"] // TODO: infill_mesh settigns are excluded hardcoded, but should be based on the fact that settable_globally, settable_per_meshgroup and settable_per_extruder are false. exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order", "cutting_mesh", "support_mesh", "anti_overhang_mesh"] // TODO: infill_mesh settigns are excluded hardcoded, but should be based on the fact that settable_globally, settable_per_meshgroup and settable_per_extruder are false.
expanded: CuraApplication.expandedCategories expanded: CuraApplication.expandedCategories
@ -244,40 +244,40 @@ Item
onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate() onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate()
} }
property var indexWithFocus: -1 property int indexWithFocus: -1
delegate: Loader delegate: Loader
{ {
id: delegate id: delegate
width: scrollView.width width: scrollView.width
height: provider.properties.enabled == "True" ? UM.Theme.getSize("section").height : - contents.spacing height: provider.properties.enabled === "True" ? UM.Theme.getSize("section").height : - contents.spacing
Behavior on height { NumberAnimation { duration: 100 } } Behavior on height { NumberAnimation { duration: 100 } }
opacity: provider.properties.enabled == "True" ? 1 : 0 opacity: provider.properties.enabled === "True" ? 1 : 0
Behavior on opacity { NumberAnimation { duration: 100 } } Behavior on opacity { NumberAnimation { duration: 100 } }
enabled: enabled:
{ {
if (!Cura.ExtruderManager.activeExtruderStackId && machineExtruderCount.properties.value > 1) if (!Cura.ExtruderManager.activeExtruderStackId && machineExtruderCount.properties.value > 1)
{ {
// disable all controls on the global tab, except categories // disable all controls on the global tab, except categories
return model.type == "category" return model.type === "category"
} }
return provider.properties.enabled == "True" return provider.properties.enabled === "True"
} }
property var definition: model property var definition: model
property var settingDefinitionsModel: definitionsModel property var settingDefinitionsModel: definitionsModel
property var propertyProvider: provider property var propertyProvider: provider
property var globalPropertyProvider: inheritStackProvider property var globalPropertyProvider: inheritStackProvider
property var externalResetHandler: false property bool externalResetHandler: false
property string activeMachineId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id : "" property string activeMachineId: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id : ""
//Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989 //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, //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. //causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely.
asynchronous: model.type != "enum" && model.type != "extruder" && model.type != "optional_extruder" asynchronous: model.type !== "enum" && model.type !== "extruder" && model.type !== "optional_extruder"
active: model.type != undefined active: model.type !== undefined
source: source:
{ {
@ -313,7 +313,7 @@ Item
{ {
target: provider target: provider
property: "containerStackId" property: "containerStackId"
when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0); when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder !== null && inheritStackProvider.properties.limit_to_extruder >= 0);
value: value:
{ {
// Associate this binding with Cura.MachineManager.activeMachine.id in the beginning so this // Associate this binding with Cura.MachineManager.activeMachine.id in the beginning so this
@ -326,7 +326,7 @@ Item
//Not settable per extruder or there only is global, so we must pick global. //Not settable per extruder or there only is global, so we must pick global.
return delegate.activeMachineId return delegate.activeMachineId
} }
if (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) if (inheritStackProvider.properties.limit_to_extruder !== null && inheritStackProvider.properties.limit_to_extruder >= 0)
{ {
//We have limit_to_extruder, so pick that stack. //We have limit_to_extruder, so pick that stack.
return Cura.ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; return Cura.ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)];
@ -359,7 +359,7 @@ Item
key: model.key ? model.key : "" key: model.key ? model.key : ""
watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder", "resolve" ] watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder", "resolve" ]
storeIndex: 0 storeIndex: 0
removeUnusedValue: model.resolve == undefined removeUnusedValue: model.resolve === undefined
} }
Connections Connections
@ -465,7 +465,7 @@ Item
//: Settings context menu action //: Settings context menu action
text: catalog.i18nc("@action:menu", "Copy value to all extruders") text: catalog.i18nc("@action:menu", "Copy value to all extruders")
visible: machineExtruderCount.properties.value > 1 visible: machineExtruderCount.properties.value > 1
enabled: contextMenu.provider != undefined && contextMenu.provider.properties.settable_per_extruder != "False" enabled: contextMenu.provider !== undefined && contextMenu.provider.properties.settable_per_extruder !== "False"
onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key) onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key)
} }
@ -474,7 +474,7 @@ Item
//: Settings context menu action //: Settings context menu action
text: catalog.i18nc("@action:menu", "Copy all changed values to all extruders") text: catalog.i18nc("@action:menu", "Copy all changed values to all extruders")
visible: machineExtruderCount.properties.value > 1 visible: machineExtruderCount.properties.value > 1
enabled: contextMenu.provider != undefined enabled: contextMenu.provider !== undefined
onTriggered: Cura.MachineManager.copyAllValuesToExtruders() onTriggered: Cura.MachineManager.copyAllValuesToExtruders()
} }