qt/ledset/main.cpp

94 lines
4.3 KiB
C++
Raw Normal View History

2022-08-25 18:43:03 +08:00
#include "mainwin.h"
#include <QApplication>
#include <QIcon>
2023-08-21 11:21:00 +08:00
#include <QLocale>
2022-08-25 18:43:03 +08:00
#include <QMessageBox>
2023-08-21 11:21:00 +08:00
#include <QTranslator>
2022-08-25 18:43:03 +08:00
#ifdef _MSC_VER //MSVC编译器
#include <windows.h>
#include <DbgHelp.h>
LONG WINAPI handleException(_EXCEPTION_POINTERS *excep) {
2023-08-21 11:21:00 +08:00
auto errCode = QString::number(excep->ExceptionRecord->ExceptionCode, 16);
auto errAddr = QString::number((uint)excep->ExceptionRecord->ExceptionAddress, 16);
auto hDumpFile = CreateFile(L"ledset-crash.dmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hDumpFile == INVALID_HANDLE_VALUE) {
qCritical()<<"CreateFile ledset-crash.dmp Failed! ExceptionCode"<<errCode<<"ExceptionAddress"<<errAddr;
return EXCEPTION_CONTINUE_SEARCH;
}
2022-08-25 18:43:03 +08:00
MINIDUMP_EXCEPTION_INFORMATION dumpInfo{GetCurrentThreadId(), excep, TRUE};
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL);//写入Dump文件内容
CloseHandle(hDumpFile);
2023-08-21 11:21:00 +08:00
QMessageBox::critical(0, "程序出错 (V" __VER__" - " __DATE__", Code: "+errCode+")", "<b>程序出错!</b><br/>请将安装目录下的 ledok-crash.dmp 文件发送到 gangphon@qq.com 邮箱, 研发人员会尽快处理.");
2022-08-25 18:43:03 +08:00
return EXCEPTION_EXECUTE_HANDLER; //已处理异常, 让 windows 正常结束
}
#endif
2023-08-21 11:21:00 +08:00
2022-08-25 18:43:03 +08:00
int main(int argc, char *argv[]) {
2023-05-27 17:43:57 +08:00
qputenv("QT_QPA_PLATFORM", "windows:darkmode=2");
2022-08-25 18:43:03 +08:00
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
2023-05-27 17:43:57 +08:00
QApplication::setOrganizationName("Shanghai Xixun Electronic Technology");
2023-06-07 19:11:03 +08:00
QApplication::setOrganizationDomain("ledok.cn");
2023-05-27 17:43:57 +08:00
QApplication::setApplicationName("LedSet Express");
2022-08-25 18:43:03 +08:00
QApplication a(argc, argv);
2023-08-21 11:21:00 +08:00
QApplication::setStyle("Fusion");
2022-08-25 18:43:03 +08:00
a.setWindowIcon(QIcon(":/128.ico"));
a.setStyleSheet(R"rrr(
2023-03-20 11:30:19 +08:00
QLineEdit {border: 1px solid #777; border-radius: 2px; padding: 2px;}
QAbstractScrollArea {border: 1px solid #777;}
QTableView {gridline-color:#777;}
2022-09-09 23:25:49 +08:00
QMessageBox {background: #333;}
2022-12-16 15:08:53 +08:00
QRadioButton::indicator {border-image: url(:/imgs/radio-un.png); width: 1em; height: 1em;}
2022-08-25 18:43:03 +08:00
QRadioButton::indicator:checked {border-image: url(:/imgs/radio-check.png);}
2022-12-16 15:08:53 +08:00
QCheckBox::indicator {border-image: url(:/imgs/checkbox-un.png); width: 1em; height: 1em;}
QCheckBox::indicator:checked {border-image: url(:/imgs/checkbox-check.png);}
2022-08-25 18:43:03 +08:00
2023-08-21 11:21:00 +08:00
QPushButton:checked {border: 2px solid #0a0; border-radius: 3px; padding-top: 2px; padding-bottom: 2px; }
2023-06-07 19:11:03 +08:00
QPushButton:disabled {color: #777;}
2023-03-20 11:30:19 +08:00
QPushButton[ss="min"]{padding: 0; width: 30px; height: 25px; }
QPushButton[ss="close"]{padding: 0; width: 30px; height: 25px; }
2022-08-25 18:43:03 +08:00
2023-05-27 17:43:57 +08:00
QPushButton[ss="blue"] {background: #059;}
2023-06-07 19:11:03 +08:00
QGroupBox {border: 1px solid #777; border-radius: 3px; margin-top: 0.5em; padding-top: 0.4em;}
QGroupBox::title {color: #fff; subcontrol-origin: margin; left: 0.5em;}
2022-08-25 18:43:03 +08:00
)rrr");
2022-12-16 15:08:53 +08:00
QFont font;
font.setFamilies(QStringList{"Arial","Microsoft YaHei UI"});
a.setFont(font);
QPalette plt = a.palette();
plt.setBrush(QPalette::Window, QColor(0x333333));
plt.setBrush(QPalette::WindowText, QColor(0xffffff));
plt.setBrush(QPalette::Base, QColor(0x222222));
plt.setBrush(QPalette::AlternateBase, QColor(0x333333));
plt.setBrush(QPalette::Text, QColor(0xffffff));
2023-03-20 11:30:19 +08:00
plt.setBrush(QPalette::PlaceholderText, QColor(0xaaaaaa));
2023-05-27 17:43:57 +08:00
plt.setBrush(QPalette::Button, QColor(0x444444));
2022-12-16 15:08:53 +08:00
plt.setBrush(QPalette::ButtonText, QColor(0xffffff));
plt.setBrush(QPalette::ToolTipBase, QColor(0x444466));
2023-03-20 11:30:19 +08:00
plt.setBrush(QPalette::ToolTipText, QColor(0xeeeeee));
2022-12-16 15:08:53 +08:00
plt.setBrush(QPalette::Light, QColor(0x444444));
2023-03-20 11:30:19 +08:00
plt.setBrush(QPalette::Midlight, QColor(0x666666));
plt.setBrush(QPalette::Mid, QColor(0x888888));
plt.setBrush(QPalette::Dark, QColor(0xaaaaaa));
2022-12-16 15:08:53 +08:00
plt.setBrush(QPalette::BrightText, QColor(0,0,0));
plt.setBrush(QPalette::Shadow, QColor(0xaaaaaa));
a.setPalette(plt);
2022-08-25 18:43:03 +08:00
QTranslator translator;
2023-08-21 11:21:00 +08:00
if(translator.load(QLocale(), "app", "_", ":/i18n")) a.installTranslator(&translator);
2022-08-25 18:43:03 +08:00
QTranslator qtTrans;
2023-08-21 11:21:00 +08:00
if(qtTrans.load(QLocale(), "qt", "_", "translations")) a.installTranslator(&qtTrans);
2022-08-25 18:43:03 +08:00
MainWin w;
#ifdef _MSC_VER
SetUnhandledExceptionFilter(handleException);
#endif
return a.exec();
}