Profile: improve tooltip animation

Remove a couple of expand() calls(?). Also store the last
expanded rectangle size in the private variable nextRectangle
and use that in collapse() animation. Patch prevents a small
jump/resize glitch if the user quickly hovers over and out
of the profile while the tooltip is still resizing.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Lubomir I. Ivanov 2013-07-05 15:33:50 +03:00 committed by Dirk Hohndel
parent 3b07cd204b
commit 2e26de5ae6
2 changed files with 2 additions and 5 deletions

View file

@ -1198,8 +1198,6 @@ void ToolTipItem::removeToolTip(const QString& toolTip)
t.second->setPos(SPACING + ICON_SMALL + SPACING, yValue); t.second->setPos(SPACING + ICON_SMALL + SPACING, yValue);
toolTipIndex++; toolTipIndex++;
} }
expand();
} }
void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos) void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos)
@ -1225,7 +1223,6 @@ void ToolTipItem::clear()
delete t.second; delete t.second;
} }
toolTips.clear(); toolTips.clear();
expand();
} }
void ToolTipItem::setRect(const QRectF& r) void ToolTipItem::setRect(const QRectF& r)
@ -1266,7 +1263,7 @@ void ToolTipItem::collapse()
{ {
QPropertyAnimation *animation = new QPropertyAnimation(this, "rect"); QPropertyAnimation *animation = new QPropertyAnimation(this, "rect");
animation->setDuration(100); animation->setDuration(100);
animation->setStartValue(boundingRect()); animation->setStartValue(nextRectangle);
animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL)); animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL));
animation->start(QAbstractAnimation::DeleteWhenStopped); animation->start(QAbstractAnimation::DeleteWhenStopped);
clear(); clear();
@ -1281,7 +1278,6 @@ void ToolTipItem::expand()
return; return;
} }
QRectF nextRectangle;
double width = 0, height = title->boundingRect().height() + SPACING; double width = 0, height = title->boundingRect().height() + SPACING;
Q_FOREACH(ToolTip t, toolTips) { Q_FOREACH(ToolTip t, toolTips) {
if (t.second->boundingRect().width() > width) if (t.second->boundingRect().width() > width)

View file

@ -54,6 +54,7 @@ private:
Status status; Status status;
QRectF rectangle; QRectF rectangle;
bool dragging; bool dragging;
QRectF nextRectangle;
}; };
class EventItem : public QGraphicsPolygonItem class EventItem : public QGraphicsPolygonItem