66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#include "messagedialog.h"
|
|
|
|
const int ICON_SIZE = 24;
|
|
const int BTN_W = 88;
|
|
const int BTN_H = 48;
|
|
const int WIN_W = 510;
|
|
const int WIN_H = 202;
|
|
|
|
MessageDialog::MessageDialog(QWidget *parent) : kdk::KDialog(parent)
|
|
{
|
|
setFixedSize(WIN_W, WIN_H);
|
|
setWindowModality(Qt::WindowModal);
|
|
setWindowModality(Qt::ApplicationModal);
|
|
|
|
m_icon = new QLabel(this);
|
|
m_icon->resize(ICON_SIZE, ICON_SIZE);
|
|
m_textLab = new QLabel(this);
|
|
m_textLab->setAlignment(Qt::AlignLeft);
|
|
m_textLab->setWordWrap(true);
|
|
|
|
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
hLayout->setMargin(0);
|
|
hLayout->setSpacing(0);
|
|
hLayout->addWidget(m_icon);
|
|
hLayout->addSpacing(8);
|
|
hLayout->addWidget(m_textLab);
|
|
hLayout->addStretch();
|
|
|
|
m_btnLayout = new QHBoxLayout;
|
|
m_btnLayout->setMargin(0);
|
|
m_btnLayout->setSpacing(14);
|
|
m_btnLayout->addStretch();
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
layout->setMargin(24);
|
|
layout->setSpacing(0);
|
|
layout->addLayout(hLayout);
|
|
layout->addStretch();
|
|
layout->addLayout(m_btnLayout);
|
|
|
|
mainWidget()->setLayout(layout);
|
|
}
|
|
|
|
void MessageDialog::setText(QString text)
|
|
{
|
|
m_textLab->setText(text);
|
|
}
|
|
|
|
void MessageDialog::setIconPixmap(QIcon icon)
|
|
{
|
|
m_icon->setPixmap(icon.pixmap(QSize(ICON_SIZE, ICON_SIZE)));
|
|
}
|
|
|
|
QPushButton *MessageDialog::addButton(QString text)
|
|
{
|
|
QPushButton *btn = new QPushButton(this);
|
|
btn->setText(text);
|
|
connect(btn, &QPushButton::clicked, this, [=]() {
|
|
Q_EMIT buttonClicked(btn);
|
|
close();
|
|
});
|
|
m_btnLayout->addWidget(btn);
|
|
|
|
return btn;
|
|
}
|