2009-03-01 08:38:21 +01:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2012-01-01 00:05:37 +01:00
|
|
|
* Copyright (C) 2007-2012 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>
|
2009-07-02 10:32:29 +02:00
|
|
|
#include <QTranslator>
|
2010-07-11 00:04:53 +02:00
|
|
|
#include <QMetaType>
|
2011-04-07 15:07:55 +02:00
|
|
|
#include <QStringList>
|
|
|
|
#include <iostream>
|
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()
|
|
|
|
{
|
|
|
|
std::cout << "Cppcheck GUI.\n\n";
|
|
|
|
std::cout << "Syntax:\n";
|
|
|
|
std::cout << " cppcheck-gui [OPTIONS] [files or paths]\n\n";
|
|
|
|
std::cout << "Options:\n";
|
|
|
|
std::cout << " -h, --help Print this help\n";
|
|
|
|
std::cout << " -p <file> Open given project file and start checking it\n";
|
|
|
|
}
|