-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (52 loc) · 1.81 KB
/
main.cpp
File metadata and controls
65 lines (52 loc) · 1.81 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
#include "widget.h"
#include "debug_helper.h"
#include "cpu_detector.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QMessageBox>
// main widget
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
// 初始化调试日志
DebugHelper::initLog();
DebugHelper::installCrashHandler();
DebugHelper::log("应用程序启动");
// 检查CPU兼容性
DebugHelper::log("检查CPU兼容性...");
QString cpuInfo = CPUDetector::getCPUInfo();
DebugHelper::log(cpuInfo);
if (!CPUDetector::isCompatible()) {
DebugHelper::log("CPU不兼容");
QMessageBox::critical(nullptr, "CPU不兼容",
"您的CPU不支持AVX2指令集,无法运行此程序。\n\n"
"最低要求:Intel Haswell (4代) 或 AMD Ryzen 1代\n\n"
"您的CPU信息:\n" + cpuInfo);
return 1;
}
if (CPUDetector::hasAVX512()) {
DebugHelper::log("CPU支持AVX-512");
} else {
DebugHelper::log("CPU不支持AVX-512");
}
// 设置应用程序图标
a.setWindowIcon(QIcon(":/resource_icon/logo.ico"));
DebugHelper::log("图标设置完成");
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "translator_qt_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
DebugHelper::log("创建Widget...");
Widget w;
DebugHelper::log("Widget创建完成");
w.show();
DebugHelper::log("窗口显示");
int result = a.exec();
DebugHelper::log(QString("应用程序退出,返回码: %1").arg(result));
return result;
}