2015-12-09 19:21:38 +08:00
|
|
|
#include "icontitlewidget.h"
|
|
|
|
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QString>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QStyle>
|
|
|
|
|
|
|
|
IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent) :
|
|
|
|
QFrame(parent)
|
|
|
|
{
|
2016-02-12 14:15:10 +08:00
|
|
|
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
2015-12-09 19:21:38 +08:00
|
|
|
l->setContentsMargins(0, 0, 0, 0);
|
|
|
|
setLayout(l);
|
|
|
|
|
2016-02-26 16:07:19 +08:00
|
|
|
_iconLabel = new QLabel();
|
|
|
|
if (!icon.isNull())
|
|
|
|
_iconLabel->setPixmap(icon.pixmap(16, 16));
|
|
|
|
l->addWidget(_iconLabel);
|
|
|
|
|
|
|
|
_titleLabel = new QLabel();
|
|
|
|
_titleLabel->setText(title);
|
|
|
|
l->addWidget(_titleLabel, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IconTitleWidget::polishUpdate()
|
|
|
|
{
|
|
|
|
QList<QWidget*> widgets;
|
|
|
|
widgets.append(_iconLabel);
|
|
|
|
widgets.append(_titleLabel);
|
|
|
|
foreach (QWidget* w, widgets)
|
2015-12-09 19:21:38 +08:00
|
|
|
{
|
2016-02-26 16:07:19 +08:00
|
|
|
w->style()->unpolish(w);
|
|
|
|
w->style()->polish(w);
|
|
|
|
w->update();
|
2015-12-09 19:21:38 +08:00
|
|
|
}
|
2016-02-15 21:25:12 +08:00
|
|
|
}
|