1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef COLLAPSEWIDGET_H
6#define COLLAPSEWIDGET_H
7
8#include <QPaintEvent>
9#include <QWidget>
10
11class CollapseWidgetPrivate;
12class CollapseWidget : public QWidget
13{
14 CollapseWidgetPrivate *const d;
15public:
16 explicit CollapseWidget(QWidget *parent = nullptr);
17 explicit CollapseWidget(const QString &title, QWidget *widget, QWidget *parent = nullptr);
18 virtual ~CollapseWidget() override;
19
20 QWidget *takeWidget();
21 void setWidget(QWidget *widget);
22 QWidget* widget();
23
24 void setTitle(const QString &title);
25 QString title();
26
27 void setCheckable(bool checkable);
28 bool isCheckable();
29
30 bool isChecked();
31
32protected:
33 void resizeEvent(QResizeEvent *event) override;
34 void paintEvent(QPaintEvent *event) override;
35
36public slots:
37 void setChecked(bool);
38
39private slots:
40 void doChecked(bool);
41 void resetHeight(const QVariant &);
42};
43
44#endif // COLLAPSEWIDGET_H
45