MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / main

Function main

gui/main.cpp:48–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46static bool CheckArgs(const QStringList &args);
47
48int 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()

Callers

nothing calls this directly

Calls 9

CheckArgsFunction · 0.85
startsWithMethod · 0.80
suggestLanguageMethod · 0.80
endMethod · 0.45
setValueMethod · 0.45
setLanguageMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected