BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
CautionSignWidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Info/CautionSignWidget.cpp
6 //! @brief Implements class CautionSignWidget
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <QMessageBox>
17 #include <QPainter>
18 #include <QRect>
19 
21  : QWidget(parent)
22  , m_pixmap(":/images/warning@2x.png")
23  , m_caution_header("Houston, we have a problem.")
24 {
25  setAttribute(Qt::WA_NoSystemBackground);
26  setToolTip(m_caution_header + "\nClick to see details.");
27 }
28 
29 void CautionSignWidget::paintEvent(QPaintEvent* event)
30 {
31  Q_UNUSED(event);
32  QPainter painter(this);
33  QRect target(m_pixmap.rect());
34  painter.drawPixmap(target, m_pixmap);
35 }
36 
37 void CautionSignWidget::mousePressEvent(QMouseEvent* event)
38 {
39  Q_UNUSED(event);
40  QMessageBox box;
41  box.setWindowTitle(m_caution_header);
42  box.setInformativeText(m_caution_message);
43  box.setStandardButtons(QMessageBox::Ok);
44  box.setDefaultButton(QMessageBox::Ok);
45  box.exec();
46 }
47 
48 //! set geometry of widget around center point
50 {
51  setGeometry(x, y, m_pixmap.width(), m_pixmap.height());
52 }
53 
54 void CautionSignWidget::setCautionHeader(const QString& message)
55 {
56  m_caution_header = message;
57  setToolTip(m_caution_header + "\nClick to see details.");
58 }
Defines class CautionSignWidget.
CautionSignWidget(QWidget *parent=nullptr)
void setCautionHeader(const QString &message)
void paintEvent(QPaintEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void setPosition(int x, int y)
set geometry of widget around center point