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 "abstractmenubar.h" |
7 | #include "abstractmainwindow.h" |
8 | |
9 | #include <QDebug> |
10 | #include <QObject> |
11 | #include <QMainWindow> |
12 | #include <QToolBar> |
13 | #include <QMenuBar> |
14 | |
15 | class AbstractMainWindowPrivate |
16 | { |
17 | friend class AbstractMainWindow; |
18 | QMainWindow* mainwindow = nullptr; |
19 | }; |
20 | |
21 | AbstractMainWindow::~AbstractMainWindow() |
22 | { |
23 | if (d) { |
24 | delete d; |
25 | } |
26 | } |
27 | |
28 | void *AbstractMainWindow::qMainWindow() |
29 | { |
30 | return static_cast<void*>(d->mainwindow); |
31 | } |
32 | |
33 | AbstractMainWindow::AbstractMainWindow(void *qMainWindow) |
34 | : d(new AbstractMainWindowPrivate()) |
35 | { |
36 | if (!qMainWindow) { |
37 | qCritical() << "Failed, use QMainWindow(0x0) to AbstractMainWindow"; |
38 | abort(); |
39 | } |
40 | |
41 | d->mainwindow = static_cast<QMainWindow*>(qMainWindow); |
42 | QMainWindow::connect(d->mainwindow, &QMainWindow::destroyed, |
43 | d->mainwindow ,[this]() { |
44 | delete this; |
45 | }, Qt::UniqueConnection); |
46 | } |
47 |