Wireshark 4.7.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
102 private slots:
107 void onToggle(bool checked);
108
109 private:
110 QToolButton *toggleButton;
111 QFrame *headerLine;
112 QHBoxLayout *headerLayout_ = nullptr;
115 QWidget *headerContainer_ = nullptr;
116 QWidget *contentArea;
117 QVBoxLayout *mainLayout;
119 QWidget *headerTrailingWidget_ = nullptr;
120 int savedHeight;
126 int titleH_ = 0;
127};
128
129#endif // COLLAPSIBLE_SECTION_H
A collapsible section widget for use in a QSplitter.
Definition collapsible_section.h:31
void toggled(bool expanded)
Emitted when the section is toggled.
void setHeaderTrailingWidget(QWidget *widget)
Set an optional widget in the header row after the horizontal rule (order: title, rule,...
Definition collapsible_section.cpp:110
void setContentWidget(QWidget *contentWidget)
Set the content widget for this section.
Definition collapsible_section.cpp:90
void setExpanded(bool expanded)
Set the expanded state of the section.
Definition collapsible_section.cpp:130
void setTitle(const QString &title)
Set the title text.
Definition collapsible_section.cpp:141
int headerHeight() const
Get the header height (for splitter sizing when collapsed).
Definition collapsible_section.cpp:146
int titleButtonHeight() const
Height of the title / toggle control (single header line).
Definition collapsible_section.cpp:153
bool isExpanded() const
Check if the section is currently expanded.
Definition collapsible_section.cpp:136
QFont titleButtonFont() const
Font used for the section title (bold application font).
Definition collapsible_section.cpp:158