mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Profile: make sure text is scaled correctly when drawn
We had all this wonderful code to scale the text correctly, except we went out of our way to make sure the code wouldn't be called unless something changed on this specific text item. But that's bogus because the scaling depends on external factors like the fontPrintScale. So instead of calling updateText() when attributes of this DiveTextItem change simply call it right before the DiveTextItem gets painted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ccaff3a06d
commit
487ddce353
2 changed files with 7 additions and 3 deletions
|
@ -14,11 +14,16 @@ DiveTextItem::DiveTextItem(QGraphicsItem *parent) : QGraphicsItemGroup(parent),
|
|||
textItem->setPen(Qt::NoPen);
|
||||
}
|
||||
|
||||
void DiveTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
updateText();
|
||||
QGraphicsItemGroup::paint(painter, option, widget);
|
||||
}
|
||||
|
||||
void DiveTextItem::setAlignment(int alignFlags)
|
||||
{
|
||||
if (alignFlags != internalAlignFlags) {
|
||||
internalAlignFlags = alignFlags;
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +36,6 @@ void DiveTextItem::setScale(double newscale)
|
|||
{
|
||||
if (scale != newscale) {
|
||||
scale = newscale;
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +43,6 @@ void DiveTextItem::setText(const QString &t)
|
|||
{
|
||||
if (internalText != t) {
|
||||
internalText = t;
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
void setScale(double newscale);
|
||||
void setBrush(const QBrush &brush);
|
||||
const QString &text();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
private:
|
||||
void updateText();
|
||||
|
|
Loading…
Reference in a new issue