20 #include <QToolButton>
28 QSignalBlocker b(p->m_toggleButton);
29 p->m_toggleButton->setChecked(
false);
30 p->m_toggleButton->setArrowType(Qt::ArrowType::RightArrow);
31 p->m_contentArea->hide();
39 if (groupBox ==
nullptr)
52 btn->setToolButtonStyle(Qt::ToolButtonIconOnly);
53 btn->setDefaultAction(action);
54 if (action->menu() !=
nullptr)
55 btn->setPopupMode(QToolButton::InstantPopup);
59 connect(action, &QAction::changed, [=]() { btn->setVisible(action->isVisible()); });
81 auto* mainLayout =
new QVBoxLayout;
82 mainLayout->setSpacing(0);
83 mainLayout->setContentsMargins(0, 0, 0, 0);
90 groupBox->setLayout(mainLayout);
96 "QToolButton { border: none; text-align: left; font: bold; padding: 5px}");
102 m_toggleButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
116 groupBox->setTitle(
"");
117 groupBox->setProperty(
"collapsible",
true);
124 m_toggleButton->setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);
ApplicationSettings * appSettings
global pointer to the instance
Defines class ApplicationSettings.
Defines class GroupBoxCollapser.
ApplicationSettings::Style currentStyle()
Add-on to group boxes to make them collapsible.
QWidget * m_contentArea
widget to where the original group box content has been moved
QHBoxLayout * m_titleLayout
layout in the title widget
void setExpanded(bool expanded=true)
Expand/collapse the content area.
GroupBoxCollapser(QGroupBox *groupBox)
void toggle(bool checked)
QWidget * contentArea() const
The content area, to which the found group box content has been moved when the add-on has been instal...
QWidget * m_titleWidget
widget used to present the new groupbox title
void addAction(QAction *action)
Add a tool button to the title bar, connected to the given action.
void addWidget(QWidget *widget)
Add a widget to the title bar.
QToolButton * m_toggleButton
button to toggle between collapsed/expanded
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
void setTitle(const QString &title)
Set the title of the group box. Do not use the method groupBox->setTitle() any more once the add-on i...
static GroupBoxCollapser * findInstalledCollapser(QGroupBox *groupBox)