-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (67 loc) · 2.56 KB
/
Copy pathmain.cpp
File metadata and controls
85 lines (67 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <QGuiApplication>
#include <QSurfaceFormat>
#include <QSettings>
#include <QThread>
#include <WeaQuick/initialize.h>
#include "InjectionMolding/Utils.h"
#include "InjectionMolding/Engine.h"
#include "InjectionMolding/AlarmModel.h"
#include "InjectionMolding/RecordModel.h"
#include "InjectionMolding/plciomodel.h"
#include "InjectionMolding/Registerations.h"
const char* DEBUG_MESSAGE_PATTERN = "[%{type}][%{threadid}][%{function}:%{line}] - %{message}";
int main(int argc, char* argv[])
{
/** OpenGL Properties **/
QSurfaceFormat fmt;
// fmt.setVersion(2, 6);
// fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setDepthBufferSize(24);
fmt.setStencilBufferSize(8);
fmt.setSwapInterval(1);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
QSurfaceFormat::setDefaultFormat(fmt);
QSurfaceFormat curFmt = QSurfaceFormat::defaultFormat();
// qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
// qputenv("QT_FONT_DPI", "96");
// qputenv("QT_SCALE_FACTOR", "1.25");
qInstallMessageHandler(logMessageHandler);
qputenv("QML_DISABLE_DISK_CACHE", "1");
// qputenv("QT_ASSUME_STDERR_HAS_CONSOLE", "1");
// qputenv("QSG_INFO", "1");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QGuiApplication::setOrganizationName("WeaProject");
QGuiApplication::setOrganizationDomain("com.wearily");
QGuiApplication::setApplicationName("InjectionMolding");
const QString projectSourceDir(PROJECT_SOURCE_DIR);
const QString mainQmlPath(projectSourceDir + "/main.qml");
Engine engine;
// const QUrl url(QStringLiteral("qrc:/main.qml"));
const QUrl url(QUrl::fromLocalFile(mainQmlPath));
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreated,
&app,
[url](QObject * obj, const QUrl & objUrl)
{
if (!obj && url == objUrl)
{
QCoreApplication::exit(-1);
}
},
Qt::QueuedConnection);
// 3rdParty initializing
WeaQuick::initialize(&engine);
engine.addImportPath(PROJECT_SOURCE_DIR);
// Engine Property Contexts
engine.addEngineContextProperty();
engine.rootContext()->setContextProperty("_alarmModel", &AlarmModel::getInstance());
engine.rootContext()->setContextProperty("_recordModel", &RecordModel::getInstance());
engine.rootContext()->setContextProperty("_plcIOModel", &PlcIOModel::getInstance());
engine.load(url);
return app.exec();
}