1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "abstractcentral.h"
6
7#include <QDebug>
8#include <QWidget>
9
10class AbstractCentralPrivate
11{
12 friend class AbstractCentral;
13 QWidget *widget;
14};
15
16AbstractCentral::AbstractCentral(void *qwidget)
17 : d(new AbstractCentralPrivate())
18{
19 if (!qwidget) {
20 qCritical() << "Failed, use QWidget(0x0) to AbstractCentral";
21 abort();
22 }
23
24 d->widget = static_cast<QWidget*>(qwidget);
25 QWidget::connect(d->widget, &QWidget::destroyed,
26 d->widget, [this](){
27 delete this;
28 }, Qt::UniqueConnection);
29}
30
31AbstractCentral::~AbstractCentral()
32{
33 if (d) {
34 delete d;
35 }
36}
37
38void *AbstractCentral::qWidget()
39{
40 return d->widget;
41}
42