28 #include <QMessageBox> 
   35 #include <QApplication> 
   36 #include <QCoreApplication> 
   40 #include <QStringList> 
   46 static bool CheckArgs(
const QStringList &args);
 
   48 int main(
int argc, 
char *argv[])
 
   51 #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) 
   52     QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
 
   53     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
 
   56     QApplication app(argc, argv);
 
   58     QCoreApplication::setOrganizationName(
"Cppcheck");
 
   59     QCoreApplication::setApplicationName(
"Cppcheck-GUI");
 
   61     auto* settings = 
new QSettings(
"Cppcheck", 
"Cppcheck-GUI", &app);
 
   64     const QStringList args = QApplication::arguments();
 
   65     auto it = std::find_if(args.cbegin(), args.cend(), [](
const QString& arg) {
 
   66         return arg.startsWith(
"--data-dir=");
 
   68     if (it != args.end()) {
 
   69         settings->setValue(
"DATADIR", it->mid(11));
 
   74     th->setLanguage(settings->value(
SETTINGS_LANGUAGE, th->suggestLanguage()).toString());
 
   76     if (!
CheckArgs(QApplication::arguments()))
 
   79     QApplication::setWindowIcon(QIcon(
":cppcheck-gui.png"));
 
   82     qRegisterMetaType<ErrorItem>(
"ErrorItem");
 
   86     return QApplication::exec();
 
   93     if (args.contains(
"-h") || args.contains(
"--help")) {
 
   97     if (args.contains(
"-v") || args.contains(
"--version")) {
 
  106     QString helpMessage = MainWindow::tr(
 
  109         "    cppcheck-gui [OPTIONS] [files or paths]\n\n" 
  111         "    -h, --help              Print this help\n" 
  112         "    -p <file>               Open given project file and start checking it\n" 
  113         "    -l <file>               Open given results xml file\n" 
  114         "    -d <directory>          Specify the directory that was checked to generate the results xml specified with -l\n" 
  115         "    -v, --version           Show program version\n" 
  116         "    --data-dir=<directory>  This option is for installation scripts so they can configure the directory where\n" 
  117         "                            datafiles are located (translations, cfg). The GUI is not started when this option\n" 
  120     QMessageBox msgBox(QMessageBox::Information,
 
  121                        MainWindow::tr(
"Cppcheck GUI - Command line parameters"),
 
  127     std::cout << helpMessage.toStdString() << std::endl;
 
  138     std::string versionMessage(
"Cppcheck ");
 
  141     if (*extraVersion != 0)
 
  142         versionMessage += std::string(
" (") + extraVersion + 
")";
 
  144     std::cout << versionMessage << std::endl;
 
static const char * version()
Returns current version number as a string.
 
static const char * extraVersion()
Returns extra version info as a string.
 
Main window for cppcheck-gui.
 
A class handling the available translations.
 
#define SETTINGS_LANGUAGE
 
int main(int argc, char *argv[])
 
static bool CheckArgs(const QStringList &args)
 
static void ShowVersion()