From 98e4f937091bf93721c4ef79fdd3c58b123b3b29 Mon Sep 17 00:00:00 2001
From: Matthias Puchner <github@mpuchner.de>
Date: Wed, 10 Nov 2021 09:25:29 +0100
Subject: [PATCH] add method to create "show in real space" action

---
 GUI/View/SampleDesigner/ActionFactory.cpp | 15 +++++++++++++++
 GUI/View/SampleDesigner/ActionFactory.h   |  9 ++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/GUI/View/SampleDesigner/ActionFactory.cpp b/GUI/View/SampleDesigner/ActionFactory.cpp
index 057d42f8653..4bf3093e3f9 100644
--- a/GUI/View/SampleDesigner/ActionFactory.cpp
+++ b/GUI/View/SampleDesigner/ActionFactory.cpp
@@ -29,3 +29,18 @@ QAction* ActionFactory::createRemoveAction(QObject* parent, const QString& what,
 
     return removeAction;
 }
+
+QAction* ActionFactory::createShowInRealSpaceAction(QObject* parent, const QString& what,
+                                                    std::function<void()> slot)
+{
+    auto* action = new QAction(parent);
+    action->setText("Show in Real Space (3D) view");
+    action->setIcon(QIcon(":/SampleDesigner/images/rotate-3d.svg"));
+    action->setIconText("3D");
+    action->setToolTip("Show " + what + " in Real Space (3D) view");
+
+    if (slot)
+        QObject::connect(action, &QAction::triggered, slot);
+
+    return action;
+}
diff --git a/GUI/View/SampleDesigner/ActionFactory.h b/GUI/View/SampleDesigner/ActionFactory.h
index 3315e4f7cd3..5237b1e593b 100644
--- a/GUI/View/SampleDesigner/ActionFactory.h
+++ b/GUI/View/SampleDesigner/ActionFactory.h
@@ -32,11 +32,18 @@ public:
 
     //! Create "remove" action.
     //!
-    //! The "what text will be used in the tooltip, appended to "Remove ".
+    //! The "what" text will be used in the tooltip, appended to "Remove ".
     //! If a slot is given, it will be connected to the "triggered" signal.
     static QAction* createRemoveAction(QObject* parent, const QString& what,
                                        std::function<void()> slot = nullptr);
 
+    //! Create "show in RealSpace" action.
+    //!
+    //! The "what" text will be used in the tooltip.
+    //! If a slot is given, it will be connected to the "triggered" signal.
+    static QAction* createShowInRealSpaceAction(QObject* parent, const QString& what,
+                                                std::function<void()> slot = nullptr);
+
 private:
     ActionFactory() = default;
 };
-- 
GitLab