main.cpp 963 B

123456789101112131415161718192021222324252627282930313233
  1. #include <QCoreApplication>
  2. #include <QLocale>
  3. #include <QTranslator>
  4. #include "DataManager.h"
  5. #include <QCommandLineParser>
  6. #include <QCommandLineOption>
  7. #include "Config.h"
  8. int main(int argc, char *argv[])
  9. {
  10. QCoreApplication a(argc, argv);
  11. QTranslator translator;
  12. const QStringList uiLanguages = QLocale::system().uiLanguages();
  13. for (const QString &locale : uiLanguages) {
  14. const QString baseName = "DataManager_" + QLocale(locale).name();
  15. if (translator.load(":/i18n/" + baseName)) {
  16. a.installTranslator(&translator);
  17. break;
  18. }
  19. }
  20. QCommandLineOption op1("config","config file path","config[filepath]", "config/config.json");
  21. QCommandLineParser parser;
  22. parser.addOption(op1);
  23. parser.addHelpOption();
  24. parser.process(a);
  25. Config config(parser.value("config"));
  26. DataManager dataMgr;
  27. dataMgr.Startup(config);
  28. return a.exec();
  29. }