Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/widget/wlabel.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           wlabel.cpp  -  description
00003                              -------------------
00004     begin                : Wed Jan 5 2005
00005     copyright            : (C) 2003 by Tue Haste Andersen
00006     email                : haste@diku.dk
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010 *                                                                         *
00011 *   This program is free software; you can redistribute it and/or modify  *
00012 *   it under the terms of the GNU General Public License as published by  *
00013 *   the Free Software Foundation; either version 2 of the License, or     *
00014 *   (at your option) any later version.                                   *
00015 *                                                                         *
00016 ***************************************************************************/
00017 
00018 #include "wlabel.h"
00019 #include "wskincolor.h"
00020 #include <math.h>
00021 #include <qfont.h>
00022 //Added by qt3to4:
00023 #include <QLabel>
00024 
00025 WLabel::WLabel(QWidget * parent) : WWidget(parent)
00026 {
00027     m_pLabel = new QLabel(this);
00028     m_qsText = "";
00029 }
00030 
00031 WLabel::~WLabel()
00032 {
00033     delete m_pLabel;
00034 }
00035 
00036 void WLabel::setup(QDomNode node)
00037 {
00038     // Colors
00039     QPalette palette = m_pLabel->palette(); //we have to copy out the palette to edit it since it's const (probably for threadsafety)
00040 
00041     if(!WWidget::selectNode(node, "BgColor").isNull()) {
00042         m_qBgColor.setNamedColor(WWidget::selectNodeQString(node, "BgColor"));
00043         //m_pLabel->setPaletteBackgroundColor(WSkinColor::getCorrectColor(m_qBgColor)); //deprecated
00044         palette.setColor(this->backgroundRole(), WSkinColor::getCorrectColor(m_qBgColor));
00045         m_pLabel->setAutoFillBackground(true);
00046     }
00047     m_qFgColor.setNamedColor(WWidget::selectNodeQString(node, "FgColor"));
00048     //m_pLabel->setPaletteForegroundColor(WSkinColor::getCorrectColor(m_qFgColor)); //deprecated
00049     palette.setColor(this->foregroundRole(), WSkinColor::getCorrectColor(m_qFgColor));
00050 
00051     m_pLabel->setPalette(palette);
00052 
00053     m_pLabel->setToolTip(toolTip());
00054 
00055     // Text
00056     if (!selectNode(node, "Text").isNull())
00057         m_qsText = selectNodeQString(node, "Text");
00058     m_pLabel->setText(m_qsText);
00059 
00060     // Size
00061     QString size = selectNodeQString(node, "Size");
00062     int x = size.left(size.indexOf(",")).toInt();
00063     int y = size.mid(size.indexOf(",")+1).toInt();
00064     m_pLabel->setFixedSize(x,y);
00065 
00066     // Alignment
00067     if (!selectNode(node, "Alignment").isNull())
00068     {
00069         if (selectNodeQString(node, "Alignment")=="right")
00070             m_pLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
00071     }
00072 
00073     QString style = selectNodeQString(node, "Style");
00074     if (style != "") {
00075         m_pLabel->setStyleSheet(style);
00076     }
00077 }
00078 
00079 void WLabel::setAlignment(Qt::Alignment i)
00080 {
00081     m_pLabel->setAlignment(i);
00082 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines