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-02 20:49:10 +08:00
|
|
|
// Icon label
|
2015-12-09 19:21:38 +08:00
|
|
|
if (icon.isNull())
|
|
|
|
{
|
2016-02-15 22:18:52 +08:00
|
|
|
// QLabel* titleIcon = new QLabel();
|
|
|
|
// titleIcon->setPixmap(style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(16, 16));
|
|
|
|
// l->addWidget(titleIcon);
|
2015-12-09 19:21:38 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-12 14:15:10 +08:00
|
|
|
QLabel* titleIcon = new QLabel();
|
2015-12-09 19:21:38 +08:00
|
|
|
titleIcon->setPixmap(icon.pixmap(16, 16));
|
2016-02-02 20:49:10 +08:00
|
|
|
l->addWidget(titleIcon);
|
2015-12-09 19:21:38 +08:00
|
|
|
}
|
|
|
|
|
2016-02-02 20:49:10 +08:00
|
|
|
// Title label
|
2016-02-12 14:15:10 +08:00
|
|
|
QLabel* titleText = new QLabel(title);
|
|
|
|
QFont titleFont = titleText->font();
|
2015-12-09 19:21:38 +08:00
|
|
|
titleText->setFont(titleFont);
|
|
|
|
l->addWidget(titleText, 1);
|
2016-02-15 21:25:12 +08:00
|
|
|
}
|