BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
CautionSign Class Reference

Description

The CautionSign controls appearance of CautionSignWidget on top of parent widget.

Definition at line 25 of file CautionSign.h.

Inheritance diagram for CautionSign:
[legend]
Collaboration diagram for CautionSign:
[legend]

Public Member Functions

 CautionSign (QWidget *parent)
 
void clear ()
 Clears caution message;. More...
 
bool isShown () const
 
void setArea (QWidget *area)
 
void setCautionHeader (const QString &cautionHeader)
 
void setCautionMessage (const QString &cautionMessage)
 Shows caution sign on the screen. If clear of previous caution sign had happened just few msec ago, make a small delay, to stress its reapearance. More...
 

Protected Member Functions

bool eventFilter (QObject *obj, QEvent *event) override
 

Private Member Functions

QPoint positionForCautionSign () const
 
void updateLabelGeometry ()
 

Private Attributes

QWidget * m_area
 
QString m_caution_header
 
QString m_caution_message
 
CautionSignWidgetm_cautionWidget
 
bool m_clear_just_had_happened
 

Constructor & Destructor Documentation

◆ CautionSign()

CautionSign::CautionSign ( QWidget *  parent)

Definition at line 30 of file CautionSign.cpp.

31  : QObject(parent)
32  , m_caution_header("Houston, we have a problem.")
33  , m_cautionWidget(nullptr)
34  , m_area(nullptr)
36 {
37  setArea(parent);
38 }
QWidget * m_area
Definition: CautionSign.h:49
CautionSignWidget * m_cautionWidget
Definition: CautionSign.h:48
void setArea(QWidget *area)
Definition: CautionSign.cpp:79
QString m_caution_header
Definition: CautionSign.h:46
bool m_clear_just_had_happened
Definition: CautionSign.h:50

References setArea().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

◆ eventFilter()

bool CautionSign::eventFilter ( QObject *  obj,
QEvent *  event 
)
overrideprotected

Definition at line 90 of file CautionSign.cpp.

91 {
92  if (event->type() == QEvent::Resize)
94 
95  return QObject::eventFilter(obj, event);
96 }
void updateLabelGeometry()
Definition: CautionSign.cpp:98

References updateLabelGeometry().

Here is the call graph for this function:

◆ isShown()

bool CautionSign::isShown ( ) const

Definition at line 85 of file CautionSign.cpp.

86 {
87  return m_cautionWidget != nullptr;
88 }

References m_cautionWidget.

◆ positionForCautionSign()

QPoint CautionSign::positionForCautionSign ( ) const
private

Definition at line 107 of file CautionSign.cpp.

108 {
109  ASSERT(m_area);
110 
111  int x = m_area->width() - xpos_offset;
112  int y = m_area->height() - ypos_offset;
113 
114  if (auto* scrollArea = dynamic_cast<QAbstractScrollArea*>(m_area)) {
115  if (QScrollBar* horizontal = scrollArea->horizontalScrollBar()) {
116  if (horizontal->isVisible())
117  y -= horizontal->height();
118  }
119 
120  if (QScrollBar* vertical = scrollArea->verticalScrollBar()) {
121  if (vertical->isVisible())
122  x -= vertical->width();
123  }
124  }
125 
126  return QPoint(x, y);
127 }

References m_area.

Referenced by updateLabelGeometry().

◆ setArea()

void CautionSign::setArea ( QWidget *  area)

Definition at line 79 of file CautionSign.cpp.

80 {
81  m_area = area;
82  m_area->installEventFilter(this);
83 }

References m_area.

Referenced by CautionSign().

◆ setCautionHeader()

void CautionSign::setCautionHeader ( const QString &  cautionHeader)

Definition at line 52 of file CautionSign.cpp.

53 {
54  m_caution_header = cautionHeader;
55 }

References m_caution_header.

◆ setCautionMessage()

void CautionSign::setCautionMessage ( const QString &  cautionMessage)

Shows caution sign on the screen. If clear of previous caution sign had happened just few msec ago, make a small delay, to stress its reapearance.

Definition at line 60 of file CautionSign.cpp.

61 {
62  ASSERT(m_area);
63 
66  QTimer::singleShot(50, this, [=]() { setCautionMessage(cautionMessage); });
67  } else {
68  m_caution_message = cautionMessage;
69 
70  if (!m_cautionWidget)
72 
75  m_cautionWidget->show();
76  }
77 }
The CautionSignWidget is an transparent widget with caution sign pixmap intended to be overlayed onto...
void setCautionMessage(const QString &message)
void setCautionMessage(const QString &cautionMessage)
Shows caution sign on the screen. If clear of previous caution sign had happened just few msec ago,...
Definition: CautionSign.cpp:60

References m_area, m_caution_message, m_cautionWidget, m_clear_just_had_happened, CautionSignWidget::setCautionMessage(), and updateLabelGeometry().

Referenced by ScriptPanel::generateCodeSnippet(), PythonScriptWidget::generatePythonScript(), RunFitControlWidget::onFittingError(), DistributionPlot::plotItem(), ParameterTuningWidget::updateJobStatus(), and RealSpaceCanvas::updateScene().

Here is the call graph for this function:

◆ updateLabelGeometry()

void CautionSign::updateLabelGeometry ( )
private

Definition at line 98 of file CautionSign.cpp.

99 {
100  if (!m_cautionWidget || !m_area)
101  return;
102 
103  QPoint pos = positionForCautionSign();
104  m_cautionWidget->setPosition(pos.x(), pos.y());
105 }
void setPosition(int x, int y)
set geometry of widget around center point
QPoint positionForCautionSign() const

References m_area, m_cautionWidget, positionForCautionSign(), and CautionSignWidget::setPosition().

Referenced by eventFilter(), and setCautionMessage().

Here is the call graph for this function:

Member Data Documentation

◆ m_area

QWidget* CautionSign::m_area
private

◆ m_caution_header

QString CautionSign::m_caution_header
private

Definition at line 46 of file CautionSign.h.

Referenced by setCautionHeader().

◆ m_caution_message

QString CautionSign::m_caution_message
private

Definition at line 47 of file CautionSign.h.

Referenced by clear(), and setCautionMessage().

◆ m_cautionWidget

CautionSignWidget* CautionSign::m_cautionWidget
private

Definition at line 48 of file CautionSign.h.

Referenced by clear(), isShown(), setCautionMessage(), and updateLabelGeometry().

◆ m_clear_just_had_happened

bool CautionSign::m_clear_just_had_happened
private

Definition at line 50 of file CautionSign.h.

Referenced by clear(), and setCautionMessage().


The documentation for this class was generated from the following files: