-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
104 lines (86 loc) · 2.73 KB
/
main.cpp
File metadata and controls
104 lines (86 loc) · 2.73 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "UI/MainWindow.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include "ElaApplication.h"
#include "ElaWidget.h"
#include "QSplashScreen"
#include "UI/widget/CustomSplashScreen.h"
#include "Utils/Settings/SettingsHandler.h"
#include "QSettings"
#include "UI/DataViewer/DataViewerPage.h"
#include "ElaContentDialog.h"
#include "UI/widget/FluentLoadingWidget.h"
#include "Utils/Settings/parser.hpp"
#include "QMessageBox"
#include <chrono>
#include <thread>
#ifdef Q_OS_WIN32
#include "WinBase.h"
#endif
int main(int argc, char* argv[])
{
// SetProcessDPIAware(); // call before the main event loop
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
#endif
QApplication a(argc, argv);
a.setApplicationName("Bitbot Copilot");
a.setApplicationDisplayName("Bitbot Copilot");
a.setApplicationVersion(QString(BUILD_VERSION_COMMIT_HASH));
ZCP_INIT; //初始化parser
if (ZCP.isUpgradeMode())
{
if (ZCP.ProcessUpgradeLogic())
return 0;
else
{
QMessageBox::critical(nullptr, QObject::tr("Upgrade Failed"), QObject::tr("Program upgrade failed, try again later or contact publisher for more information."), QMessageBox::Ok);
}
}
eApp->init();
QFontDatabase::addApplicationFont(":/include/Font/segoe_slboot.ttf");
a.processEvents();
bool no_show_screen = ZCP.isNoSplashScreen();
CustomSplashScreen* screen;
if (!no_show_screen)
{
screen = new CustomSplashScreen(3000);
screen->show();
}
a.processEvents();
a.setWindowIcon(QIcon(":/logo/Image/ProgramIcon.ico"));
a.processEvents();
QTranslator translator;
qDebug() << QLocale::system().language();
if (translator.load(":/i18n/Translation/BitbotCopilot_zh_CN.qm") && QLocale::system().language() == QLocale::Chinese) {
a.installTranslator(&translator);
qDebug() << "Load zh_CN.qm";
}
MainWindow w;
if (!no_show_screen)
screen->exec();
if (ZCP.isMaximizeMode())
w.showMaximized();
else
{
w.show();
}
//w.showMaximized();
//screen->close();
a.processEvents();
if (!no_show_screen)
delete screen;
#ifdef Q_OS_WIN32
EXECUTION_STATE s = SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
#endif // Q_OS_WIN32
int rtn = a.exec();
#ifdef Q_OS_WIN32
SetThreadExecutionState(ES_CONTINUOUS);
#endif // Q_OS_WIN32
return rtn;
}