BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
gui2::MainWindow Class Reference

Application main window. More...

Inheritance diagram for gui2::MainWindow:
[legend]
Collaboration diagram for gui2::MainWindow:
[legend]

Public Member Functions

 MainWindow ()
 
 ~MainWindow ()
 

Protected Member Functions

void closeEvent (QCloseEvent *event)
 

Private Member Functions

void init_application ()
 
void init_components ()
 
void init_connections ()
 Setup main connections. More...
 
void write_settings ()
 

Private Attributes

ActionManagerm_actionManager {nullptr}
 
MainBarWidgetm_barWidget {nullptr}
 
ImportDataViewm_importDataView {nullptr}
 
std::unique_ptr< ApplicationModelsm_models
 
SettingsViewm_settingsView {nullptr}
 
SimulationViewm_simView {nullptr}
 
WelcomeViewm_welcomeView {nullptr}
 

Detailed Description

Application main window.

Definition at line 34 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( )

Definition at line 38 of file mainwindow.cpp.

39  : m_models(std::make_unique<ApplicationModels>()), m_actionManager(new ActionManager(this))
40 {
44  setCentralWidget(m_barWidget);
45 }
Class to handle MainWindow's menu and corresponding actions.
Definition: actionmanager.h:28
void init_components()
Definition: mainwindow.cpp:74
void init_application()
Definition: mainwindow.cpp:59
ActionManager * m_actionManager
Definition: mainwindow.h:51
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

References init_application(), init_components(), init_connections(), and m_barWidget.

Here is the call graph for this function:

◆ ~MainWindow()

MainWindow::~MainWindow ( )
default

Member Function Documentation

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent *  event)
protected

Definition at line 49 of file mainwindow.cpp.

50 {
53  event->accept();
54  } else {
55  event->ignore();
56  }
57 }
WelcomeView * m_welcomeView
Definition: mainwindow.h:52
bool canCloseProject() const
Returns 'true' if current project can be closed.
Definition: welcomeview.cpp:55

References gui2::WelcomeView::canCloseProject(), m_welcomeView, and write_settings().

Here is the call graph for this function:

◆ init_application()

void MainWindow::init_application ( )
private

Definition at line 59 of file mainwindow.cpp.

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 }

Referenced by MainWindow().

◆ init_components()

void MainWindow::init_components ( )
private

Definition at line 74 of file mainwindow.cpp.

75 {
76  m_welcomeView = new WelcomeView(m_models.get());
78  m_simView = new SimulationView(m_models.get());
79  m_settingsView = new SettingsView(m_models.get());
80  m_barWidget = new MainBarWidget;
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 }
The ImportDataView class is a main view for importing experimental data.
void addWidget(QWidget *widget, const QString &title, bool is_enabled=true)
void setCurrentIndex(int index)
SimulationView * m_simView
Definition: mainwindow.h:54
SettingsView * m_settingsView
Definition: mainwindow.h:55
ImportDataView * m_importDataView
Definition: mainwindow.h:53

References gui2::MainBarWidget::addWidget(), m_barWidget, m_importDataView, m_models, m_settingsView, m_simView, m_welcomeView, and gui2::MainBarWidget::setCurrentIndex().

Referenced by MainWindow().

Here is the call graph for this function:

◆ init_connections()

void MainWindow::init_connections ( )
private

Setup main connections.

Definition at line 93 of file mainwindow.cpp.

94 {
95  // connect ActionManager signals with WelcomeView slots
106 
109 
111 }
void saveCurrentProjectRequest()
void clearResentProjectListRequest()
void setRecentProjectsList(const QStringList &projects)
void openExistingProjectRequest(const QString &dirname)
void createNewProjectRequest()
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

References gui2::ActionManager::clearResentProjectListRequest(), gui2::ActionManager::createNewProjectRequest(), m_actionManager, m_welcomeView, gui2::WelcomeView::onClearRecentProjectsList(), gui2::WelcomeView::onCreateNewProject(), gui2::WelcomeView::onOpenExistingProject(), gui2::WelcomeView::onSaveCurrentProject(), gui2::WelcomeView::onSaveProjectAs(), gui2::ActionManager::openExistingProjectRequest(), gui2::WelcomeView::recentProjectsListModified(), gui2::ActionManager::saveCurrentProjectRequest(), gui2::ActionManager::saveProjectAsRequest(), gui2::ActionManager::setRecentProjectsList(), and gui2::WelcomeView::updateNames().

Referenced by MainWindow().

Here is the call graph for this function:

◆ write_settings()

void MainWindow::write_settings ( )
private

Definition at line 113 of file mainwindow.cpp.

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 }

Referenced by closeEvent().

Member Data Documentation

◆ m_actionManager

ActionManager* gui2::MainWindow::m_actionManager {nullptr}
private

Definition at line 51 of file mainwindow.h.

Referenced by init_connections().

◆ m_barWidget

MainBarWidget* gui2::MainWindow::m_barWidget {nullptr}
private

Definition at line 56 of file mainwindow.h.

Referenced by MainWindow(), and init_components().

◆ m_importDataView

ImportDataView* gui2::MainWindow::m_importDataView {nullptr}
private

Definition at line 53 of file mainwindow.h.

Referenced by init_components().

◆ m_models

std::unique_ptr<ApplicationModels> gui2::MainWindow::m_models
private

Definition at line 50 of file mainwindow.h.

Referenced by init_components().

◆ m_settingsView

SettingsView* gui2::MainWindow::m_settingsView {nullptr}
private

Definition at line 55 of file mainwindow.h.

Referenced by init_components().

◆ m_simView

SimulationView* gui2::MainWindow::m_simView {nullptr}
private

Definition at line 54 of file mainwindow.h.

Referenced by init_components().

◆ m_welcomeView

WelcomeView* gui2::MainWindow::m_welcomeView {nullptr}
private

Definition at line 52 of file mainwindow.h.

Referenced by closeEvent(), init_components(), and init_connections().


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