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