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

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.

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
 

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)
32  , m_topLabel(new QLabel)
33  , m_textEdit(new QTextEdit)
34 {
35  setWindowTitle(title);
36  m_topLabel->setText(text);
37  m_textEdit->setText(details);
38  m_textEdit->setReadOnly(true);
39  m_textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
40  setWindowFlags(Qt::Dialog);
41 
42  resize(default_dialog_size);
43  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
44 
45  QColor bgColor(240, 240, 240, 255);
46  QPalette palette;
47  palette.setColor(QPalette::Window, bgColor);
48  setAutoFillBackground(true);
49  setPalette(palette);
50 
51  auto* topLayout = new QHBoxLayout;
52  topLayout->addLayout(createLogoLayout());
53  topLayout->addLayout(createInfoLayout());
54  topLayout->addStretch(1);
55 
56  auto* mainLayout = new QVBoxLayout;
57  mainLayout->addLayout(topLayout);
58  mainLayout->addWidget(m_textEdit);
59  mainLayout->addLayout(createButtonLayout());
60 
61  setLayout(mainLayout);
62 
63  setSizeGripEnabled(true);
64 }
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 107 of file DetailedMessageBox.cpp.

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

Referenced by DetailedMessageBox().

◆ createInfoLayout()

QBoxLayout * DetailedMessageBox::createInfoLayout ( )
private

Creates right layout with text and QComboBox selection.

Definition at line 95 of file DetailedMessageBox.cpp.

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

References m_topLabel.

Referenced by DetailedMessageBox().

◆ createLogoLayout()

QBoxLayout * DetailedMessageBox::createLogoLayout ( )
private

Returns layout with icon for left part of the widget.

Definition at line 78 of file DetailedMessageBox.cpp.

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

Referenced by DetailedMessageBox().

◆ setDetailedText()

void DetailedMessageBox::setDetailedText ( const QString &  text)

Definition at line 71 of file DetailedMessageBox.cpp.

72 {
73  m_textEdit->setText(text);
74 }

References m_textEdit.

◆ setText()

void DetailedMessageBox::setText ( const QString &  text)

Definition at line 66 of file DetailedMessageBox.cpp.

67 {
68  m_topLabel->setText(text);
69 }

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: