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

Description

The dialog to inform user about encountered problems during the loading of old project.

Definition at line 24 of file ProjectLoadProblemDialog.h.

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

Public Member Functions

 ProjectLoadProblemDialog (QWidget *parent, const QStringList &details, QString documentVersion)
 

Private Member Functions

QLayout * buttonLayout ()
 
QWidget * createWarningWidget ()
 
QString explanationText () const
 Returns explanations what went wrong. More...
 

Private Attributes

QString m_projectDocumentVersion
 

Constructor & Destructor Documentation

◆ ProjectLoadProblemDialog()

ProjectLoadProblemDialog::ProjectLoadProblemDialog ( QWidget *  parent,
const QStringList &  details,
QString  documentVersion 
)

Definition at line 30 of file ProjectLoadProblemDialog.cpp.

32  : QDialog(parent)
33  , m_projectDocumentVersion(std::move(documentVersion))
34 {
35  setMinimumSize(256, 256);
36  resize(520, 620);
37  setWindowTitle("Problems encountered while loading project");
38  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
39 
40  auto* mainLayout = new QVBoxLayout;
41 
42  QFont titleFont;
43  titleFont.setPointSize(DesignerHelper::getSectionFontSize());
44  titleFont.setBold(true);
45 
46  const auto addHeadline = [&](const QString& text) {
47  auto* label = new QLabel(text, this);
48  label->setFont(titleFont);
49  mainLayout->addWidget(label);
50  };
51 
52  // -- warning icon + info
53  auto* topPanelLayout = new QHBoxLayout;
54  auto* messageLabel = new QLabel("Some parts of the project were not loaded correctly.");
55  messageLabel->setFont(titleFont);
56  messageLabel->setWordWrap(true);
57 
58  topPanelLayout->addWidget(createWarningWidget());
59  topPanelLayout->addWidget(messageLabel);
60  topPanelLayout->setContentsMargins(0, 0, 0, 0);
61  mainLayout->addLayout(topPanelLayout);
62 
63  // -- explanations
64  addHeadline("Why did this happen?");
65  auto* explanationLabel = new QLabel(explanationText());
66  explanationLabel->setWordWrap(true);
67  mainLayout->addWidget(explanationLabel);
68 
69  addHeadline("What to do?");
70  auto* adviceLabel =
71  new QLabel("Check parameters of your items and re-enter uninitialized values. "
72  "Use detailed log below to get a hint what went wrong. "
73  "After that, save your project and work as normal.");
74  adviceLabel->setWordWrap(true);
75  mainLayout->addWidget(adviceLabel);
76 
77  // -- details view
78  addHeadline("Details:");
79  auto* detailsWidget = new QListWidget;
80  detailsWidget->setWordWrap(true);
81  detailsWidget->setAlternatingRowColors(true);
82  detailsWidget->addItems(details);
83  mainLayout->addWidget(detailsWidget);
84 
85  // -- buttons
86  mainLayout->addLayout(buttonLayout());
87 
88  setLayout(mainLayout);
89  setAttribute(Qt::WA_DeleteOnClose, true);
90 }
static int getSectionFontSize()
Returns system dependent font size.
QString explanationText() const
Returns explanations what went wrong.

References buttonLayout(), createWarningWidget(), explanationText(), and DesignerHelper::getSectionFontSize().

Here is the call graph for this function:

Member Function Documentation

◆ buttonLayout()

QLayout * ProjectLoadProblemDialog::buttonLayout ( )
private

Definition at line 107 of file ProjectLoadProblemDialog.cpp.

108 {
109  auto* button = new QPushButton("Close", this);
110  button->setAutoDefault(false);
111  connect(button, &QPushButton::clicked, this, &ProjectLoadProblemDialog::close);
112 
113  auto* result = new QHBoxLayout;
114  result->addStretch(3);
115  result->setContentsMargins(0, 0, 0, 0);
116  result->addWidget(button);
117 
118  return result;
119 }

Referenced by ProjectLoadProblemDialog().

◆ createWarningWidget()

QWidget * ProjectLoadProblemDialog::createWarningWidget ( )
private

Definition at line 92 of file ProjectLoadProblemDialog.cpp.

93 {
94  auto* warningLabel = new QLabel;
95  warningLabel->setPixmap(QPixmap(":/images/warning_64x64.png"));
96 
97  auto* warningWidget = new QWidget;
98  warningWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
99  warningWidget->resize(top_panel_height, top_panel_height);
100  auto* warningWidgetLayout = new QHBoxLayout;
101  warningWidgetLayout->addWidget(warningLabel);
102  warningWidget->setLayout(warningWidgetLayout);
103 
104  return warningWidget;
105 }

Referenced by ProjectLoadProblemDialog().

◆ explanationText()

QString ProjectLoadProblemDialog::explanationText ( ) const
private

Returns explanations what went wrong.

Definition at line 122 of file ProjectLoadProblemDialog.cpp.

123 {
125  return QString(
126  "Given project was created using BornAgain version %1 "
127  " which is different from version %2 you are currently using. "
128  "At the moment we provide only limited support for import from older versions.")
131  }
132 
133  return QString("Given project was created using BornAgain version %1 "
134  "which is the same as the current version of the framework. "
135  "Strangely enough, some parts were not loaded correctly due to format mismatch. "
136  "Please contact the developers.")
138 }
QString getBornAgainVersionString()
Definition: Path.cpp:60

References GUI::Util::Path::getBornAgainVersionString(), and m_projectDocumentVersion.

Referenced by ProjectLoadProblemDialog().

Here is the call graph for this function:

Member Data Documentation

◆ m_projectDocumentVersion

QString ProjectLoadProblemDialog::m_projectDocumentVersion
private

Definition at line 33 of file ProjectLoadProblemDialog.h.

Referenced by explanationText().


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