diff options
| author | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 | 
|---|---|---|
| committer | Jedidiah Barber <contact@jedbarber.id.au> | 2021-07-14 11:49:10 +1200 | 
| commit | d24f813f3f2a05c112e803e4256b53535895fc98 (patch) | |
| tree | 601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/study/WarningPanel.cpp | |
Diffstat (limited to 'src/study/WarningPanel.cpp')
| -rw-r--r-- | src/study/WarningPanel.cpp | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/src/study/WarningPanel.cpp b/src/study/WarningPanel.cpp new file mode 100644 index 0000000..9bf6122 --- /dev/null +++ b/src/study/WarningPanel.cpp @@ -0,0 +1,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; +} | 
