From c31cadca04d480239556a83e459bb8f07b3c6cc5 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Mon, 26 Feb 2024 08:20:05 +0100
Subject: [PATCH] new... actions made local

---
 GUI/View/Setup/FrameActions.cpp   | 16 --------------
 GUI/View/Setup/FrameActions.h     |  4 ----
 GUI/View/Views/InstrumentView.cpp | 36 +++++++++++++++++--------------
 3 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/GUI/View/Setup/FrameActions.cpp b/GUI/View/Setup/FrameActions.cpp
index a08225d2ab7..36a35eea151 100644
--- a/GUI/View/Setup/FrameActions.cpp
+++ b/GUI/View/Setup/FrameActions.cpp
@@ -76,22 +76,6 @@ FrameActions::FrameActions()
     cycle_data2d_edit_mode->setIcon(QIcon(":/images/sprocket3.svg"));
     cycle_data2d_edit_mode->setToolTip("Cycle data 2d edit mode: Data, Mask, Projection");
 
-    new_gisas_instrument = new QAction("New GISAS");
-    new_gisas_instrument->setIcon(QIcon(":/images/shape-square-plus.svg"));
-    new_gisas_instrument->setToolTip("Add new GISAS instrument with default settings");
-
-    new_offspec_instrument = new QAction("New off-specular");
-    new_offspec_instrument->setIcon(QIcon(":/images/shape-square-plus.svg"));
-    new_offspec_instrument->setToolTip("Add new off-specular instrument with default settings");
-
-    new_specular_instrument = new QAction("New specular");
-    new_specular_instrument->setIcon(QIcon(":/images/shape-square-plus.svg"));
-    new_specular_instrument->setToolTip("Add new specular instrument with default settings");
-
-    new_depthprobe_instrument = new QAction("New depth probe");
-    new_depthprobe_instrument->setIcon(QIcon(":/images/shape-square-plus.svg"));
-    new_depthprobe_instrument->setToolTip("Add new depth probe instrument with default settings");
-
     remove_instrument = ActionFactory::createRemoveAction("instrument");
     copy_instrument = ActionFactory::createCopyAction("instrument");
 
diff --git a/GUI/View/Setup/FrameActions.h b/GUI/View/Setup/FrameActions.h
index e2cf29951fb..8b738a19960 100644
--- a/GUI/View/Setup/FrameActions.h
+++ b/GUI/View/Setup/FrameActions.h
@@ -46,10 +46,6 @@ public:
 
     QAction* cycle_data2d_edit_mode;
 
-    QAction* new_gisas_instrument;
-    QAction* new_offspec_instrument;
-    QAction* new_specular_instrument;
-    QAction* new_depthprobe_instrument;
     QAction* remove_instrument;
     QAction* copy_instrument;
     QAction* store_in_library_instrument;
diff --git a/GUI/View/Views/InstrumentView.cpp b/GUI/View/Views/InstrumentView.cpp
index 0ea19abff94..7804888a827 100644
--- a/GUI/View/Views/InstrumentView.cpp
+++ b/GUI/View/Views/InstrumentView.cpp
@@ -45,10 +45,26 @@ InstrumentView::InstrumentView()
     layout->addWidget(toolbar);
     toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
 
-    toolbar->addAction(gActions->new_gisas_instrument);
-    toolbar->addAction(gActions->new_offspec_instrument);
-    toolbar->addAction(gActions->new_specular_instrument);
-    toolbar->addAction(gActions->new_depthprobe_instrument);
+    auto new_action = [toolbar](const QString& name, const QString& description) {
+        QAction* a = new QAction("New " + name);
+        a->setIcon(QIcon(":/images/shape-square-plus.svg"));
+        a->setToolTip("Add new " + description + " instrument with default settings");
+        toolbar->addAction(a);
+        return a;
+    };
+
+    connect(new_action("GISAS", "2D scattering"), &QAction::triggered,
+            [this] { m_qlistmodel->pushInstrument(new Scatter2DInstrumentItem); });
+
+    connect(new_action("offspec", "off-specular"), &QAction::triggered,
+            [this] { m_qlistmodel->pushInstrument(new OffspecInstrumentItem); });
+
+    connect(new_action("specular", "specular reflectivity"), &QAction::triggered,
+            [this] { m_qlistmodel->pushInstrument(new SpecularInstrumentItem); });
+
+    connect(new_action("depthprobe", "depth intensity profile"), &QAction::triggered,
+            [this] { m_qlistmodel->pushInstrument(new DepthprobeInstrumentItem); });
+
     toolbar->addAction(gActions->remove_instrument);
     toolbar->addAction(gActions->copy_instrument);
     toolbar->addAction(gActions->store_in_library_instrument);
@@ -74,18 +90,6 @@ InstrumentView::InstrumentView()
 
     //... Finalize
 
-    connect(gActions->new_gisas_instrument, &QAction::triggered,
-            [this] { m_qlistmodel->pushInstrument(new Scatter2DInstrumentItem); });
-
-    connect(gActions->new_offspec_instrument, &QAction::triggered,
-            [this] { m_qlistmodel->pushInstrument(new OffspecInstrumentItem); });
-
-    connect(gActions->new_specular_instrument, &QAction::triggered,
-            [this] { m_qlistmodel->pushInstrument(new SpecularInstrumentItem); });
-
-    connect(gActions->new_depthprobe_instrument, &QAction::triggered,
-            [this] { m_qlistmodel->pushInstrument(new DepthprobeInstrumentItem); });
-
     connect(gActions->remove_instrument, &QAction::triggered, m_qlistmodel,
             &InstrumentsQModel::removeInstrument);
 
-- 
GitLab