summaryrefslogtreecommitdiff
path: root/src/study/WarningPanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/study/WarningPanel.cpp')
-rw-r--r--src/study/WarningPanel.cpp49
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;
+}