BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
AboutDialog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Main/AboutDialog.cpp
6 //! @brief Implements class AboutDialog
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 "GUI/Util/Path.h"
19 #include <QDate>
20 #include <QLabel>
21 #include <QPushButton>
22 #include <QVBoxLayout>
23 
24 namespace {
25 
26 QLabel* createLinkLabel(const QString& text)
27 {
28  auto* result = new QLabel();
29  result->setTextFormat(Qt::RichText);
30  result->setTextInteractionFlags(Qt::TextBrowserInteraction);
31  result->setText(text);
32  result->setOpenExternalLinks(true);
33  return result;
34 }
35 
36 QLabel* createLogoLabel()
37 {
38  QPixmap logo(":/images/about_icon.awk", "JPG");
39  auto* result = new QLabel;
40  result->setPixmap(logo.scaled(656, 674, Qt::KeepAspectRatio));
41  return result;
42 }
43 
44 } // namespace
45 
46 AboutDialog::AboutDialog(QWidget* parent)
47  : QDialog(parent)
48 {
49  QColor bgColor(240, 240, 240, 255);
50  QPalette palette;
51  palette.setColor(QPalette::Window, bgColor);
52  setAutoFillBackground(true);
53  setPalette(palette);
54 
55  setWindowTitle("About BornAgain");
56  setWindowFlags(Qt::Dialog);
57 
58  auto* detailsLayout = new QHBoxLayout;
59  detailsLayout->addLayout(createLogoLayout());
60  detailsLayout->addLayout(createTextLayout());
61 
62  auto* mainLayout = new QVBoxLayout;
63  mainLayout->addLayout(detailsLayout);
64  mainLayout->addLayout(createButtonLayout());
65 
66  setLayout(mainLayout);
67 }
68 
70 {
71  auto* result = new QVBoxLayout;
72 
73  QPixmap logo(":/images/about_icon.png");
74  auto* label = new QLabel;
75  label->setPixmap(logo.scaled(120, 120, Qt::KeepAspectRatio));
76 
77  result->addWidget(label);
78  result->addStretch(1);
79  result->setContentsMargins(5, 5, 5, 5);
80 
81  return result;
82 }
83 
85 {
86  auto* result = new QVBoxLayout;
87 
88  QFont titleFont;
89  titleFont.setPointSize(DesignerHelper::getLabelFontSize() + 2);
90  titleFont.setBold(true);
91 
92  QFont normalFont;
93  normalFont.setPointSize(DesignerHelper::getLabelFontSize() + 2);
94  normalFont.setBold(false);
95 
96  // title
97  auto* aboutTitleLabel =
98  new QLabel("BornAgain version " + GUI::Util::Path::getBornAgainVersionString());
99  aboutTitleLabel->setFont(titleFont);
100 
101  // description
102  QString description = "Open-source research software to simulate and fit neutron and x-ray"
103  " reflectometry and grazing-incidence small-angle scattering.";
104  auto* descriptionLabel = new QLabel(description);
105  descriptionLabel->setFont(normalFont);
106  descriptionLabel->setWordWrap(true);
107 
108  // copyright
109  auto* copyrightLabel = new QLabel("Copyright: Forschungszentrum Jülich GmbH 2012-"
110  + QDate::currentDate().toString("yyyy") + ".");
111  copyrightLabel->setFont(normalFont);
112 
113  // home page
114  auto* homepageLabel = createLinkLabel(
115  "Homepage: "
116  " <a href=\"https://www.bornagainproject.org\">www.bornagainproject.org</a>.");
117  homepageLabel->setFont(normalFont);
118 
119  // mailing list
120  auto* mailingLabel = createLinkLabel(
121  "For updates, subscribe to <a "
122  "href = \"https://lists.fz-juelich.de/mailman/listinfo/BornAgain-announcements\">"
123  "bornagain-announcements</a>.");
124  mailingLabel->setFont(normalFont);
125  mailingLabel->setWordWrap(true);
126 
127  result->addWidget(aboutTitleLabel);
128  result->addStretch(1);
129  result->addWidget(descriptionLabel);
130  result->addStretch(1);
131  result->addWidget(copyrightLabel);
132  result->addStretch(1);
133  result->addWidget(homepageLabel);
134  result->addStretch(1);
135  result->addWidget(mailingLabel);
136  result->addStretch(1);
137 
138  return result;
139 }
140 
142 {
143  auto* result = new QHBoxLayout;
144 
145  auto* closeButton = new QPushButton("Close");
146  connect(closeButton, &QPushButton::clicked, this, &QDialog::reject);
147 
148  result->addStretch(1);
149  result->addWidget(closeButton);
150 
151  static const char mydata[] = {0x64, 0x65, 0x76, 0x73};
152  QByteArray b = QByteArray::fromRawData(mydata, sizeof(mydata));
153  auto* f = new ShortcodeFilter(b, this);
154  connect(f, &ShortcodeFilter::found, this, [=]() { layout()->addWidget(createLogoLabel()); });
155  installEventFilter(f);
156 
157  return result;
158 }
Defines class AboutDialog.
Defines classes releted to event filtering.
Defines class DesignerHelper.
Defines class Helpers functions.
QBoxLayout * createButtonLayout()
QBoxLayout * createTextLayout()
Definition: AboutDialog.cpp:84
AboutDialog(QWidget *parent=nullptr)
Definition: AboutDialog.cpp:46
QBoxLayout * createLogoLayout()
Definition: AboutDialog.cpp:69
static int getLabelFontSize()
Event filter for global tracking of shortcodes.
QString getBornAgainVersionString()
Definition: Path.cpp:60
QString toString(const QModelIndex &index)
Provides string representation of index data.