2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2013-01-01 17:29:08 +01:00
|
|
|
* Copyright (C) 2007-2013 Daniel Marjamäki and Cppcheck team.
|
2009-03-01 08:38:21 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-09-27 17:08:31 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-03-01 08:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
2011-05-13 09:09:17 +02:00
|
|
|
#include <QCoreApplication>
|
2009-06-06 09:51:50 +02:00
|
|
|
#include <QTextCodec>
|
2010-07-11 00:04:53 +02:00
|
|
|
#include <QMetaType>
|
2011-04-07 15:07:55 +02:00
|
|
|
#include <QStringList>
|
2012-10-06 12:19:01 +02:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <QMessageBox>
|
|
|
|
#else
|
2011-04-07 15:07:55 +02:00
|
|
|
#include <iostream>
|
2012-10-06 12:19:01 +02:00
|
|
|
#endif
|
2009-03-01 08:38:21 +01:00
|
|
|
#include "mainwindow.h"
|
2010-07-14 13:24:46 +02:00
|
|
|
#include "erroritem.h"
|
2009-03-01 08:38:21 +01:00
|
|
|
|
2011-04-07 15:07:55 +02:00
|
|
|
void ShowUsage();
|
|
|
|
bool CheckArgs(const QStringList &args);
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QApplication app(argc, argv);
|
2011-04-07 15:07:55 +02:00
|
|
|
|
|
|
|
if (!CheckArgs(app.arguments()))
|
|
|
|
return 0;
|
|
|
|
|
2011-05-13 09:09:17 +02:00
|
|
|
QCoreApplication::setOrganizationName("Cppcheck");
|
|
|
|
QCoreApplication::setApplicationName("Cppcheck-GUI");
|
|
|
|
|
2009-05-28 10:32:32 +02:00
|
|
|
app.setWindowIcon(QIcon(":icon.png"));
|
2009-05-25 15:00:42 +02:00
|
|
|
|
2010-07-11 00:04:53 +02:00
|
|
|
// Register this metatype that is used to transfer error info
|
2010-07-14 13:24:46 +02:00
|
|
|
qRegisterMetaType<ErrorItem>("ErrorItem");
|
2010-07-11 00:04:53 +02:00
|
|
|
|
2009-06-06 09:51:50 +02:00
|
|
|
// Set codecs so that UTF-8 strings in sources are handled correctly.
|
|
|
|
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
|
|
|
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
|
|
|
|
2009-03-01 08:38:21 +01:00
|
|
|
MainWindow window;
|
|
|
|
window.show();
|
|
|
|
return app.exec();
|
|
|
|
}
|
2011-04-07 15:07:55 +02:00
|
|
|
|
|
|
|
// Check only arguments needing action before GUI is shown.
|
|
|
|
// Rest of the arguments are handled in MainWindow::HandleCLIParams()
|
|
|
|
bool CheckArgs(const QStringList &args)
|
|
|
|
{
|
2011-10-13 20:53:06 +02:00
|
|
|
if (args.contains("-h") || args.contains("--help")) {
|
2011-04-07 15:07:55 +02:00
|
|
|
ShowUsage();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowUsage()
|
|
|
|
{
|
2012-09-26 20:26:46 +02:00
|
|
|
const char helpMessage[] =
|
|
|
|
"Cppcheck GUI.\n\n"
|
|
|
|
"Syntax:\n"
|
|
|
|
" cppcheck-gui [OPTIONS] [files or paths]\n\n"
|
|
|
|
"Options:\n"
|
|
|
|
" -h, --help Print this help\n"
|
|
|
|
" -p <file> Open given project file and start checking it\n";
|
|
|
|
#if defined(_WIN32)
|
|
|
|
QMessageBox msgBox(QMessageBox::Information,
|
|
|
|
"Cppcheck GUI",
|
|
|
|
helpMessage,
|
|
|
|
QMessageBox::Ok
|
|
|
|
);
|
|
|
|
(void)msgBox.exec();
|
|
|
|
#else
|
|
|
|
std::cout << helpMessage;
|
|
|
|
#endif
|
2011-04-07 15:07:55 +02:00
|
|
|
}
|