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