diff --git a/GUI/View/Main/CentralWidget.cpp b/GUI/View/Main/CentralWidget.cpp index c7e3b40611f6d44d76561f3d2d4d2b2d2adb83ce..a323f7c44839a71ff88edfcb9f2c965308552b7c 100644 --- a/GUI/View/Main/CentralWidget.cpp +++ b/GUI/View/Main/CentralWidget.cpp @@ -63,43 +63,12 @@ CentralWidget::CentralWidget() layout->addLayout(m_view_selection_buttons_layout); layout->addLayout(vlayout); - initProgressBar(); - initButtons(); - initViews(); -} - -CentralWidget::~CentralWidget() = default; - -QWidget* CentralWidget::currentView() const -{ - return m_views_stack->currentWidget(); -} - -void CentralWidget::setCurrentView(int viewId) -{ - if (auto* btn = m_view_selection_buttons->button(viewId); btn != nullptr) - btn->click(); -} - -void CentralWidget::raiseView(int viewId) -{ - if (m_views_stack->currentIndex() != viewId) { - m_views_stack->setCurrentIndex(viewId); - emit currentViewChanged(GUI::ID::ViewId(viewId)); - } -} - -void CentralWidget::initProgressBar() -{ m_progress_bar->hide(); m_progress_bar->setTextVisible(false); m_progress_bar->setFixedHeight(QApplication::fontMetrics().boundingRect("M").height()); m_progress_bar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); m_view_selection_buttons_layout->addWidget(m_progress_bar); -} -void CentralWidget::initButtons() -{ addButton(GUI::ID::ViewId::Datafile, QIcon(":/images/view/data.svg"), "Data", "Import intensity data to fit"); addButton(GUI::ID::ViewId::Instrument, QIcon(":/images/view/instrument.svg"), "Instrument", @@ -113,24 +82,6 @@ void CentralWidget::initButtons() for (auto* button : m_view_selection_buttons->buttons()) button->setEnabled(false); -} - -void CentralWidget::updateViews(bool open) -{ - if (!open) - return; - for (auto* button : m_view_selection_buttons->buttons()) - button->setEnabled(true); - auto* filler = - m_view_selection_buttons_layout->itemAt(m_view_selection_buttons->buttons().size()); - if (filler) - if (auto* fillerBtn = dynamic_cast<QToolButton*>(filler->widget()); fillerBtn) - fillerBtn->setEnabled(true); -} - -void CentralWidget::initViews() -{ - ASSERT(gDoc); m_instrument_view = new InstrumentView; m_sample_view = new SampleView; @@ -150,6 +101,40 @@ void CentralWidget::initViews() m_job_view->onJobSelectionChanged(); } +CentralWidget::~CentralWidget() = default; + +QWidget* CentralWidget::currentView() const +{ + return m_views_stack->currentWidget(); +} + +void CentralWidget::setCurrentView(int viewId) +{ + if (auto* btn = m_view_selection_buttons->button(viewId); btn != nullptr) + btn->click(); +} + +void CentralWidget::raiseView(int viewId) +{ + if (m_views_stack->currentIndex() != viewId) { + m_views_stack->setCurrentIndex(viewId); + emit currentViewChanged(GUI::ID::ViewId(viewId)); + } +} + +void CentralWidget::updateViews(bool open) +{ + if (!open) + return; + for (auto* button : m_view_selection_buttons->buttons()) + button->setEnabled(true); + auto* filler = + m_view_selection_buttons_layout->itemAt(m_view_selection_buttons->buttons().size()); + if (filler) + if (auto* fillerBtn = dynamic_cast<QToolButton*>(filler->widget()); fillerBtn) + fillerBtn->setEnabled(true); +} + void CentralWidget::addButton(GUI::ID::ViewId id, const QIcon& icon, const QString& title, const QString& tooltip) { diff --git a/GUI/View/Main/CentralWidget.h b/GUI/View/Main/CentralWidget.h index cfd71b61956d06654728743877479df2336b4638..84d02cbfdb88a1aad7e983656322cfe6fdb96c04 100644 --- a/GUI/View/Main/CentralWidget.h +++ b/GUI/View/Main/CentralWidget.h @@ -49,10 +49,6 @@ signals: void currentViewChanged(GUI::ID::ViewId newView); private: - void initProgressBar(); - void initButtons(); - void initViews(); - void addButton(GUI::ID::ViewId id, const QIcon& icon, const QString& title, const QString& tooltip); QToolButton* createViewSelectionButton() const;