| 54 | } |
| 55 | |
| 56 | int main(int argc, char *argv[]) |
| 57 | { |
| 58 | Q_INIT_RESOURCE(qhexedit); |
| 59 | QApplication app(argc, argv); |
| 60 | |
| 61 | QCoreApplication::setApplicationName("QHexEdit"); |
| 62 | QCoreApplication::setApplicationVersion(QT_VERSION_STR); |
| 63 | app.setOrganizationName("QHexEdit"); |
| 64 | app.setWindowIcon(QIcon(":images/qhexedit.ico")); |
| 65 | |
| 66 | QTranslator translator_app; |
| 67 | if (translator_app.load(QLocale(), "qhexedit", "_", ":/translations")) |
| 68 | QCoreApplication::installTranslator(&translator_app); |
| 69 | |
| 70 | QTranslator translator_qt; |
| 71 | |
| 72 | #if QT_VERSION < 0x060000 |
| 73 | QString path = QLibraryInfo::location(QLibraryInfo::TranslationsPath); |
| 74 | #else |
| 75 | QString path = QLibraryInfo::path(QLibraryInfo::TranslationsPath); |
| 76 | #endif |
| 77 | |
| 78 | if (translator_qt.load(QLocale(), "qt", "_", path)) |
| 79 | QCoreApplication::installTranslator(&translator_qt); |
| 80 | |
| 81 | QCommandLineParser parser; |
| 82 | parser.setApplicationDescription(QCoreApplication::translate("QHexEdit", "A hex editor application")); |
| 83 | |
| 84 | MainWindow *mainWin = new MainWindow; |
| 85 | |
| 86 | ParsedOptions query; |
| 87 | using Status = CommandLineParseResult::Status; |
| 88 | CommandLineParseResult parseResult = parseCommandLine(parser, &query); |
| 89 | |
| 90 | switch (parseResult.statusCode) { |
| 91 | case Status::Ok: |
| 92 | break; |
| 93 | |
| 94 | case Status::Error: |
| 95 | std::fputs(qPrintable(parseResult.errorString.value_or("Unknown error occurred")), stderr); |
| 96 | std::fputs("\n\n", stderr); |
| 97 | std::fputs(qPrintable(parser.helpText()), stderr); |
| 98 | return 1; |
| 99 | |
| 100 | case Status::VersionRequested: |
| 101 | parser.showVersion(); |
| 102 | return 0; |
| 103 | |
| 104 | case Status::HelpRequested: |
| 105 | parser.showHelp(); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | if (query.hasFile) |
| 110 | mainWin->loadFile(query.file); |
| 111 | |
| 112 | mainWin->show(); |
| 113 |
nothing calls this directly
no test coverage detected