MathVizAnimator
Home
First Steps
User Guide
Developer Guide
Reference Guide (doxygen)
MathVizAnimator
MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/app/src/main.h Source File
View page source
/home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/app/src/main.h Source File
MathVizAnimator: /home/docs/checkouts/readthedocs.org/user_builds/mathvizanimator/checkouts/latest/app/src/main.h Source File
MathVizAnimator
0.0.1
app
src
main.h
1
/* mathvizanimator
2
* Copyright (C) 2023 codingwithmagga
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef APP_SRC_MAIN_H_
19
#define APP_SRC_MAIN_H_
20
21
#include <QGuiApplication>
22
#include <QQmlApplicationEngine>
23
24
#include "mainlogic.h"
25
26
class
SetupMain
{
27
public
:
28
struct
SetupObjects
{
29
QSharedPointer<MainLogic> mainlogic;
30
QSharedPointer<QQmlApplicationEngine> engine;
31
};
32
33
SetupMain
() =
delete
;
34
35
static
SetupObjects
setupApp(
const
QSharedPointer<QGuiApplication> gui_app = Q_NULLPTR)
36
{
37
SetupObjects
setup_objects;
38
39
qSetMessagePattern(
"%{time dd.MM.yyyy hh:mm:ss.zzz} | "
40
"%{if-debug}DBG%{endif}%{if-info}INF%{endif}%{if-warning}WRN%{endif}%{"
41
"if-"
42
"critical}CRT%{endif}%{if-fatal}FTL%{endif} | %{category} | "
43
"%{message}"
);
44
45
setup_objects.mainlogic = QSharedPointer<MainLogic>(
new
MainLogic
);
46
setup_objects.engine = QSharedPointer<QQmlApplicationEngine>(
new
QQmlApplicationEngine);
47
48
// TODO(codingwithmagga): pointer to shared pointer
49
setup_objects.mainlogic->initEngine(setup_objects.engine.data());
50
51
const
QUrl url(
"qrc:/qt/qml/cwa/mva/gui/qml/MainWindow.qml"
);
52
53
if
(gui_app) {
54
QCoreApplication::setApplicationName(
"mathvizanimator"
);
55
QCoreApplication::setOrganizationName(
"codingwithmagga"
);
56
QObject::connect(
57
setup_objects.engine.data(), &QQmlApplicationEngine::objectCreationFailed, gui_app.data(),
58
[]() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
59
}
60
61
setup_objects.engine->load(url);
62
63
setup_objects.mainlogic->connectEngine();
64
65
return
setup_objects;
66
}
67
};
68
69
#endif
// APP_SRC_MAIN_H_
MainLogic
Definition:
mainlogic.h:32
SetupMain
Definition:
main.h:26
SetupMain::SetupObjects
Definition:
main.h:28
Generated by
1.9.1