73 lines
3.3 KiB
C++
73 lines
3.3 KiB
C++
#include "mainwindow.h"
|
|
#include <QApplication>
|
|
#include <QFile>
|
|
#include <QMessageBox>
|
|
#include <QSplashScreen>
|
|
#include <QStandardPaths>
|
|
|
|
#ifdef _MSC_VER //MSVC编译器
|
|
#include <Windows.h>
|
|
#include <DbgHelp.h>
|
|
LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
|
|
auto errCode = QString::number(excep->ExceptionRecord->ExceptionCode, 16);
|
|
auto errAddr = QString::number((uint)excep->ExceptionRecord->ExceptionAddress, 16);
|
|
auto hDumpFile = CreateFile(L"ledok-crash.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
if(hDumpFile == INVALID_HANDLE_VALUE) {
|
|
qCritical()<<"CreateFile ledok-crash.dmp Failed! ExceptionCode"<<errCode<<"ExceptionAddress"<<errAddr;
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
MINIDUMP_EXCEPTION_INFORMATION dumpInfo{GetCurrentThreadId(), excep, TRUE};
|
|
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL);//写入Dump文件内容
|
|
CloseHandle(hDumpFile);
|
|
QMessageBox::critical(0, "程序出错 (V" APP_VERSION" - " __DATE__", Code: "+errCode+")", "<b>程序出错!</b><br/>请将安装目录下的 ledok-crash.dmp 文件发送到 gangphon@qq.com 邮箱, 研发人员会尽快处理.");
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
// EXCEPTION_EXECUTE_HANDLER 已处理异常, 让 windows 正常结束
|
|
// EXCEPTION_CONTINUE_SEARCH 未处理异常, 让 windows 弹出错误框并结束 (Qt会卡死一段时间)
|
|
// EXCEPTION_CONTINUE_EXECUTION 已修复错误, 让 windows 从异常发生处继续执行
|
|
}
|
|
#endif
|
|
|
|
QString css;
|
|
int main(int argc, char *argv[]) {
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
|
QApplication::setOrganizationName("Shanghai Xixun Electronic Technology Co., Ltd.");
|
|
QApplication::setOrganizationDomain("www.ledok.cn");
|
|
QApplication::setApplicationName("LedOK Express");
|
|
QApplication::setStyle("Fusion");
|
|
QApplication a(argc, argv);
|
|
|
|
QSplashScreen splash(QPixmap(":/res/splash.png"));
|
|
splash.show();
|
|
splash.showMessage(QObject::tr("Setting up the LedOK Express..."), Qt::AlignRight | Qt::AlignTop, Qt::white);
|
|
|
|
QFile file(":/css.css");
|
|
if(file.exists() && file.open(QFile::ReadOnly)) {
|
|
a.setStyleSheet(css = file.readAll());
|
|
file.close();
|
|
}
|
|
QFont font;
|
|
font.setFamilies(QStringList{"Arial","PingFang SC","Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei","sans-serif"});
|
|
a.setFont(font);
|
|
auto plt = a.palette();
|
|
plt.setBrush(QPalette::AlternateBase, plt.brush(QPalette::Active, QPalette::Window));
|
|
plt.setBrush(QPalette::Inactive, QPalette::Highlight, plt.brush(QPalette::Active, QPalette::Highlight));
|
|
plt.setBrush(QPalette::Inactive, QPalette::HighlightedText, plt.brush(QPalette::Active, QPalette::HighlightedText));
|
|
a.setPalette(plt);
|
|
|
|
QTranslator qtTrans;
|
|
if(qtTrans.load(QLocale(), "qt", "_", "translations")) QCoreApplication::installTranslator(&qtTrans);
|
|
|
|
gFileHome = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
|
|
|
#ifdef _MSC_VER
|
|
SetUnhandledExceptionFilter(handleException);
|
|
#endif
|
|
MainWindow w;
|
|
w.show();
|
|
splash.finish(&w);
|
|
|
|
return a.exec();
|
|
}
|