BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
MainWindow Class Reference
Inheritance diagram for MainWindow:
[legend]
Collaboration diagram for MainWindow:
[legend]

Public Types

enum  ViewId {
  WELCOME , INSTRUMENT , SAMPLE , IMPORT ,
  SIMULATION , JOB , SESSIONMODEL
}
 

Public Slots

void onFocusRequest (int index)
 
void onRunSimulationShortcut ()
 
void onSessionModelViewActive (bool isActive)
 Inserts/removes developers SessionModelView on the left tabbar. More...
 
void openRecentProject ()
 

Signals

void currentViewChanged (ViewId newView)
 

Public Member Functions

 MainWindow ()
 
 ~MainWindow ()
 
QWidget * currentView () const
 
InstrumentModelinstrumentModel ()
 
JobModeljobModel ()
 
LinkInstrumentManagerlinkInstrumentManager ()
 
MaterialModelmaterialModel ()
 
ApplicationModelsmodels ()
 
QProgressBar * progressBar ()
 
ProjectManagerprojectManager ()
 
RealDataModelrealDataModel ()
 
SampleModelsampleModel ()
 
void setCurrentView (int viewId)
 
QStatusBar * statusBar ()
 
UpdateNotifierupdateNotifier ()
 

Static Public Member Functions

static MainWindowinstance ()
 Returns the one and only instance of this class. More...
 

Protected Member Functions

void closeEvent (QCloseEvent *event)
 

Private Member Functions

void addView (ViewId id, const QIcon &icon, const QString &title, const QString &tooltip, QWidget *view)
 
QToolButton * createViewSelectionButton () const
 
void initApplication ()
 
void initConnections ()
 
void initProgressBar ()
 
void initViews ()
 
void readSettings ()
 
void updateViewSelectionButtonsGeometry () const
 Recalculate the size of the view selection buttons to show complete button text. More...
 
void writeSettings ()
 

Private Attributes

ActionManagerm_actionManager
 
ApplicationModelsm_applicationModels
 
ImportDataViewm_importDataView
 
InstrumentViewm_instrumentView
 
JobViewm_jobView
 
LinkInstrumentManagerm_linkManager
 
QProgressBar * m_progressBar
 
ProjectManagerm_projectManager
 
SampleViewm_sampleView
 
SessionModelViewm_sessionModelView
 
SimulationViewm_simulationView
 
QStatusBar * m_statusBar
 
ToolTipDataBasem_toolTipDataBase
 
UpdateNotifierm_updateNotifier
 
QButtonGroup * m_viewSelectionButtons
 
QVBoxLayout * m_viewSelectionButtonsLayout
 
QStackedLayout * m_viewsStack
 
WelcomeViewm_welcomeView
 

Static Private Attributes

static MainWindows_instance = nullptr
 Holds the one and only instance of this class. More...
 

Detailed Description

Definition at line 47 of file mainwindow.h.

Member Enumeration Documentation

◆ ViewId

Enumerator
WELCOME 
INSTRUMENT 
SAMPLE 
IMPORT 
SIMULATION 
JOB 
SESSIONMODEL 

Definition at line 51 of file mainwindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( )
explicit

Definition at line 48 of file mainwindow.cpp.

49  : QMainWindow(nullptr)
50  , m_progressBar(new QProgressBar)
51  , m_viewSelectionButtons(new QButtonGroup(this))
52  , m_viewsStack(new QStackedLayout)
53  , m_viewSelectionButtonsLayout(new QVBoxLayout)
54  , m_statusBar(new QStatusBar)
57  , m_projectManager(new ProjectManager(this))
58  , m_actionManager(new ActionManager(this))
60  , m_updateNotifier(new UpdateNotifier(this))
61  , m_welcomeView(0)
62  , m_instrumentView(0)
63  , m_sampleView(0)
64  , m_importDataView(0)
65  , m_simulationView(0)
66  , m_jobView(0)
68 {
69 
70  s_instance = this;
71 
73 
74  QWidget* centralWidget = new QWidget(this);
75  QHBoxLayout* mainLayout = new QHBoxLayout(centralWidget);
76  mainLayout->setMargin(0);
77  mainLayout->setSpacing(0);
78 
79  m_viewSelectionButtonsLayout->setMargin(0);
80  m_viewSelectionButtonsLayout->setSpacing(0);
81 
82  auto fillerButton = createViewSelectionButton();
83  fillerButton->setMinimumSize(5, 5);
84  fillerButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
85  fillerButton->setEnabled(false);
86  m_viewSelectionButtonsLayout->insertWidget(-1, fillerButton);
87 
88 #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
89  connect(m_viewSelectionButtons, &QButtonGroup::idClicked, this, &MainWindow::setCurrentView);
90 #else
91  connect(m_viewSelectionButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this,
93 #endif
94 
95  m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
96 
97  QVBoxLayout* vlayout = new QVBoxLayout;
98  vlayout->setMargin(0);
99  vlayout->setSpacing(0);
100  vlayout->addLayout(m_viewsStack);
101  vlayout->addWidget(m_statusBar);
102 
103  mainLayout->addLayout(m_viewSelectionButtonsLayout);
104  mainLayout->addLayout(vlayout);
105 
106  setCentralWidget(centralWidget);
107 
108  m_statusBar->hide();
109 
110  initApplication();
111  readSettings();
112  initProgressBar();
113  initViews();
114  initConnections();
115 
116  ASSERT(m_viewSelectionButtons->button(ViewId::WELCOME) != nullptr);
117  m_viewSelectionButtons->button(ViewId::WELCOME)->setChecked(true);
118 
119  // m_applicationModels->createTestSample();
120  // m_applicationModels->createTestJob();
121  // m_applicationModels->createTestRealData();
122 }
#define ASSERT(condition)
Definition: Assert.h:31
Class to handle MainWindow's menu and corresponding actions.
Definition: actionmanager.h:28
The LinkInstrumentManager class provides communication between InstrumentModel and RealDataModel.
void setModels(InstrumentModel *instrumentModel, RealDataModel *realDataModel)
Sets models and builds initial links.
void readSettings()
Definition: mainwindow.cpp:319
SimulationView * m_simulationView
Definition: mainwindow.h:120
WelcomeView * m_welcomeView
Definition: mainwindow.h:116
SessionModelView * m_sessionModelView
Definition: mainwindow.h:122
void setCurrentView(int viewId)
Definition: mainwindow.cpp:194
QButtonGroup * m_viewSelectionButtons
Definition: mainwindow.h:104
InstrumentView * m_instrumentView
Definition: mainwindow.h:117
LinkInstrumentManager * m_linkManager
Definition: mainwindow.h:110
ProjectManager * m_projectManager
Definition: mainwindow.h:111
ActionManager * m_actionManager
Definition: mainwindow.h:112
ImportDataView * m_importDataView
Definition: mainwindow.h:119
InstrumentModel * instrumentModel()
Definition: mainwindow.cpp:139
UpdateNotifier * m_updateNotifier
Definition: mainwindow.h:114
QStackedLayout * m_viewsStack
Definition: mainwindow.h:105
void initViews()
Definition: mainwindow.cpp:281
QStatusBar * m_statusBar
Definition: mainwindow.h:107
void initProgressBar()
Definition: mainwindow.cpp:272
ApplicationModels * m_applicationModels
Definition: mainwindow.h:109
QVBoxLayout * m_viewSelectionButtonsLayout
Definition: mainwindow.h:106
QProgressBar * m_progressBar
Definition: mainwindow.h:103
void initApplication()
Definition: mainwindow.cpp:256
RealDataModel * realDataModel()
Definition: mainwindow.cpp:149
QToolButton * createViewSelectionButton() const
Definition: mainwindow.cpp:401
void initConnections()
Definition: mainwindow.cpp:342
static MainWindow * s_instance
Holds the one and only instance of this class.
Definition: mainwindow.h:125
JobView * m_jobView
Definition: mainwindow.h:121
ToolTipDataBase * m_toolTipDataBase
Definition: mainwindow.h:113
SampleView * m_sampleView
Definition: mainwindow.h:118
Handles activity related to opening/save projects.
The MaterialEditor is the main class to access materials.

References ASSERT, createViewSelectionButton(), initApplication(), initConnections(), initProgressBar(), initViews(), instrumentModel(), m_linkManager, m_statusBar, m_viewSelectionButtons, m_viewSelectionButtonsLayout, m_viewsStack, readSettings(), realDataModel(), s_instance, setCurrentView(), and LinkInstrumentManager::setModels().

Here is the call graph for this function:

◆ ~MainWindow()

MainWindow::~MainWindow ( )

Definition at line 124 of file mainwindow.cpp.

125 {
126  s_instance = nullptr;
127 }

References s_instance.

Member Function Documentation

◆ addView()

void MainWindow::addView ( ViewId  id,
const QIcon &  icon,
const QString &  title,
const QString &  tooltip,
QWidget *  view 
)
private

Definition at line 347 of file mainwindow.cpp.

349 {
350  QToolButton* btn = createViewSelectionButton();
351  m_viewSelectionButtonsLayout->insertWidget(id, btn);
352 
353  btn->setText(title);
354  btn->setToolTip(tooltip);
355  btn->setIcon(icon);
356  m_viewSelectionButtons->addButton(btn, id);
357 
359 
360  m_viewsStack->insertWidget(id, view);
361 }
void updateViewSelectionButtonsGeometry() const
Recalculate the size of the view selection buttons to show complete button text.
Definition: mainwindow.cpp:363

References createViewSelectionButton(), m_viewSelectionButtons, m_viewSelectionButtonsLayout, m_viewsStack, and updateViewSelectionButtonsGeometry().

Referenced by initViews().

Here is the call graph for this function:

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent *  event)
protected

Definition at line 239 of file mainwindow.cpp.

240 {
241  if (jobModel()->hasUnfinishedJobs()) {
242  QMessageBox::warning(this, "Can't quit the application.",
243  "Can't quit the application while jobs are running.\n"
244  "Cancel running jobs or wait until they are completed.");
245  event->ignore();
246  return;
247  }
249  writeSettings();
250  event->accept();
251  } else {
252  event->ignore();
253  }
254 }
void writeSettings()
Definition: mainwindow.cpp:331
JobModel * jobModel()
Definition: mainwindow.cpp:154
bool closeCurrentProject()
Processes close current project request.
void warning(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
Definition: GUIHelpers.cpp:74

References ProjectManager::closeCurrentProject(), jobModel(), m_projectManager, GUIHelpers::warning(), and writeSettings().

Here is the call graph for this function:

◆ createViewSelectionButton()

QToolButton * MainWindow::createViewSelectionButton ( ) const
private

Definition at line 401 of file mainwindow.cpp.

402 {
403 
404  const QString viewSelectionButtonStyle =
405  "QToolButton { border: none; color: white; background-color: qlineargradient(x1: 0, "
406  "y1: 0, x2: 1, y2: 0, stop : 0 #153b4c, stop : 1 #347a9c);} "
407  "QToolButton:pressed { "
408  " color: black; background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 "
409  "#97a8b0, stop: "
410  "1 #dae7ed); }"
411  "QToolButton:hover { "
412  " color: white; background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 "
413  "#254b5c, stop: 1 #448aac); }"
414  "QToolButton:checked { "
415  " color: black; background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 "
416  "#97a8b0, stop: "
417  "1 #dae7ed);"
418  "} ";
419 
420  QToolButton* btn = new QToolButton;
421  btn->setCheckable(true);
422  btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
423  btn->setStyleSheet(viewSelectionButtonStyle);
424  return btn;
425 }

Referenced by MainWindow(), and addView().

◆ currentView()

QWidget * MainWindow::currentView ( ) const

Definition at line 189 of file mainwindow.cpp.

190 {
191  return m_viewsStack->currentWidget();
192 }

References m_viewsStack.

Referenced by ActionManager::onAboutToShowViewMenu().

◆ currentViewChanged

void MainWindow::currentViewChanged ( ViewId  newView)
signal

◆ initApplication()

void MainWindow::initApplication ( )
private

Definition at line 256 of file mainwindow.cpp.

257 {
258  QCoreApplication::setApplicationName(QLatin1String(Constants::APPLICATION_NAME));
259  QCoreApplication::setApplicationVersion(GUIHelpers::getBornAgainVersionString());
260  QCoreApplication::setOrganizationName(QLatin1String(Constants::APPLICATION_NAME));
261 
263  QApplication::setWindowIcon(QIcon(":/images/BornAgain.ico"));
264 
265  setDockNestingEnabled(true);
266  setAcceptDrops(true);
267 
268  setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
269  setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
270 }
static bool isMacHost()
Definition: hostosinfo.h:69
const char APPLICATION_NAME[]
QString getBornAgainVersionString()
Definition: GUIHelpers.cpp:130

References Constants::APPLICATION_NAME, GUIHelpers::getBornAgainVersionString(), and GUI_OS_Utils::HostOsInfo::isMacHost().

Referenced by MainWindow().

Here is the call graph for this function:

◆ initConnections()

void MainWindow::initConnections ( )
private

Definition at line 342 of file mainwindow.cpp.

343 {
345 }
void focusRequest(int)
void onFocusRequest(int index)
Definition: mainwindow.cpp:202

References JobView::focusRequest(), m_jobView, and onFocusRequest().

Referenced by MainWindow().

Here is the call graph for this function:

◆ initProgressBar()

void MainWindow::initProgressBar ( )
private

Definition at line 272 of file mainwindow.cpp.

273 {
274  m_progressBar->hide();
275  m_progressBar->setTextVisible(false);
276  m_progressBar->setFixedHeight(QApplication::fontMetrics().boundingRect("M").height());
277  m_progressBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
279 }

References m_progressBar, and m_viewSelectionButtonsLayout.

Referenced by MainWindow().

◆ initViews()

void MainWindow::initViews ( )
private

Definition at line 281 of file mainwindow.cpp.

282 {
283  m_welcomeView = new WelcomeView(this);
284  m_instrumentView = new InstrumentView(this);
285  m_sampleView = new SampleView(this);
286  m_importDataView = new ImportDataView(this);
287  m_simulationView = new SimulationView(this);
288  m_jobView = new JobView(this);
290 
291  addView(ViewId::WELCOME, QIcon(":/images/main_welcomeview.svg"), "Welcome",
292  "Switch to Welcome View", m_welcomeView);
293 
294  addView(ViewId::INSTRUMENT, QIcon(":/images/main_instrumentview.svg"), "Instrument",
295  "Define the beam and the detector", m_instrumentView);
296 
297  addView(ViewId::SAMPLE, QIcon(":/images/main_sampleview.svg"), "Sample", "Build the sample",
298  m_sampleView);
299 
300  addView(ViewId::IMPORT, QIcon(":/images/main_importview.svg"), "Data",
301  "Import intensity data to fit", m_importDataView);
302 
303  addView(ViewId::SIMULATION, QIcon(":/images/main_simulationview.svg"), "Simulation",
304  "Run simulation", m_simulationView);
305 
306  addView(ViewId::JOB, QIcon(":/images/main_jobview.svg"), "Jobs",
307  "Switch to see job results, tune parameters real time,\nfit the data", m_jobView);
308 
309  addView(ViewId::SESSIONMODEL, QIcon(":/images/main_sessionmodel.svg"), "Models", "",
311 
312  // enabling technical view
313  QSettings settings;
314  settings.beginGroup(Constants::S_SESSIONMODELVIEW);
315  onSessionModelViewActive(settings.value(Constants::S_VIEWISACTIVE, false).toBool());
316  settings.endGroup();
317 }
The ImportDataView class is a main view for importing experimental data.
The JobView class is a main view to show list of jobs, job results and widgets for real time and fitt...
Definition: JobView.h:35
void onSessionModelViewActive(bool isActive)
Inserts/removes developers SessionModelView on the left tabbar.
Definition: mainwindow.cpp:225
void addView(ViewId id, const QIcon &icon, const QString &title, const QString &tooltip, QWidget *view)
Definition: mainwindow.cpp:347
The SessionModelView is a technical view which shows the content all current application models.
const char S_SESSIONMODELVIEW[]
const char S_VIEWISACTIVE[]

References addView(), m_importDataView, m_instrumentView, m_jobView, m_sampleView, m_sessionModelView, m_simulationView, m_welcomeView, onSessionModelViewActive(), Constants::S_SESSIONMODELVIEW, and Constants::S_VIEWISACTIVE.

Referenced by MainWindow().

Here is the call graph for this function:

◆ instance()

◆ instrumentModel()

InstrumentModel * MainWindow::instrumentModel ( )

Definition at line 139 of file mainwindow.cpp.

140 {
141  return models()->instrumentModel();
142 }
InstrumentModel * instrumentModel()
ApplicationModels * models()
Definition: mainwindow.cpp:159

References ApplicationModels::instrumentModel(), and models().

Referenced by MainWindow(), and SessionModelView::modelsForTabs().

Here is the call graph for this function:

◆ jobModel()

JobModel * MainWindow::jobModel ( )

Definition at line 154 of file mainwindow.cpp.

155 {
156  return models()->jobModel();
157 }

References ApplicationModels::jobModel(), and models().

Referenced by JobProgressAssistant::JobProgressAssistant(), closeEvent(), JobView::connectJobRelated(), JobView::createSubWindows(), and SessionModelView::modelsForTabs().

Here is the call graph for this function:

◆ linkInstrumentManager()

LinkInstrumentManager * MainWindow::linkInstrumentManager ( )

Definition at line 164 of file mainwindow.cpp.

165 {
166  return m_linkManager;
167 }

References m_linkManager.

◆ materialModel()

MaterialModel * MainWindow::materialModel ( )

Definition at line 134 of file mainwindow.cpp.

135 {
136  return models()->materialModel();
137 }
MaterialModel * materialModel()

References ApplicationModels::materialModel(), and models().

Referenced by SessionModelView::modelsForTabs(), PyImportAssistant::populateModels(), and TestView::test_MaterialEditor().

Here is the call graph for this function:

◆ models()

◆ onFocusRequest

void MainWindow::onFocusRequest ( int  index)
slot

Definition at line 202 of file mainwindow.cpp.

203 {
204  m_viewSelectionButtons->button(index)->click();
205 }

References m_viewSelectionButtons.

Referenced by initConnections().

◆ onRunSimulationShortcut

void MainWindow::onRunSimulationShortcut ( )
slot

Definition at line 215 of file mainwindow.cpp.

216 {
217  // This clearFocus is needed for the propagation of the current editor value,
218  // since the runSimulation method will only change focus after finishing the simulation
219  if (auto widget = QApplication::focusWidget())
220  widget->clearFocus();
222 }
void onRunSimulationShortcut()

References m_simulationView, and SimulationView::onRunSimulationShortcut().

Referenced by ActionManager::createGlobalShortcuts().

Here is the call graph for this function:

◆ onSessionModelViewActive

void MainWindow::onSessionModelViewActive ( bool  isActive)
slot

Inserts/removes developers SessionModelView on the left tabbar.

Definition at line 225 of file mainwindow.cpp.

226 {
227  auto btn = m_viewSelectionButtons->button(ViewId::SESSIONMODEL);
228  ASSERT(btn != nullptr);
229  if (btn == nullptr)
230  return;
231 
232  if (!isActive && m_viewsStack->currentIndex() == SESSIONMODEL)
233  m_viewSelectionButtons->buttons().first()->click();
234 
235  btn->setEnabled(isActive);
236  btn->setVisible(isActive);
237 }

References ASSERT, m_viewSelectionButtons, m_viewsStack, and SESSIONMODEL.

Referenced by initViews(), and ActionManager::setSessionModelViewActive().

◆ openRecentProject

void MainWindow::openRecentProject ( )
slot

Definition at line 207 of file mainwindow.cpp.

208 {
209  if (const QAction* action = qobject_cast<const QAction*>(sender())) {
210  QString file = action->data().value<QString>();
212  }
213 }
void openProject(QString fileName="")
Opens existing project. If fileName is empty, will popup file selection dialog.

References m_projectManager, and ProjectManager::openProject().

Referenced by ActionManager::onAboutToShowFileMenu().

Here is the call graph for this function:

◆ progressBar()

QProgressBar * MainWindow::progressBar ( )

Definition at line 169 of file mainwindow.cpp.

170 {
171  return m_progressBar;
172 }

References m_progressBar.

Referenced by JobProgressAssistant::onGlobalProgress().

◆ projectManager()

◆ readSettings()

void MainWindow::readSettings ( )
private

Definition at line 319 of file mainwindow.cpp.

320 {
321  QSettings settings;
322  if (settings.childGroups().contains(Constants::S_MAINWINDOW)) {
323  settings.beginGroup(Constants::S_MAINWINDOW);
324  resize(settings.value(Constants::S_WINDOWSIZE, QSize(400, 400)).toSize());
325  move(settings.value(Constants::S_WINDOWPOSITION, QPoint(200, 200)).toPoint());
326  settings.endGroup();
327  }
329 }
void readSettings()
Reads settings of ProjectManager from global settings.
const char S_WINDOWPOSITION[]
const char S_WINDOWSIZE[]
const char S_MAINWINDOW[]

References m_projectManager, ProjectManager::readSettings(), Constants::S_MAINWINDOW, Constants::S_WINDOWPOSITION, and Constants::S_WINDOWSIZE.

Referenced by MainWindow().

Here is the call graph for this function:

◆ realDataModel()

RealDataModel * MainWindow::realDataModel ( )

Definition at line 149 of file mainwindow.cpp.

150 {
151  return models()->realDataModel();
152 }
RealDataModel * realDataModel()

References models(), and ApplicationModels::realDataModel().

Referenced by ImportDataView::ImportDataView(), MainWindow(), and SessionModelView::modelsForTabs().

Here is the call graph for this function:

◆ sampleModel()

SampleModel * MainWindow::sampleModel ( )

Definition at line 144 of file mainwindow.cpp.

145 {
146  return models()->sampleModel();
147 }
SampleModel * sampleModel()

References models(), and ApplicationModels::sampleModel().

Referenced by SessionModelView::modelsForTabs(), PyImportAssistant::populateModels(), and TestView::test_ba3d().

Here is the call graph for this function:

◆ setCurrentView()

void MainWindow::setCurrentView ( int  viewId)

Definition at line 194 of file mainwindow.cpp.

195 {
196  if (m_viewsStack->currentIndex() != viewId) {
197  m_viewsStack->setCurrentIndex(viewId);
198  emit currentViewChanged(ViewId(viewId));
199  }
200 }
void currentViewChanged(ViewId newView)

References currentViewChanged(), and m_viewsStack.

Referenced by MainWindow().

◆ statusBar()

QStatusBar * MainWindow::statusBar ( )

Definition at line 174 of file mainwindow.cpp.

175 {
176  return m_statusBar;
177 }

References m_statusBar.

◆ updateNotifier()

UpdateNotifier * MainWindow::updateNotifier ( )

Definition at line 184 of file mainwindow.cpp.

185 {
186  return m_updateNotifier;
187 }

References m_updateNotifier.

Referenced by ActionManager::toggleCheckForUpdates().

◆ updateViewSelectionButtonsGeometry()

void MainWindow::updateViewSelectionButtonsGeometry ( ) const
private

Recalculate the size of the view selection buttons to show complete button text.

Definition at line 363 of file mainwindow.cpp.

364 {
365  if (m_viewSelectionButtons->buttons().isEmpty())
366  return;
367 
368  const QFontMetrics fontMetrics = m_viewSelectionButtons->buttons().first()->fontMetrics();
369 
370  // Find the maximum text extents
371  int maxTextWidth = 0;
372  int maxTextHeight = 0;
373  for (auto b : m_viewSelectionButtons->buttons()) {
374  const auto r = fontMetrics.boundingRect(b->text());
375  maxTextWidth = std::max(maxTextWidth, r.width());
376  maxTextHeight = std::max(maxTextHeight, r.height());
377  }
378 
379  // calculate the button extent by width (width == height!). Ensure an extent of 70 for normal
380  // DPI devices (legacy value)
381  const int margin = fontMetrics.boundingRect("M").width();
382  const int buttonExtent = std::max(70, maxTextWidth + 2 * margin);
383 
384  // calculate the icon extent by height (width == height!)
385  const int iconExtent = buttonExtent - margin - maxTextHeight;
386 
387  // set new values in all buttons
388  for (auto b : m_viewSelectionButtons->buttons()) {
389  b->setFixedSize(buttonExtent, buttonExtent);
390  b->setIconSize({iconExtent, iconExtent});
391  }
392  // set fixed width in filler and progress bar
393  auto filler = m_viewSelectionButtonsLayout->itemAt(m_viewSelectionButtons->buttons().size());
394  if (filler)
395  if (auto fillerBtn = dynamic_cast<QToolButton*>(filler->widget()); fillerBtn)
396  fillerBtn->setFixedWidth(buttonExtent);
397 
398  m_progressBar->setFixedWidth(buttonExtent);
399 }

References m_progressBar, m_viewSelectionButtons, and m_viewSelectionButtonsLayout.

Referenced by addView().

◆ writeSettings()

void MainWindow::writeSettings ( )
private

Definition at line 331 of file mainwindow.cpp.

332 {
333  QSettings settings;
334  settings.beginGroup(Constants::S_MAINWINDOW);
335  settings.setValue(Constants::S_WINDOWSIZE, size());
336  settings.setValue(Constants::S_WINDOWPOSITION, pos());
337  settings.endGroup();
339  settings.sync();
340 }
void writeSettings()
Saves settings of ProjectManager in global settings.

References m_projectManager, Constants::S_MAINWINDOW, Constants::S_WINDOWPOSITION, Constants::S_WINDOWSIZE, and ProjectManager::writeSettings().

Referenced by closeEvent().

Here is the call graph for this function:

Member Data Documentation

◆ m_actionManager

ActionManager* MainWindow::m_actionManager
private

Definition at line 112 of file mainwindow.h.

◆ m_applicationModels

ApplicationModels* MainWindow::m_applicationModels
private

Definition at line 109 of file mainwindow.h.

Referenced by models().

◆ m_importDataView

ImportDataView* MainWindow::m_importDataView
private

Definition at line 119 of file mainwindow.h.

Referenced by initViews().

◆ m_instrumentView

InstrumentView* MainWindow::m_instrumentView
private

Definition at line 117 of file mainwindow.h.

Referenced by initViews().

◆ m_jobView

JobView* MainWindow::m_jobView
private

Definition at line 121 of file mainwindow.h.

Referenced by initConnections(), and initViews().

◆ m_linkManager

LinkInstrumentManager* MainWindow::m_linkManager
private

Definition at line 110 of file mainwindow.h.

Referenced by MainWindow(), and linkInstrumentManager().

◆ m_progressBar

QProgressBar* MainWindow::m_progressBar
private

Definition at line 103 of file mainwindow.h.

Referenced by initProgressBar(), progressBar(), and updateViewSelectionButtonsGeometry().

◆ m_projectManager

ProjectManager* MainWindow::m_projectManager
private

◆ m_sampleView

SampleView* MainWindow::m_sampleView
private

Definition at line 118 of file mainwindow.h.

Referenced by initViews().

◆ m_sessionModelView

SessionModelView* MainWindow::m_sessionModelView
private

Definition at line 122 of file mainwindow.h.

Referenced by initViews().

◆ m_simulationView

SimulationView* MainWindow::m_simulationView
private

Definition at line 120 of file mainwindow.h.

Referenced by initViews(), and onRunSimulationShortcut().

◆ m_statusBar

QStatusBar* MainWindow::m_statusBar
private

Definition at line 107 of file mainwindow.h.

Referenced by MainWindow(), and statusBar().

◆ m_toolTipDataBase

ToolTipDataBase* MainWindow::m_toolTipDataBase
private

Definition at line 113 of file mainwindow.h.

◆ m_updateNotifier

UpdateNotifier* MainWindow::m_updateNotifier
private

Definition at line 114 of file mainwindow.h.

Referenced by updateNotifier().

◆ m_viewSelectionButtons

QButtonGroup* MainWindow::m_viewSelectionButtons
private

◆ m_viewSelectionButtonsLayout

QVBoxLayout* MainWindow::m_viewSelectionButtonsLayout
private

◆ m_viewsStack

QStackedLayout* MainWindow::m_viewsStack
private

◆ m_welcomeView

WelcomeView* MainWindow::m_welcomeView
private

Definition at line 116 of file mainwindow.h.

Referenced by initViews().

◆ s_instance

MainWindow * MainWindow::s_instance = nullptr
staticprivate

Holds the one and only instance of this class.

Definition at line 125 of file mainwindow.h.

Referenced by MainWindow(), ~MainWindow(), and instance().


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