Skip to content
Snippets Groups Projects
Commit bbe649c2 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

implement functionality narrowing in InstrumentView

parent 216aa0b2
No related branches found
No related tags found
1 merge request!297Add project settings view
Pipeline #44115 passed
...@@ -48,7 +48,7 @@ private: ...@@ -48,7 +48,7 @@ private:
QMap<QString, int> mapOfNames(); QMap<QString, int> mapOfNames();
template <class Instrument> void newInstrument(); template <class Instrument> void newInstrument();
private: public:
QAction* m_action_new_gisas; QAction* m_action_new_gisas;
QAction* m_action_new_offspecular; QAction* m_action_new_offspecular;
QAction* m_action_new_specular; QAction* m_action_new_specular;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <QBoxLayout> #include <QBoxLayout>
InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) 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; auto horizontalLayout = new QHBoxLayout;
m_instrumentSelector = new InstrumentSelectorWidget(document->instrumentModel(), this); m_instrumentSelector = new InstrumentSelectorWidget(document->instrumentModel(), this);
...@@ -40,8 +40,13 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) ...@@ -40,8 +40,13 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document)
mainLayout->addLayout(horizontalLayout); mainLayout->addLayout(horizontalLayout);
setLayout(mainLayout); setLayout(mainLayout);
updateFunctionalityNarrowing();
connect(m_instrumentSelector, &InstrumentSelectorWidget::selectionChanged, this, connect(m_instrumentSelector, &InstrumentSelectorWidget::selectionChanged, this,
&InstrumentView::onItemSelectionChanged); &InstrumentView::onItemSelectionChanged);
connect(m_document, &ProjectDocument::modified, this,
&InstrumentView::updateFunctionalityNarrowing);
} }
void InstrumentView::onItemSelectionChanged(SessionItem* instrumentItem) void InstrumentView::onItemSelectionChanged(SessionItem* instrumentItem)
...@@ -53,3 +58,16 @@ void InstrumentView::showEvent(QShowEvent*) ...@@ -53,3 +58,16 @@ void InstrumentView::showEvent(QShowEvent*)
{ {
m_instrumentSelector->updateSelection(); 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());
}
...@@ -37,9 +37,15 @@ private slots: ...@@ -37,9 +37,15 @@ private slots:
protected: protected:
void showEvent(QShowEvent*); void showEvent(QShowEvent*);
private:
//! Show/hide UI elements according to settings in current project
void updateFunctionalityNarrowing();
private: private:
InstrumentSelectorWidget* m_instrumentSelector; InstrumentSelectorWidget* m_instrumentSelector;
InstrumentEditor* m_instrumentEditor; InstrumentEditor* m_instrumentEditor;
ProjectDocument* m_document;
}; };
#endif // BORNAGAIN_GUI_VIEWS_INSTRUMENTWIDGETS_INSTRUMENTVIEW_H #endif // BORNAGAIN_GUI_VIEWS_INSTRUMENTWIDGETS_INSTRUMENTVIEW_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment