From 8031720dbcdae5839e1c70d1e85df85539003c0f Mon Sep 17 00:00:00 2001 From: RJ Ryan Date: Tue, 24 Dec 2013 12:22:33 -0500 Subject: Refactor WNumber to inherit from WLabel since they had almost identical code. --- src/widget/wlabel.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/widget/wlabel.cpp') diff --git a/src/widget/wlabel.cpp b/src/widget/wlabel.cpp index 147b77e3cb..5926ac81c6 100644 --- a/src/widget/wlabel.cpp +++ b/src/widget/wlabel.cpp @@ -15,27 +15,28 @@ * * ***************************************************************************/ +#include "widget/wlabel.h" + +#include #include -#include "widget/wlabel.h" #include "widget/wskincolor.h" -WLabel::WLabel(QWidget * parent) : WWidget(parent) -{ - m_pLabel = new QLabel(this); +WLabel::WLabel(QWidget* pParent) + : WWidget(pParent), + m_pLabel(new QLabel(this)), + m_qsText("") { QLayout* pLayout = new QVBoxLayout(this); pLayout->setContentsMargins(0, 0, 0, 0); pLayout->addWidget(m_pLabel); setLayout(pLayout); - m_qsText = ""; } WLabel::~WLabel() { delete m_pLabel; } -void WLabel::setup(QDomNode node) -{ +void WLabel::setup(QDomNode node) { // Colors QPalette palette = m_pLabel->palette(); //we have to copy out the palette to edit it since it's const (probably for threadsafety) if (!WWidget::selectNode(node, "BgColor").isNull()) { @@ -52,13 +53,19 @@ void WLabel::setup(QDomNode node) m_qsText = selectNodeQString(node, "Text"); m_pLabel->setText(m_qsText); + // Font size + if (!selectNode(node, "FontSize").isNull()) { + int fontsize = 9; + fontsize = selectNodeQString(node, "FontSize").toInt(); + m_pLabel->setFont( QFont("Helvetica",fontsize,QFont::Normal) ); + } + // Alignment if (!selectNode(node, "Alignment").isNull()) { - if (selectNodeQString(node, "Alignment")=="right") + if (selectNodeQString(node, "Alignment")=="right") { m_pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter); - // FWI: Begin of font alignment patch - else if (selectNodeQString(node, "Alignment")=="center") + } else if (selectNodeQString(node, "Alignment")=="center") { m_pLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); - // FWI: End of font alignment patch + } } } -- cgit v1.2.3