iconlabel.cpp
1 //------------------------------------------------------------------------------
2 // iconlabel.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2015 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "iconlabel.h"
24 
25 IconLabel::IconLabel(QWidget *pParent)
26  : QWidget(pParent)
27 {
28  lblIcon = new QLabel(this);
29  lblIcon->setPixmap(QPixmap(":/icons/help"));
30  lblIcon->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
31 
32  lblText = new QLabel(this);
33  lblText->setText("TextLabel");
34 
35  pLayout = new QHBoxLayout(this);
36  pLayout->addWidget(lblIcon);
37  pLayout->addWidget(lblText);
38  pLayout->setContentsMargins(0, 0, 0, 0);
39 
40  this->setLayout(pLayout);
41  this->setContentsMargins(0, 0, 0, 0);
42 }
43 
44 const QPixmap *IconLabel::pixmap() const
45 {
46  return lblIcon->pixmap();
47 }
48 
49 QString IconLabel::text() const
50 {
51  return lblText->text();
52 }
53 
54 void IconLabel::setPixmap(const QPixmap &pixmap)
55 {
56  lblIcon->setPixmap(pixmap);
57 }
58 
59 void IconLabel::setText(const QString &str)
60 {
61  lblText->setText(str);
62 }
63 
64 void IconLabel::setWordWrap(bool wrap)
65 {
66  lblText->setWordWrap(wrap);
67 }