1
0

main.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "mainwindow.h"
  2. #include <QCoreApplication>
  3. #include <QApplication>
  4. #include <QObject>
  5. #include <QSettings>
  6. #include <QTranslator>
  7. #include <QString>
  8. #include <QLocale>
  9. #include <QCommandLineParser>
  10. #include <QFileInfo>
  11. #ifdef _WEBBOX
  12. #include <QtWebEngine>
  13. #endif
  14. int main(int argc, char *argv[])
  15. {
  16. QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  17. QApplication a(argc, argv);
  18. a.setApplicationName("Qqsp");
  19. a.setOrganizationName("Qqsp");
  20. a.setApplicationVersion("1.6");
  21. a.setDoubleClickInterval(1);
  22. QObject::tr("__LANGNAME__");
  23. QObject::tr("__LANGID__");
  24. QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName());
  25. QTranslator qtTranslator;
  26. QString langid = settings.value("application/language", QLocale::system().name()).toString();
  27. if(qtTranslator.load(QApplication::applicationName() + "." + langid, QApplication::applicationDirPath()))
  28. a.installTranslator(&qtTranslator);
  29. else
  30. if(qtTranslator.load(QApplication::applicationName() + "." + langid, ":/translations/"))
  31. a.installTranslator(&qtTranslator);
  32. QCommandLineParser parser;
  33. parser.setApplicationDescription("Qqsp");
  34. parser.addPositionalArgument("file", QCoreApplication::translate("main", "Game file to open."));
  35. parser.addHelpOption();
  36. parser.addVersionOption();
  37. parser.process(a);
  38. #ifdef _WEBBOX
  39. QtWebEngine::initialize();
  40. #endif
  41. MainWindow w;
  42. if(parser.positionalArguments().size() != 0)
  43. {
  44. QFileInfo file(parser.positionalArguments().at(0));
  45. w.OpenGameFile(file.filePath());
  46. }
  47. w.show();
  48. return a.exec();
  49. }