diff --git a/GUI/Views/InstrumentWidgets/InstrumentSelectorWidget.h b/GUI/Views/InstrumentWidgets/InstrumentSelectorWidget.h index b31d3121d95c01ced066b11dd7643b03d831b9e4..b0ddfacda0db343a88973633195a4c1f20eee8c1 100644 --- a/GUI/Views/InstrumentWidgets/InstrumentSelectorWidget.h +++ b/GUI/Views/InstrumentWidgets/InstrumentSelectorWidget.h @@ -48,7 +48,7 @@ private: QMap<QString, int> mapOfNames(); template <class Instrument> void newInstrument(); -private: +public: QAction* m_action_new_gisas; QAction* m_action_new_offspecular; QAction* m_action_new_specular; diff --git a/GUI/Views/InstrumentWidgets/InstrumentView.cpp b/GUI/Views/InstrumentWidgets/InstrumentView.cpp index 8f4bb31892009575e9f130d0f3369309df5fe3eb..f3f2bbede063fab1612938f4ade4628e75f56ade 100644 --- a/GUI/Views/InstrumentWidgets/InstrumentView.cpp +++ b/GUI/Views/InstrumentWidgets/InstrumentView.cpp @@ -22,7 +22,7 @@ #include <QBoxLayout> InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) - : QWidget(parent), m_instrumentEditor(new InstrumentEditor) + : QWidget(parent), m_instrumentEditor(new InstrumentEditor), m_document(document) { auto horizontalLayout = new QHBoxLayout; m_instrumentSelector = new InstrumentSelectorWidget(document->instrumentModel(), this); @@ -40,8 +40,13 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) mainLayout->addLayout(horizontalLayout); setLayout(mainLayout); + updateFunctionalityNarrowing(); + connect(m_instrumentSelector, &InstrumentSelectorWidget::selectionChanged, this, &InstrumentView::onItemSelectionChanged); + + connect(m_document, &ProjectDocument::modified, this, + &InstrumentView::updateFunctionalityNarrowing); } void InstrumentView::onItemSelectionChanged(SessionItem* instrumentItem) @@ -53,3 +58,16 @@ void InstrumentView::showEvent(QShowEvent*) { m_instrumentSelector->updateSelection(); } + +void InstrumentView::updateFunctionalityNarrowing() +{ + const auto f = m_document->functionalities(); + + m_instrumentSelector->m_action_new_gisas->setVisible(f.testFlag(ProjectDocument::Gisas)); + m_instrumentSelector->m_action_new_offspecular->setVisible( + f.testFlag(ProjectDocument::OffSpecular)); + m_instrumentSelector->m_action_new_specular->setVisible(f.testFlag(ProjectDocument::Specular)); + m_instrumentSelector->m_action_new_depthprobe->setVisible( + f.testFlag(ProjectDocument::DepthProbe)); + m_instrumentSelector->m_action_copy->setVisible(!m_document->singleInstrumentMode()); +} diff --git a/GUI/Views/InstrumentWidgets/InstrumentView.h b/GUI/Views/InstrumentWidgets/InstrumentView.h index 969029a7e948b6bee568bb6e381c18905ffb93d0..2d3917f10409081b128e2907601f7268d45e9e86 100644 --- a/GUI/Views/InstrumentWidgets/InstrumentView.h +++ b/GUI/Views/InstrumentWidgets/InstrumentView.h @@ -37,9 +37,15 @@ private slots: protected: void showEvent(QShowEvent*); +private: + //! Show/hide UI elements according to settings in current project + void updateFunctionalityNarrowing(); + + private: InstrumentSelectorWidget* m_instrumentSelector; InstrumentEditor* m_instrumentEditor; + ProjectDocument* m_document; }; #endif // BORNAGAIN_GUI_VIEWS_INSTRUMENTWIDGETS_INSTRUMENTVIEW_H