BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentViewToolBar Class Reference

Styled tool bar on top of InstrumentView with add/remove/clone instrument buttons. More...

Inheritance diagram for InstrumentViewToolBar:
[legend]
Collaboration diagram for InstrumentViewToolBar:
[legend]

Public Member Functions

 InstrumentViewToolBar (InstrumentViewActions *actions, QWidget *parent=nullptr)
 
void addSpacing (int width=2)
 Width of the spacing between buttons. More...
 
void addStyledExpand ()
 
void addStyledSeparator ()
 

Protected Member Functions

void contextMenuEvent (QContextMenuEvent *)
 

Private Slots

void onAddInstrument ()
 

Private Attributes

QToolButton * m_addInstrumentButton
 
QMenu * m_addInstrumentMenu
 
QToolButton * m_cloneInstrumentButton
 
QToolButton * m_removeInstrumentButton
 

Detailed Description

Styled tool bar on top of InstrumentView with add/remove/clone instrument buttons.

Definition at line 28 of file InstrumentViewToolBar.h.

Constructor & Destructor Documentation

◆ InstrumentViewToolBar()

InstrumentViewToolBar::InstrumentViewToolBar ( InstrumentViewActions actions,
QWidget *  parent = nullptr 
)
explicit

Definition at line 20 of file InstrumentViewToolBar.cpp.

21  : StyledToolBar(parent)
22  , m_addInstrumentButton(new QToolButton)
23  , m_removeInstrumentButton(new QToolButton)
24  , m_cloneInstrumentButton(new QToolButton)
26 {
27  m_addInstrumentButton->setText("Add");
28  m_addInstrumentButton->setIcon(QIcon(":/images/shape-square-plus.svg"));
29  m_addInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
30  m_addInstrumentButton->setToolTip("Add new instrument");
31  m_addInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
32  m_addInstrumentButton->setPopupMode(QToolButton::MenuButtonPopup);
34  addWidget(m_addInstrumentButton);
35 
36  m_removeInstrumentButton->setText("Remove");
37  m_removeInstrumentButton->setIcon(QIcon(":/images/delete.svg"));
38  m_removeInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
39  m_removeInstrumentButton->setToolTip("Remove currently selected instrument");
40  addWidget(m_removeInstrumentButton);
41 
42  m_cloneInstrumentButton->setText("Clone");
43  m_cloneInstrumentButton->setIcon(QIcon(":/images/content-copy.svg"));
44  m_cloneInstrumentButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
45  m_cloneInstrumentButton->setToolTip("Clone currently selected instrument");
46  addWidget(m_cloneInstrumentButton);
47 
48  connect(m_addInstrumentButton, &QToolButton::clicked, this,
50  connect(m_removeInstrumentButton, &QToolButton::clicked, actions,
52  connect(m_cloneInstrumentButton, &QToolButton::clicked, actions,
54 }
void onRemoveInstrument()
Removes currently selected instrument.
void onCloneInstrument()
Clones currently selected instrument.
QMenu * instrumentMenu()
Returns menu to create one of available instrument types.
QToolButton * m_cloneInstrumentButton
QToolButton * m_removeInstrumentButton
QToolButton * m_addInstrumentButton
StyledToolBar(QWidget *parent=nullptr)

References m_addInstrumentButton, m_addInstrumentMenu, m_cloneInstrumentButton, m_removeInstrumentButton, onAddInstrument(), InstrumentViewActions::onCloneInstrument(), and InstrumentViewActions::onRemoveInstrument().

Here is the call graph for this function:

Member Function Documentation

◆ addSpacing()

void StyledToolBar::addSpacing ( int  width = 2)
inherited

Width of the spacing between buttons.

Definition at line 37 of file StyledToolBar.cpp.

38 {
39  QString space;
40  space.fill(' ', width);
41  addWidget(new QLabel(space));
42 }

Referenced by ItemComboToolBar::setActionList().

◆ addStyledExpand()

void StyledToolBar::addStyledExpand ( )
inherited

Definition at line 44 of file StyledToolBar.cpp.

45 {
46  QWidget* empty = new QWidget();
47  empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
48  addWidget(empty);
49 }

Referenced by ItemComboToolBar::setActionList().

◆ addStyledSeparator()

void StyledToolBar::addStyledSeparator ( )
inherited

Definition at line 28 of file StyledToolBar.cpp.

29 {
30  addWidget(new QLabel(" "));
31  addSeparator();
32  addWidget(new QLabel(" "));
33 }

Referenced by SampleToolBar::SampleToolBar().

◆ contextMenuEvent()

void StyledToolBar::contextMenuEvent ( QContextMenuEvent *  )
protectedinherited

Definition at line 51 of file StyledToolBar.cpp.

52 {
53  // Context menu reimplemented to suppress the default one
54 }

◆ onAddInstrument

void InstrumentViewToolBar::onAddInstrument ( )
privateslot

Definition at line 56 of file InstrumentViewToolBar.cpp.

57 {
58  m_addInstrumentMenu->defaultAction()->triggered();
59 }

References m_addInstrumentMenu.

Referenced by InstrumentViewToolBar().

Member Data Documentation

◆ m_addInstrumentButton

QToolButton* InstrumentViewToolBar::m_addInstrumentButton
private

Definition at line 38 of file InstrumentViewToolBar.h.

Referenced by InstrumentViewToolBar().

◆ m_addInstrumentMenu

QMenu* InstrumentViewToolBar::m_addInstrumentMenu
private

Definition at line 41 of file InstrumentViewToolBar.h.

Referenced by InstrumentViewToolBar(), and onAddInstrument().

◆ m_cloneInstrumentButton

QToolButton* InstrumentViewToolBar::m_cloneInstrumentButton
private

Definition at line 40 of file InstrumentViewToolBar.h.

Referenced by InstrumentViewToolBar().

◆ m_removeInstrumentButton

QToolButton* InstrumentViewToolBar::m_removeInstrumentButton
private

Definition at line 39 of file InstrumentViewToolBar.h.

Referenced by InstrumentViewToolBar().


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