| 46 | static bool CheckArgs(const QStringList &args); |
| 47 | |
| 48 | int main(int argc, char *argv[]) |
| 49 | { |
| 50 | QApplication app(argc, argv); |
| 51 | |
| 52 | QCoreApplication::setOrganizationName("Cppcheck"); |
| 53 | QCoreApplication::setApplicationName("Cppcheck-GUI"); |
| 54 | |
| 55 | auto* settings = new QSettings("Cppcheck", "Cppcheck-GUI", &app); |
| 56 | |
| 57 | // Set data dir.. |
| 58 | const QStringList args = QApplication::arguments(); |
| 59 | auto it = std::find_if(args.cbegin(), args.cend(), [](const QString& arg) { |
| 60 | return arg.startsWith("--data-dir="); |
| 61 | }); |
| 62 | if (it != args.end()) { |
| 63 | settings->setValue("DATADIR", it->mid(11)); |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | auto* th = new TranslationHandler(&app); |
| 68 | th->setLanguage(settings->value(SETTINGS_LANGUAGE, th->suggestLanguage()).toString()); |
| 69 | |
| 70 | if (!CheckArgs(QApplication::arguments())) |
| 71 | return 0; |
| 72 | |
| 73 | QApplication::setWindowIcon(QIcon(":cppcheck-gui.png")); |
| 74 | |
| 75 | // Register this metatype that is used to transfer error info |
| 76 | qRegisterMetaType<ErrorItem>("ErrorItem"); |
| 77 | |
| 78 | MainWindow window(th, settings); |
| 79 | window.show(); |
| 80 | return QApplication::exec(); |
| 81 | } |
| 82 | |
| 83 | // Check only arguments needing action before GUI is shown. |
| 84 | // Rest of the arguments are handled in MainWindow::HandleCLIParams() |
nothing calls this directly
no test coverage detected