BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ActionFactory.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Util/ActionFactory.h
6 //! @brief Defines class ActionFactory
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_UTIL_ACTIONFACTORY_H
16 #define BORNAGAIN_GUI_UTIL_ACTIONFACTORY_H
17 
18 #include <functional>
19 
20 class QAction;
21 class QObject;
22 class QString;
23 class QWidget;
24 
25 //! Factory to create commonly used actions
27 public:
28  // delete copy/move constructor/assignment:
29  ActionFactory(const ActionFactory&) = delete;
33 
34  //! Create "remove" action.
35  //!
36  //! The "what" text will be used in the tooltip, appended to "Remove ".
37  //! If a slot is given, it will be connected to the "triggered" signal.
38  static QAction* createRemoveAction(QObject* parent, const QString& what,
39  std::function<void()> slot = nullptr);
40 
41  //! Create "show in RealSpace" action.
42  //!
43  //! The "what" text will be used in the tooltip.
44  //! If a slot is given, it will be connected to the "triggered" signal.
45  static QAction* createShowInRealSpaceAction(QObject* parent, const QString& what,
46  std::function<void()> slot = nullptr);
47 
48  //! Create "toggle properties panel" action.
49  //!
50  //! If toggledWidget is given, it will be shown/hidden when the actions changes its state.
51  static QAction* createTogglePropertiesPanelAction(QObject* parent,
52  QWidget* toggledWidget = nullptr);
53 
54 private:
55  ActionFactory() = default;
56 };
57 
58 #endif // BORNAGAIN_GUI_UTIL_ACTIONFACTORY_H
Factory to create commonly used actions.
Definition: ActionFactory.h:26
ActionFactory()=default
static QAction * createShowInRealSpaceAction(QObject *parent, const QString &what, std::function< void()> slot=nullptr)
Create "show in RealSpace" action.
static QAction * createRemoveAction(QObject *parent, const QString &what, std::function< void()> slot=nullptr)
Create "remove" action.
ActionFactory & operator=(ActionFactory &&)=delete
ActionFactory(const ActionFactory &)=delete
static QAction * createTogglePropertiesPanelAction(QObject *parent, QWidget *toggledWidget=nullptr)
Create "toggle properties panel" action.
ActionFactory & operator=(const ActionFactory &)=delete
ActionFactory(ActionFactory &&)=delete