BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DetailedMessageBox Class Reference

A dialog similar to standard QMessageBox intended for detailed warning messages. More...

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

Public Member Functions

 DetailedMessageBox (QWidget *parent, const QString &title, const QString &text, const QString &details)
 
void setDetailedText (const QString &text)
 
void setText (const QString &text)
 

Private Member Functions

QBoxLayout * createButtonLayout ()
 Creates button layout with buttons. More...
 
QBoxLayout * createInfoLayout ()
 Creates right layout with text and QComboBox selection. More...
 
QBoxLayout * createLogoLayout ()
 Returns layout with icon for left part of the widget. More...
 

Private Attributes

QTextEdit * m_textEdit
 
QLabel * m_topLabel
 

Detailed Description

A dialog similar to standard QMessageBox intended for detailed warning messages.

On the contrary to QMessageBox, the dialog has size grip and visible text editor.

Definition at line 28 of file DetailedMessageBox.h.

Constructor & Destructor Documentation

◆ DetailedMessageBox()

DetailedMessageBox::DetailedMessageBox ( QWidget *  parent,
const QString &  title,
const QString &  text,
const QString &  details 
)

Definition at line 29 of file DetailedMessageBox.cpp.

31  : QDialog(parent), m_topLabel(new QLabel), m_textEdit(new QTextEdit)
32 {
33  setWindowTitle(title);
34  m_topLabel->setText(text);
35  m_textEdit->setText(details);
36  m_textEdit->setReadOnly(true);
37  m_textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
38  setWindowFlags(Qt::Dialog);
39 
40  resize(default_dialog_size);
41  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
42 
43  QColor bgColor(240, 240, 240, 255);
44  QPalette palette;
45  palette.setColor(QPalette::Window, bgColor);
46  setAutoFillBackground(true);
47  setPalette(palette);
48 
49  auto topLayout = new QHBoxLayout;
50  topLayout->addLayout(createLogoLayout());
51  topLayout->addLayout(createInfoLayout());
52  topLayout->addStretch(1);
53 
54  auto mainLayout = new QVBoxLayout;
55  mainLayout->addLayout(topLayout);
56  mainLayout->addWidget(m_textEdit);
57  mainLayout->addLayout(createButtonLayout());
58 
59  setLayout(mainLayout);
60 
61  setSizeGripEnabled(true);
62 }
QBoxLayout * createButtonLayout()
Creates button layout with buttons.
QBoxLayout * createInfoLayout()
Creates right layout with text and QComboBox selection.
QBoxLayout * createLogoLayout()
Returns layout with icon for left part of the widget.

References createButtonLayout(), createInfoLayout(), createLogoLayout(), m_textEdit, and m_topLabel.

Here is the call graph for this function:

Member Function Documentation

◆ createButtonLayout()

QBoxLayout * DetailedMessageBox::createButtonLayout ( )
private

Creates button layout with buttons.

Definition at line 105 of file DetailedMessageBox.cpp.

106 {
107  auto result = new QHBoxLayout;
108 
109  auto okButton = new QPushButton("Ok");
110  connect(okButton, &QPushButton::clicked, this, &DetailedMessageBox::reject);
111 
112  result->addStretch(1);
113  result->addWidget(okButton);
114 
115  return result;
116 }

Referenced by DetailedMessageBox().

◆ createInfoLayout()

QBoxLayout * DetailedMessageBox::createInfoLayout ( )
private

Creates right layout with text and QComboBox selection.

Definition at line 93 of file DetailedMessageBox.cpp.

94 {
95  m_topLabel->setWordWrap(true);
96 
97  auto result = new QVBoxLayout;
98  result->addWidget(m_topLabel);
99  result->setContentsMargins(5, 5, 5, 5);
100  return result;
101 }

References m_topLabel.

Referenced by DetailedMessageBox().

◆ createLogoLayout()

QBoxLayout * DetailedMessageBox::createLogoLayout ( )
private

Returns layout with icon for left part of the widget.

Definition at line 76 of file DetailedMessageBox.cpp.

77 {
78  auto result = new QVBoxLayout;
79 
80  QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
81 
82  auto label = new QLabel;
83  label->setPixmap(icon.pixmap(128));
84 
85  result->addWidget(label);
86  result->setContentsMargins(5, 5, 5, 5);
87 
88  return result;
89 }

Referenced by DetailedMessageBox().

◆ setDetailedText()

void DetailedMessageBox::setDetailedText ( const QString &  text)

Definition at line 69 of file DetailedMessageBox.cpp.

70 {
71  m_textEdit->setText(text);
72 }

References m_textEdit.

◆ setText()

void DetailedMessageBox::setText ( const QString &  text)

Definition at line 64 of file DetailedMessageBox.cpp.

65 {
66  m_topLabel->setText(text);
67 }

References m_topLabel.

Member Data Documentation

◆ m_textEdit

QTextEdit* DetailedMessageBox::m_textEdit
private

Definition at line 43 of file DetailedMessageBox.h.

Referenced by DetailedMessageBox(), and setDetailedText().

◆ m_topLabel

QLabel* DetailedMessageBox::m_topLabel
private

Definition at line 42 of file DetailedMessageBox.h.

Referenced by DetailedMessageBox(), createInfoLayout(), and setText().


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