main.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include <QApplication>
  2. #include <QTranslator>
  3. #include <QDesktopWidget>
  4. #include <QScreen>
  5. #include <QTextCodec>
  6. #include <locale>
  7. #include "../../helper/GenerateMiniDump.h"
  8. #include "EXLoginWidget.h"
  9. #include "MainWindow.h"
  10. #include "FileUtil.h"
  11. #include "importDataUtil.h"
  12. #include "EXConfig.h"
  13. int main(int argc, char *argv[])
  14. {
  15. DUMP_FILE_HOOK_HANLE;
  16. QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
  17. std::locale::global(std::locale(""));
  18. #ifndef QT_NO_OPENGL
  19. QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
  20. #endif
  21. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
  22. QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache, true);
  23. // Set application attributes
  24. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  25. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
  26. QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
  27. #endif
  28. QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true);
  29. QApplication a(argc, argv);
  30. a.setApplicationVersion("2.0");
  31. a.setApplicationName("ExpertClient");
  32. a.setApplicationDisplayName("伪装防护评估系统软件");
  33. QFont font;
  34. font.setPointSize(14);
  35. a.setFont(font);
  36. Q_INIT_RESOURCE(qfluentwidgets);
  37. QTranslator *translator = new QTranslator();
  38. translator->load(QLocale::system(), ":/resource/i18n/qfluentwidgets_zh.qm");
  39. QCoreApplication::installTranslator(translator);
  40. QIcon icon = QIcon(":/resource/logo.png");
  41. a.setWindowIcon(icon);
  42. int roleType = EXConfig::roleType();
  43. if (roleType != QFUser::SuperAdmin) {
  44. bool result = FileUtil().importEngineerFile();
  45. if (result) {
  46. ImportDataUtil().importSystemData();
  47. EXLoginWidget w;
  48. // 居中显示窗体
  49. w.move((QApplication::primaryScreen()->availableGeometry().width() - w.width()) / 2,
  50. (QApplication::primaryScreen()->availableGeometry().height() - w.height()) / 2);
  51. w.show();
  52. return a.exec();
  53. } else {
  54. qApp->exit();
  55. }
  56. }
  57. return 0;
  58. }