blob: 9bf6122bc52b868527b31fcac0a876f6c6540b3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include "WarningPanel.h"
WarningPanel::WarningPanel(QWidget* parent):
QFrame(parent),
warningLabel(new QLabel)
{
initPanel();
setLayout(createWarningLayout());
}
void WarningPanel::initPanel()
{
setFrameStyle(QFrame::StyledPanel);
setPalette(QPalette("#ffffcc"));
setAutoFillBackground(true);
hide();
}
QHBoxLayout* WarningPanel::createWarningLayout()
{
QHBoxLayout* warningLt = new QHBoxLayout;
warningLt->addWidget(createWarningIconLabel(), 0, Qt::AlignTop);
warningLt->addWidget(warningLabel, 1);
warningLt->addWidget(createWarningCloseButton(), 0, Qt::AlignTop);
return warningLt;
}
void WarningPanel::setText(const QString& text)
{
warningLabel->setText(text);
}
QLabel* WarningPanel::createWarningIconLabel() const
{
QLabel* label = new QLabel;
label->setPixmap( QPixmap(":/images/warning.png").scaled(
24, 24, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
return label;
}
QToolButton* WarningPanel::createWarningCloseButton() const
{
QToolButton* button = new QToolButton;
button->setAutoRaise(true);
button->setIcon(QIcon(":/images/gray-cross.png"));
button->setShortcut(Qt::Key_Escape);
connect(button, SIGNAL(clicked()), this, SLOT(hide()));
return button;
}
|