1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "configurewidget.h"
6#include "collapsewidget.h"
7
8#include <QVBoxLayout>
9#include <QLabel>
10#include <QDebug>
11
12class ConfigureWidgetPrivate
13{
14 friend class ConfigureWidget;
15 QWidget *centrelWidget = nullptr;
16 QVBoxLayout *layout = nullptr;
17};
18
19ConfigureWidget::ConfigureWidget(QWidget *parent)
20 : QScrollArea(parent)
21 , d(new ConfigureWidgetPrivate())
22{
23 setAutoFillBackground(true);
24 setWidgetResizable(true);
25 d->centrelWidget = new QWidget();
26 d->centrelWidget->setObjectName("ConfigureCentrelWidget");
27 d->centrelWidget->setAutoFillBackground(true);
28 d->layout = new QVBoxLayout(d->centrelWidget);
29 d->layout->setContentsMargins(24, 24, 24, 24);
30 d->layout->setSpacing(24);
31 d->centrelWidget->setLayout(d->layout);
32 d->layout->addSpacerItem(new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding));
33 setWidget(d->centrelWidget);
34}
35
36ConfigureWidget::~ConfigureWidget()
37{
38 if (d)
39 delete d;
40}
41
42void ConfigureWidget::addCollapseWidget(CollapseWidget *widget)
43{
44 if (!widget)
45 return;
46 qInfo() << widget->isChecked();
47 if (!widget->isChecked()) {
48 widget->setChecked(true);
49 }
50 widget->setFixedHeight(600);
51 d->layout->insertWidget(d->layout->count() - 1, widget);
52 qInfo() << widget->size();
53}
54
55void ConfigureWidget::addWidget(QWidget *widget)
56{
57 if (!widget)
58 return;
59
60 d->layout->insertWidget(d->layout->count() - 1, widget);
61}
62
63void ConfigureWidget::resizeEvent(QResizeEvent *event)
64{
65 d->centrelWidget->resize(d->centrelWidget->width(), event->size().width());
66 QScrollArea::resizeEvent(event);
67}
68