mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Reduce the amount of calls to create the background on the ToolTip
We were deleting / recreating the graphics background item for *every* mouse movement. Now we are just creating the painter path; no more allocations / desalocations, adding, removing from the scene. This should make things a tiny bit faster. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6a1a6c82bf
commit
054521d3a1
1 changed files with 14 additions and 14 deletions
|
@ -60,11 +60,8 @@ void ToolTipItem::setRect(const QRectF &r)
|
|||
if( r == rectangle ) {
|
||||
return;
|
||||
}
|
||||
delete background;
|
||||
|
||||
rectangle = r;
|
||||
setBrush(QBrush(Qt::white));
|
||||
setPen(QPen(Qt::black, 0.5));
|
||||
|
||||
// Creates a 2pixels border
|
||||
QPainterPath border;
|
||||
|
@ -75,17 +72,7 @@ void ToolTipItem::setRect(const QRectF &r)
|
|||
QPainterPath bg;
|
||||
bg.addRoundedRect(-1, -1, rectangle.width() + 3, rectangle.height() + 4, 3, 3);
|
||||
|
||||
QColor c = QColor(Qt::black);
|
||||
c.setAlpha(155);
|
||||
|
||||
QGraphicsPathItem *b = new QGraphicsPathItem(bg, this);
|
||||
b->setFlag(ItemStacksBehindParent);
|
||||
b->setFlag(ItemIgnoresTransformations);
|
||||
b->setBrush(c);
|
||||
b->setPen(QPen(QBrush(Qt::transparent), 0));
|
||||
b->setZValue(-10);
|
||||
background = b;
|
||||
|
||||
background->setPath(bg);
|
||||
updateTitlePosition();
|
||||
}
|
||||
|
||||
|
@ -158,6 +145,16 @@ ToolTipItem::ToolTipItem(QGraphicsItem *parent) : QGraphicsPathItem(parent),
|
|||
entryToolTip.first = NULL;
|
||||
entryToolTip.second = NULL;
|
||||
setFlags(ItemIgnoresTransformations | ItemIsMovable | ItemClipsChildrenToShape);
|
||||
|
||||
QColor c = QColor(Qt::black);
|
||||
c.setAlpha(155);
|
||||
background = new QGraphicsPathItem(this);
|
||||
background->setFlag(ItemStacksBehindParent);
|
||||
background->setFlag(ItemIgnoresTransformations);
|
||||
background->setBrush(c);
|
||||
background->setPen(QPen(QBrush(Qt::transparent), 0));
|
||||
background->setZValue(-10);
|
||||
|
||||
updateTitlePosition();
|
||||
setZValue(99);
|
||||
|
||||
|
@ -171,6 +168,9 @@ ToolTipItem::ToolTipItem(QGraphicsItem *parent) : QGraphicsPathItem(parent),
|
|||
title->setFlag(ItemIgnoresTransformations);
|
||||
title->setPen(QPen(Qt::white, 1));
|
||||
title->setBrush(Qt::white);
|
||||
|
||||
setBrush(QBrush(Qt::white));
|
||||
setPen(QPen(Qt::black, 0.5));
|
||||
}
|
||||
|
||||
ToolTipItem::~ToolTipItem()
|
||||
|
|
Loading…
Add table
Reference in a new issue