From 806d9841079b5e171fa93bbc43525aa0283011df Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 14 Jan 2015 22:30:14 -0200 Subject: Only update the rectangle if it changed Very often the rectangle of the ToolTip doesn't need to change but we were calling and firing an animation for it for *every* mouse movement, even when we didn't really needed it. Now it will only fire something if the rectangles are indeed different. From my tests we reduced the number of calls to the animatior by about 20% using a real divelog as test. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/divetooltipitem.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index ea3a74901..46d50be02 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -126,11 +126,13 @@ void ToolTipItem::expand() nextRectangle.setWidth(width); nextRectangle.setHeight(height); - QPropertyAnimation *animation = new QPropertyAnimation(this, "rect", this); - animation->setDuration(100); - animation->setStartValue(rectangle); - animation->setEndValue(nextRectangle); - animation->start(QAbstractAnimation::DeleteWhenStopped); + if (nextRectangle != rectangle) { + QPropertyAnimation *animation = new QPropertyAnimation(this, "rect", this); + animation->setDuration(100); + animation->setStartValue(rectangle); + animation->setEndValue(nextRectangle); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } status = EXPANDED; } -- cgit v1.2.3-70-g09d2