Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
collapsible_section.h
1/* collapsible_section.h
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#ifndef COLLAPSIBLE_SECTION_H
11#define COLLAPSIBLE_SECTION_H
12
13#include <QFont>
14#include <QFrame>
15#include <QToolButton>
16#include <QVBoxLayout>
17#include <QWidget>
18
19class QHBoxLayout;
20
30class CollapsibleSection : public QWidget
31{
32 Q_OBJECT
33
34 public:
40 explicit CollapsibleSection(const QString &title = QString(),
41 QWidget *parent = nullptr);
42
49 void setContentWidget(QWidget *contentWidget);
50
55 void setExpanded(bool expanded);
56
61 bool isExpanded() const;
62
67 void setTitle(const QString &title);
68
73 int headerHeight() const;
74
79 int titleButtonHeight() const;
80
84 QFont titleButtonFont() const;
85
93 void setHeaderTrailingWidget(QWidget *widget);
94
95 signals:
100 void toggled(bool expanded);
101
110
111 private slots:
116 void onToggle(bool checked);
117
122 void refreshTitleMetrics();
123
124 private:
129 void applyTitleMetrics();
130
131 QToolButton *toggleButton;
132 QFrame *headerLine;
133 QHBoxLayout *headerLayout_ = nullptr;
136 QWidget *headerContainer_ = nullptr;
137 QWidget *contentArea;
138 QVBoxLayout *mainLayout;
140 QWidget *headerTrailingWidget_ = nullptr;
141 int savedHeight;
143 bool expanded_ = false;
146 int titleH_ = 0;
147};
148
149#endif // COLLAPSIBLE_SECTION_H
void toggled(bool expanded)
Emitted when the section is toggled.
void titleMetricsChanged()
The title row height or font changed, after an application font change or a zoom step.
void setHeaderTrailingWidget(QWidget *widget)
Set an optional widget in the header row after the horizontal rule (order: title, rule,...
Definition collapsible_section.cpp:141
void setContentWidget(QWidget *contentWidget)
Set the content widget for this section.
Definition collapsible_section.cpp:121
CollapsibleSection(const QString &title=QString(), QWidget *parent=nullptr)
Construct a collapsible section.
Definition collapsible_section.cpp:21
void setExpanded(bool expanded)
Set the expanded state of the section.
Definition collapsible_section.cpp:161
void setTitle(const QString &title)
Set the title text.
Definition collapsible_section.cpp:171
int headerHeight() const
Get the header height (for splitter sizing when collapsed).
Definition collapsible_section.cpp:176
int titleButtonHeight() const
Height of the title / toggle control (single header line).
Definition collapsible_section.cpp:181
bool isExpanded() const
Check if the section is currently expanded.
Definition collapsible_section.cpp:166
QFont titleButtonFont() const
Font used for the section title (bold application font).
Definition collapsible_section.cpp:186