BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
openprojectwidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/welcomeview/openprojectwidget.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "BAVersion.h"
19 #include <QHBoxLayout>
20 #include <QLabel>
21 #include <QPushButton>
22 #include <QVBoxLayout>
23 
24 namespace {
25 int logo_width()
26 {
27  return ModelView::Utils::SizeOfLetterM().height() * 40;
28 }
29 
30 const QString str_open = "Open";
31 const QString str_new = "New";
32 
33 } // namespace
34 
35 namespace gui2 {
36 
37 OpenProjectWidget::OpenProjectWidget(QWidget* parent) : QWidget(parent)
38 {
39  auto layout = new QVBoxLayout(this);
40 
41  QPixmap logo(":/icons/F-letter_1000x.png");
42  auto label = new QLabel;
43  label->setPixmap(logo.scaled(logo_width(), logo_width(), Qt::KeepAspectRatio));
44 
45  layout->addSpacing(ModelView::Utils::SizeOfLetterM().height() * 1.5);
46  layout->addWidget(label, 0, Qt::AlignHCenter);
47  layout->addSpacing(ModelView::Utils::SizeOfLetterM().height());
48  layout->addLayout(createProjectTitleLayout());
49  layout->addSpacing(ModelView::Utils::SizeOfLetterM().height());
50  layout->addLayout(createLinkedLabelLayout());
51  layout->addStretch();
52 }
53 
55 {
56  return StyleUtils::DockSizeHint();
57 }
58 
60 {
62 }
63 
65 {
66  auto result = new QHBoxLayout;
67  QString title =
68  "BornAgain " + QString::fromStdString(BornAgain::GetVersionNumber()) + ", gui2 preview";
69  auto label = new QLabel(title);
71 
72  result->addWidget(label, 0, Qt::AlignHCenter);
73  return result;
74 }
75 
77 {
78  auto result = new QHBoxLayout;
79 
81  m_newProjectLabel->setToolTip("Create new project");
82  connect(m_newProjectLabel, &QLabel::linkActivated, [this](auto) { createNewProjectRequest(); });
84 
86  m_openProjectLabel->setToolTip("Open existing project");
87  connect(m_openProjectLabel, &QLabel::linkActivated,
88  [this](auto) { openExistingProjectRequest(); });
90 
91  result->addStretch(1);
92  result->addWidget(m_newProjectLabel);
93  result->addSpacing(ModelView::Utils::WidthOfLetterM());
94  result->addWidget(m_openProjectLabel);
95  result->addStretch(1);
96 
97  return result;
98 }
99 
100 } // namespace gui2
OpenProjectWidget(QWidget *parent=nullptr)
QBoxLayout * createProjectTitleLayout()
QBoxLayout * createLinkedLabelLayout()
QSize minimumSizeHint() const override
QSize sizeHint() const override
Defines class CLASS?
MVVM_VIEW_EXPORT QSize SizeOfLetterM()
Returns size corresponding to actual size of letter M basing on current font metrics.
MVVM_VIEW_EXPORT QString ClickableText(const QString &text, const QString &tag={})
Returns text wrapped into 'href' tag to provide clickable links in QLabel.
MVVM_VIEW_EXPORT void ScaleLabelFont(QLabel *label, double scale)
Set label's font size to system font size scaled by given factor.
MVVM_VIEW_EXPORT int WidthOfLetterM()
Returns width of the letter 'M' deduced from current font metrics.
DAREFLCORE_EXPORT QSize DockMinimumSizeHint()
Hint on minimum size of docks on main reflectometry window.
Definition: styleutils.cpp:34
DAREFLCORE_EXPORT QSize DockSizeHint()
Hint on size of docks on main reflectometry window.
Definition: styleutils.cpp:29
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Defines class CLASS?
Defines class CLASS?