Put HAvatar's tooltip image inside a Loader

Make sure to not load tooltip images unless the user is
currently trying to see one by hovering on an avatar.
This also seems to reduce idle CPU usage.
This commit is contained in:
miruka 2020-11-04 01:41:45 -04:00
parent 8ca8f490fa
commit dba41c30c2

View File

@ -13,13 +13,13 @@ Rectangle {
property alias clientUserId: avatarImage.clientUserId property alias clientUserId: avatarImage.clientUserId
property alias mxc: avatarImage.mxc property alias mxc: avatarImage.mxc
property alias title: avatarImage.title property alias title: avatarImage.title
property alias toolTipMxc: avatarToolTipImage.mxc
property alias sourceOverride: avatarImage.sourceOverride property alias sourceOverride: avatarImage.sourceOverride
property alias toolTipSourceOverride: avatarToolTipImage.sourceOverride
property alias fillMode: avatarImage.fillMode property alias fillMode: avatarImage.fillMode
property alias animate: avatarImage.animate property alias animate: avatarImage.animate
property string toolTipMxc: mxc
property string toolTipSourceOverride: ""
readonly property alias hovered: hoverHandler.hovered readonly property alias hovered: hoverHandler.hovered
readonly property alias circleRadius: avatarImage.circleRadius readonly property alias circleRadius: avatarImage.circleRadius
@ -93,13 +93,17 @@ Rectangle {
delay: 1000 delay: 1000
backgroundColor: theme.controls.avatar.hoveredImage.background backgroundColor: theme.controls.avatar.hoveredImage.background
contentItem: HMxcImage { contentItem: HLoader {
active: avatarToolTip.visible
sourceComponent: HMxcImage {
id: avatarToolTipImage id: avatarToolTipImage
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
animatedFillMode: AnimatedImage.PreserveAspectCrop animatedFillMode: AnimatedImage.PreserveAspectCrop
clientUserId: avatarImage.clientUserId clientUserId: avatarImage.clientUserId
mxc: avatarImage.mxc
title: avatarImage.title title: avatarImage.title
mxc: avatar.toolTipMxc
sourceOverride: avatar.toolTipSourceOverride
sourceSize.width: avatarToolTip.dimension sourceSize.width: avatarToolTip.dimension
sourceSize.height: avatarToolTip.dimension sourceSize.height: avatarToolTip.dimension
@ -109,3 +113,4 @@ Rectangle {
} }
} }
} }
}