BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
mainwindow.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/mainwindow/mainwindow.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"
24 #include <QCloseEvent>
25 #include <QCoreApplication>
26 #include <QFileDialog>
27 #include <QMenuBar>
28 #include <QSettings>
29 
30 namespace {
31 const QString main_window_group = "MainWindow";
32 const QString size_key = "size";
33 const QString pos_key = "pos";
34 } // namespace
35 
36 namespace gui2 {
37 
39  : m_models(std::make_unique<ApplicationModels>()), m_actionManager(new ActionManager(this))
40 {
44  setCentralWidget(m_barWidget);
45 }
46 
47 MainWindow::~MainWindow() = default;
48 
49 void MainWindow::closeEvent(QCloseEvent* event)
50 {
53  event->accept();
54  } else {
55  event->ignore();
56  }
57 }
58 
60 {
61  QCoreApplication::setApplicationName("BornAgain gui2 preview");
62  QCoreApplication::setApplicationVersion(QString::fromStdString(BornAgain::GetVersionNumber()));
63  QCoreApplication::setOrganizationName("BornAgain");
64 
65  QSettings settings;
66  if (settings.childGroups().contains(main_window_group)) {
67  settings.beginGroup(main_window_group);
68  resize(settings.value(size_key, QSize(400, 400)).toSize());
69  move(settings.value(pos_key, QPoint(200, 200)).toPoint());
70  settings.endGroup();
71  }
72 }
73 
75 {
76  m_welcomeView = new WelcomeView(m_models.get());
78  m_simView = new SimulationView(m_models.get());
81 
82  m_barWidget->addWidget(m_welcomeView, "Project");
84  m_barWidget->addWidget(m_simView, "Simulation");
85  m_barWidget->addWidget(new QWidget, "Fitting", false);
86  m_barWidget->addWidget(new QWidget, "Export", false);
87  m_barWidget->addWidget(m_settingsView, "Settings");
89 }
90 
91 //! Setup main connections.
92 
94 {
95  // connect ActionManager signals with WelcomeView slots
106 
109 
111 }
112 
114 {
115  QSettings settings;
116  settings.beginGroup(main_window_group);
117  settings.setValue(size_key, size());
118  settings.setValue(pos_key, pos());
119  settings.endGroup();
120 }
121 
122 } // namespace gui2
Defines class CLASS?
Actions for MainWindow.
Definition: actionmanager.h:31
void saveCurrentProjectRequest()
void clearResentProjectListRequest()
void setRecentProjectsList(const QStringList &projects)
void openExistingProjectRequest(const QString &dirname)
void createNewProjectRequest()
Main class to holds all models of GUI session.
Main window to import user data.
Widget container with functionality similar to QTabWidget.
Definition: mainbarwidget.h:33
void addWidget(QWidget *widget, const QString &title, bool is_enabled=true)
void setCurrentIndex(int index)
SimulationView * m_simView
Definition: mainwindow.h:54
void init_components()
Definition: mainwindow.cpp:74
void closeEvent(QCloseEvent *event)
Definition: mainwindow.cpp:49
void init_application()
Definition: mainwindow.cpp:59
ActionManager * m_actionManager
Definition: mainwindow.h:51
SettingsView * m_settingsView
Definition: mainwindow.h:55
WelcomeView * m_welcomeView
Definition: mainwindow.h:52
ImportDataView * m_importDataView
Definition: mainwindow.h:53
void init_connections()
Setup main connections.
Definition: mainwindow.cpp:93
MainBarWidget * m_barWidget
Definition: mainwindow.h:56
std::unique_ptr< ApplicationModels > m_models
Definition: mainwindow.h:50
Main settings view, belongs directly to MainWindow.
Definition: settingsview.h:33
Main simulation window with all components for quick sample editing and simulations.
Welcome view. Main widget on first tab of MainWindow.
Definition: welcomeview.h:32
bool canCloseProject() const
Returns 'true' if current project can be closed.
Definition: welcomeview.cpp:55
void onCreateNewProject()
Definition: welcomeview.cpp:65
void onClearRecentProjectsList()
Definition: welcomeview.cpp:85
void onSaveCurrentProject()
Definition: welcomeview.cpp:75
void recentProjectsListModified(const QStringList &projects)
void onOpenExistingProject(const QString &dirname={})
Definition: welcomeview.cpp:70
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
Definition: filesystem.h:81
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?