diff --git a/GUI/View/Views/InstrumentView.cpp b/GUI/View/Views/InstrumentView.cpp index 7152dd0e57ca92e86aa17a32940393e71250efcc..fd8e0cddf00696e610e18ca406293b32e83cb80d 100644 --- a/GUI/View/Views/InstrumentView.cpp +++ b/GUI/View/Views/InstrumentView.cpp @@ -46,6 +46,39 @@ InstrumentView::InstrumentView() layout->addWidget(toolbar); toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + setToolbarActions(toolbar); + + //... Everything below top toolbar + + auto* hLayout = new QHBoxLayout; + layout->addLayout(hLayout); + + // Left margin: instrument list + + hLayout->addWidget(m_qlistview); + m_qlistview->setMinimumWidth(200); + + // Large widget: current instrument + + hLayout->addWidget(m_scroll_area); + m_scroll_area->setWidgetResizable(true); + m_scroll_area->setMinimumWidth(1000); + m_scroll_area->setWidget(new QWidget(m_scroll_area)); // initial state: blank widget + + hLayout->addStretch(1); + + //... Finalize + + connect(gDoc->instruments(), &InstrumentsSet::setChanged, this, + &InstrumentView::createWidgetsForCurrentInstrument); + + updateActions(); +} + +void InstrumentView::setToolbarActions(QToolBar* toolbar) +{ + //... New-instrument actions + auto new_action = [this, toolbar](const QString& name, const QString& description) { QAction* a = new QAction("New " + name, this); a->setIcon(QIcon(":/images/shape-square-plus.svg")); @@ -66,6 +99,8 @@ InstrumentView::InstrumentView() connect(new_action("depthprobe", "depth intensity profile"), &QAction::triggered, [this] { m_qlistmodel->pushInstrument(new DepthprobeInstrumentItem); }); + //... Copy and remove actions + m_rm_action = ActionFactory::createRemoveAction("instrument", this); toolbar->addAction(m_rm_action); connect(m_rm_action, &QAction::triggered, m_qlistmodel, &InstrumentsQModel::removeInstrument); @@ -74,6 +109,8 @@ InstrumentView::InstrumentView() toolbar->addAction(m_cp_action); connect(m_cp_action, &QAction::triggered, m_qlistmodel, &InstrumentsQModel::copyInstrument); + //... Save and load actions + m_save_action = new QAction("Store in library", this); m_save_action->setIcon(QIcon(":/images/library.svg")); m_save_action->setToolTip("Store instrument in library"); @@ -88,32 +125,6 @@ InstrumentView::InstrumentView() connect(m_load_action, &QAction::triggered, [this] { m_qlistmodel->pushInstrument(RW::loadComponentFromXML<InstrumentItem>("instrument")); }); - - //... Everything below top toolbar - - auto* hLayout = new QHBoxLayout; - layout->addLayout(hLayout); - - // Left margin: instrument list - - hLayout->addWidget(m_qlistview); - m_qlistview->setMinimumWidth(200); - - // Large widget: current instrument - - hLayout->addWidget(m_scroll_area); - m_scroll_area->setWidgetResizable(true); - m_scroll_area->setMinimumWidth(1000); - m_scroll_area->setWidget(new QWidget(m_scroll_area)); // initial state: blank widget - - hLayout->addStretch(1); - - //... Finalize - - connect(gDoc->instruments(), &InstrumentsSet::setChanged, this, - &InstrumentView::createWidgetsForCurrentInstrument); - - updateActions(); } void InstrumentView::createWidgetsForCurrentInstrument() diff --git a/GUI/View/Views/InstrumentView.h b/GUI/View/Views/InstrumentView.h index 339dfe0c7c22750508ea879f40d8efa49622ec87..11f3a6e375201569e2369947e91c18343af350c9 100644 --- a/GUI/View/Views/InstrumentView.h +++ b/GUI/View/Views/InstrumentView.h @@ -23,6 +23,7 @@ class InstrumentItem; class InstrumentsQListView; class InstrumentsQModel; +class QToolBar; class InstrumentView : public QWidget { Q_OBJECT @@ -33,6 +34,7 @@ private slots: void updateActions(); private: + void setToolbarActions(QToolBar* toolbar); void createWidgetsForCurrentInstrument(); InstrumentsQModel* m_qlistmodel;