aboutsummaryrefslogtreecommitdiffstats
path: root/InfoPanelLabel.cpp
blob: 1dd5dda19c69cada2a772c090a09b3928cd4d69d (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(0, 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);
}