From d24f813f3f2a05c112e803e4256b53535895fc98 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Wed, 14 Jul 2021 11:49:10 +1200 Subject: Initial mirror commit --- src/study/WarningPanel.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/study/WarningPanel.cpp (limited to 'src/study/WarningPanel.cpp') 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; +} -- cgit