Element text item group can now be framed.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5410 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-06-24 11:16:37 +00:00
parent deabf5f2ad
commit ea3b25fa75
7 changed files with 117 additions and 32 deletions

View File

@@ -635,7 +635,6 @@ void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphics
if (m_frame)
{
painter->save();
painter->setFont(QETApp::diagramTextsFont(fontSize()));
//Adjust the thickness according to the font size,
@@ -653,24 +652,9 @@ void DynamicElementTextItem::paint(QPainter *painter, const QStyleOptionGraphics
painter->setPen(pen);
painter->setRenderHint(QPainter::Antialiasing);
//Get the bounding rectangle of the text
QSizeF size = document()->size();
size.setWidth(document()->idealWidth());
//Remove the margin. Size is exactly the bounding rect of the text
size.rheight() -= document()->documentMargin()*2;
size.rwidth() -= document()->documentMargin()*2;
//Add a little margin only for a better visual;
size.rheight() += 2;
size.rwidth() += 2;
//The pos of the rect
QPointF pos = boundingRect().center();
pos.rx() -= size.width()/2;
pos.ry() -= size.height()/2;
//Adjust the rounding of the rectangle according to the size of the font
qreal ro = (qreal)fontSize()/3;
painter->drawRoundedRect(QRectF(pos, size), ro, ro);
painter->drawRoundedRect(frameRect(), ro, ro);
painter->restore();
}