Create tooltips on demand instead of on creation.

This makes the loading of setting items a *lot* more faster, as each string
takes about 2.5 ms to create (and we load all of them in memory!).
This commit is contained in:
Jaime van Kessel 2019-10-25 15:54:45 +02:00
parent 5f2984b77e
commit 4cc8bf5946
No known key found for this signature in database
GPG Key ID: 3710727397403C91

View File

@ -56,7 +56,8 @@ Item
signal showTooltip(string text) signal showTooltip(string text)
signal hideTooltip() signal hideTooltip()
signal showAllHiddenInheritedSettings(string category_id) signal showAllHiddenInheritedSettings(string category_id)
property string tooltipText:
function createTooltipText()
{ {
var affects = settingDefinitionsModel.getRequiredBy(definition.key, "value") var affects = settingDefinitionsModel.getRequiredBy(definition.key, "value")
var affected_by = settingDefinitionsModel.getRequires(definition.key, "value") var affected_by = settingDefinitionsModel.getRequires(definition.key, "value")
@ -127,7 +128,7 @@ Item
onTriggered: onTriggered:
{ {
base.showTooltip(base.tooltipText) base.showTooltip(base.createTooltipText())
} }
} }
@ -191,7 +192,7 @@ Item
} }
base.showTooltip(tooltipText) base.showTooltip(tooltipText)
} }
onExited: base.showTooltip(base.tooltipText) onExited: base.showTooltip(base.createTooltipText())
} }
UM.SimpleButton UM.SimpleButton
@ -228,7 +229,7 @@ Item
hoverTimer.stop() hoverTimer.stop()
base.showTooltip(catalog.i18nc("@label", "This setting has a value that is different from the profile.\n\nClick to restore the value of the profile.")) base.showTooltip(catalog.i18nc("@label", "This setting has a value that is different from the profile.\n\nClick to restore the value of the profile."))
} }
onExited: base.showTooltip(base.tooltipText) onExited: base.showTooltip(base.createTooltipText())
} }
UM.SimpleButton UM.SimpleButton
@ -322,7 +323,7 @@ Item
iconSource: UM.Theme.getIcon("formula") iconSource: UM.Theme.getIcon("formula")
onEntered: { hoverTimer.stop(); base.showTooltip(catalog.i18nc("@label", "This setting is normally calculated, but it currently has an absolute value set.\n\nClick to restore the calculated value.")) } onEntered: { hoverTimer.stop(); base.showTooltip(catalog.i18nc("@label", "This setting is normally calculated, but it currently has an absolute value set.\n\nClick to restore the calculated value.")) }
onExited: base.showTooltip(base.tooltipText) onExited: base.showTooltip(base.createTooltipText())
} }
} }