]>
cloud.milkyroute.net Git - dolphin.git/blob - src/metatextlabel.cpp
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "metatextlabel.h"
22 #include <kglobalsettings.h>
26 #include <QHBoxLayout>
29 MetaTextLabel::MetaTextLabel(QWidget
* parent
) :
36 MetaTextLabel::~MetaTextLabel()
40 void MetaTextLabel::clear()
43 m_layout
->removeWidget(m_lines
);
53 void MetaTextLabel::add(const QString
& labelText
, const QString
& infoText
)
56 Q_ASSERT(m_layout
== 0);
58 m_lines
= new KVBox(this);
59 m_layout
= new QHBoxLayout();
60 m_layout
->addWidget(m_lines
);
66 QWidget
* line
= new QWidget(m_lines
);
68 QLabel
* label
= new QLabel(labelText
, line
);
69 label
->setFont(KGlobalSettings::smallestReadableFont());
70 label
->setAlignment(Qt::AlignRight
| Qt::AlignTop
);
72 QPalette palette
= label
->palette();
73 QColor foreground
= palette
.color(QPalette::Foreground
);
74 foreground
.setAlpha(128);
75 palette
.setColor(QPalette::Foreground
, foreground
);
76 label
->setPalette(palette
);
78 QLabel
* info
= new QLabel(infoText
, line
);
79 info
->setFont(KGlobalSettings::smallestReadableFont());
80 info
->setAlignment(Qt::AlignLeft
| Qt::AlignTop
);
81 info
->setWordWrap(true);
83 QHBoxLayout
* layout
= new QHBoxLayout(line
);
85 layout
->addWidget(label
, 50);
86 layout
->addWidget(info
, 50);
91 #include "metatextlabel.moc"