summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-01-14 22:30:14 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-15 14:26:35 +1300
commit806d9841079b5e171fa93bbc43525aa0283011df (patch)
treec746452f3231fad6305f707b55dbcf4a405a1b68
parent54898b15ffbcd92b839a450a943cfe0ffd8b6799 (diff)
downloadsubsurface-806d9841079b5e171fa93bbc43525aa0283011df.tar.gz
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 <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/divetooltipitem.cpp12
1 files changed, 7 insertions, 5 deletions
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;
}