BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ActionFactory Class Reference

Description

Factory to create commonly used actions.

Definition at line 26 of file ActionFactory.h.

Public Member Functions

 ActionFactory (ActionFactory &&)=delete
 
 ActionFactory (const ActionFactory &)=delete
 
ActionFactoryoperator= (ActionFactory &&)=delete
 
ActionFactoryoperator= (const ActionFactory &)=delete
 

Static Public Member Functions

static QAction * createRemoveAction (QObject *parent, const QString &what, std::function< void()> slot=nullptr)
 Create "remove" action. More...
 
static QAction * createShowInRealSpaceAction (QObject *parent, const QString &what, std::function< void()> slot=nullptr)
 Create "show in RealSpace" action. More...
 
static QAction * createTogglePropertiesPanelAction (QObject *parent, QWidget *toggledWidget=nullptr)
 Create "toggle properties panel" action. More...
 

Private Member Functions

 ActionFactory ()=default
 

Constructor & Destructor Documentation

◆ ActionFactory() [1/3]

ActionFactory::ActionFactory ( const ActionFactory )
delete

◆ ActionFactory() [2/3]

ActionFactory::ActionFactory ( ActionFactory &&  )
delete

◆ ActionFactory() [3/3]

ActionFactory::ActionFactory ( )
privatedefault

Member Function Documentation

◆ createRemoveAction()

QAction * ActionFactory::createRemoveAction ( QObject *  parent,
const QString &  what,
std::function< void()>  slot = nullptr 
)
static

Create "remove" action.

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.

Definition at line 18 of file ActionFactory.cpp.

20 {
21  auto* removeAction = new QAction(parent);
22  removeAction->setText("Remove");
23  removeAction->setIcon(QIcon(":/images/delete.svg"));
24  removeAction->setIconText("Remove");
25  removeAction->setToolTip("Remove " + what);
26 
27  if (slot)
28  QObject::connect(removeAction, &QAction::triggered, slot);
29 
30  return removeAction;
31 }

Referenced by LayerForm::LayerForm(), MesoCrystalForm::MesoCrystalForm(), ParticleCompositionForm::ParticleCompositionForm(), ParticleCoreShellForm::ParticleCoreShellForm(), ParticleForm::ParticleForm(), and ParticleLayoutForm::ParticleLayoutForm().

◆ createShowInRealSpaceAction()

QAction * ActionFactory::createShowInRealSpaceAction ( QObject *  parent,
const QString &  what,
std::function< void()>  slot = nullptr 
)
static

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.

Definition at line 33 of file ActionFactory.cpp.

35 {
36  auto* action = new QAction(parent);
37  action->setText("Show in Real Space (3D) view");
38  action->setIcon(QIcon(":/SampleDesigner/images/rotate-3d.svg"));
39  action->setIconText("3D");
40  action->setToolTip("Show " + what + " in Real Space (3D) view");
41 
42  if (slot)
43  QObject::connect(action, &QAction::triggered, slot);
44 
45  return action;
46 }

Referenced by LayerForm::LayerForm(), MesoCrystalForm::MesoCrystalForm(), MultiLayerForm::MultiLayerForm(), ParticleCompositionForm::ParticleCompositionForm(), ParticleCoreShellForm::ParticleCoreShellForm(), ParticleForm::ParticleForm(), and ParticleLayoutForm::ParticleLayoutForm().

◆ createTogglePropertiesPanelAction()

QAction * ActionFactory::createTogglePropertiesPanelAction ( QObject *  parent,
QWidget *  toggledWidget = nullptr 
)
static

Create "toggle properties panel" action.

If toggledWidget is given, it will be shown/hidden when the actions changes its state.

Definition at line 48 of file ActionFactory.cpp.

49 {
50  auto* action = new QAction(parent);
51  action->setText("Properties");
52  action->setIcon(QIcon(":/images/dock-right.svg"));
53  action->setToolTip("Toggle properties panel");
54  action->setCheckable(true);
55 
56  if (toggledWidget)
57  QObject::connect(action, &QAction::triggered, toggledWidget, &QWidget::setVisible);
58 
59  return action;
60 }

Referenced by FitComparisonWidget::FitComparisonWidget(), FitComparisonWidget1D::FitComparisonWidget1D(), IntensityDataWidget::IntensityDataWidget(), MaskEditorActions::MaskEditorActions(), and SpecularDataWidget::SpecularDataWidget().

◆ operator=() [1/2]

ActionFactory& ActionFactory::operator= ( ActionFactory &&  )
delete

◆ operator=() [2/2]

ActionFactory& ActionFactory::operator= ( const ActionFactory )
delete

The documentation for this class was generated from the following files: