Commit edb7e936 authored by Milian Wolff's avatar Milian Wolff
Browse files

don't paint too short labels.

parent 0257a9c9
......@@ -92,14 +92,18 @@ public:
{
QGraphicsRectItem::paint(painter, option, widget);
static QFontMetrics m(QFont("monospace"));
const int margin = 5;
const int width = rect().width() - 2 * margin;
if (width < m.averageCharWidth() * 6) {
return;
}
const int height = rect().height();
const QPen oldPen = painter->pen();
QPen pen = oldPen;
pen.setColor(Qt::white);
painter->setPen(pen);
static QFontMetrics m(QFont("monospace", 12));
const int margin = 5;
const int width = rect().width() - 2 * margin;
const int height = rect().height();
painter->drawText(margin + rect().x(), rect().y(), width, height, Qt::AlignCenter | Qt::TextSingleLine, m.elidedText(m_label, Qt::ElideRight, width));
painter->setPen(oldPen);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment