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

Frame for widgets with tool bar on top and collapse/expand button functionality. More...

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

Signals

void widgetHeightRequest (int)
 

Public Member Functions

 InfoPanel (QWidget *parent)
 
QSize minimumSizeHint () const
 
QSize sizeHint () const
 

Protected Slots

void onExpandButtonClicked ()
 
void setContentVisible (bool editor_status, bool dock_notify=false)
 

Protected Member Functions

bool isContentVisible ()
 
void resizeEvent (QResizeEvent *event)
 

Protected Attributes

int m_cached_height
 
QStackedWidget * m_stackedWidget
 
InfoPanelToolBarm_toolBar
 

Detailed Description

Frame for widgets with tool bar on top and collapse/expand button functionality.

Intended for QDockWindow, to be able to quickly minimize/maximize its appearance. Used in JobMessagePanel.

Definition at line 29 of file InfoPanel.h.

Constructor & Destructor Documentation

◆ InfoPanel()

InfoPanel::InfoPanel ( QWidget *  parent)
explicit

Definition at line 27 of file InfoPanel.cpp.

28  : QFrame(parent)
30  , m_stackedWidget(new QStackedWidget)
31  , m_cached_height(default_height)
32 {
33  auto mainLayout = new QVBoxLayout;
34  mainLayout->addWidget(m_toolBar);
35  mainLayout->addWidget(m_stackedWidget);
36 
37  mainLayout->setContentsMargins(0, 0, 0, 0);
38  mainLayout->setMargin(0);
39  mainLayout->setSpacing(0);
40 
41  setLayout(mainLayout);
42 
45 }
Toolbar for InfoPanel with collapse/expand buttons.
void expandButtonClicked()
QStackedWidget * m_stackedWidget
Definition: InfoPanel.h:49
void onExpandButtonClicked()
Definition: InfoPanel.cpp:66
InfoPanelToolBar * m_toolBar
Definition: InfoPanel.h:48
int m_cached_height
Definition: InfoPanel.h:50

References InfoPanelToolBar::expandButtonClicked(), m_stackedWidget, m_toolBar, and onExpandButtonClicked().

Here is the call graph for this function:

Member Function Documentation

◆ isContentVisible()

bool InfoPanel::isContentVisible ( )
protected

Definition at line 92 of file InfoPanel.cpp.

93 {
94  if (m_stackedWidget->currentWidget())
95  return m_stackedWidget->currentWidget()->isVisible();
96 
97  return false;
98 }

References m_stackedWidget.

Referenced by onExpandButtonClicked(), and resizeEvent().

◆ minimumSizeHint()

QSize InfoPanel::minimumSizeHint ( ) const

Definition at line 61 of file InfoPanel.cpp.

62 {
63  return QSize(minimum_widget_height, minimum_widget_height);
64 }

◆ onExpandButtonClicked

void InfoPanel::onExpandButtonClicked ( )
protectedslot

Definition at line 66 of file InfoPanel.cpp.

67 {
69 }
bool isContentVisible()
Definition: InfoPanel.cpp:92
void setContentVisible(bool editor_status, bool dock_notify=false)
Definition: InfoPanel.cpp:71

References isContentVisible(), and setContentVisible().

Referenced by InfoPanel().

Here is the call graph for this function:

◆ resizeEvent()

void InfoPanel::resizeEvent ( QResizeEvent *  event)
protected

Definition at line 100 of file InfoPanel.cpp.

101 {
102  // widget is schrinking in height
103  if (event->oldSize().height() > event->size().height()) {
104  if (event->size().height() <= minimum_height_before_collapse && isContentVisible())
105  setContentVisible(false);
106  }
107 
108  // widget is growing in height
109  if (event->oldSize().height() < event->size().height()) {
110  if (event->size().height() > minimum_height_before_collapse && !isContentVisible())
111  setContentVisible(true);
112  }
113 
114  QWidget::resizeEvent(event);
115 }

References isContentVisible(), and setContentVisible().

Here is the call graph for this function:

◆ setContentVisible

void InfoPanel::setContentVisible ( bool  editor_status,
bool  dock_notify = false 
)
protectedslot

Definition at line 71 of file InfoPanel.cpp.

72 {
73  m_toolBar->setExpandStatus(editor_status);
74  if (editor_status) {
75  if (m_cached_height)
76  if (dock_notify)
78 
79  if (m_stackedWidget->currentWidget())
80  m_stackedWidget->currentWidget()->show();
81 
82  } else {
83  m_cached_height = (height() < minimum_height_before_collapse ? default_height : height());
84  if (m_stackedWidget->currentWidget())
85  m_stackedWidget->currentWidget()->hide();
86 
87  if (dock_notify)
88  emit widgetHeightRequest(minimum_widget_height);
89  }
90 }
void setExpandStatus(bool status)
void widgetHeightRequest(int)

References m_cached_height, m_stackedWidget, m_toolBar, InfoPanelToolBar::setExpandStatus(), and widgetHeightRequest().

Referenced by JobMessagePanel::JobMessagePanel(), ScriptPanel::ScriptPanel(), onExpandButtonClicked(), and resizeEvent().

Here is the call graph for this function:

◆ sizeHint()

QSize InfoPanel::sizeHint ( ) const

Definition at line 47 of file InfoPanel.cpp.

48 {
49  QSize result = m_toolBar->sizeHint();
50 
51  if (QWidget* widget = m_stackedWidget->currentWidget()) {
52  if (widget->isVisible())
53  result.setHeight(widget->height() + m_toolBar->height());
54  } else {
55  result.setHeight(m_toolBar->height());
56  }
57 
58  return result;
59 }

References m_stackedWidget, and m_toolBar.

◆ widgetHeightRequest

void InfoPanel::widgetHeightRequest ( int  )
signal

Member Data Documentation

◆ m_cached_height

int InfoPanel::m_cached_height
protected

Definition at line 50 of file InfoPanel.h.

Referenced by setContentVisible().

◆ m_stackedWidget

QStackedWidget* InfoPanel::m_stackedWidget
protected

◆ m_toolBar

InfoPanelToolBar* InfoPanel::m_toolBar
protected

Definition at line 48 of file InfoPanel.h.

Referenced by InfoPanel(), ScriptPanel::ScriptPanel(), setContentVisible(), and sizeHint().


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