summaryrefslogtreecommitdiffstats
path: root/InfoPanelLabel.cpp
blob: c87e7e50a434c4d25bd293a6a2ae0bfaffde0ffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "InfoPanelLabel.h"

InfoPanelLabel::InfoPanelLabel(QWidget *parent, QRect &r):QLabel(parent),rect(r)
{
}

void InfoPanelLabel::Init(int pos, int height, const QString &text, QFont *font)
{
    if (text.length() > 0)
    {
        setText(text);
        if (font)
            setFont(*font);
    }
    setStyleSheet("QLabel { background-color : white; color : #FFFFFF; }");
    setGeometry(QRect(rect.x(), rect.y()+pos, rect.width(), height));

    /* if text is too big, align left so that we can at least read the beginning : */
    if (this->text().length() > 0 && this->fontMetrics().width(this->text()) >= rect.width())
        setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    else
        setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

    setVisible(true);
}