cppcheck.cfg: support custom productname and about message
This commit is contained in:
parent
4c650289ad
commit
635059603a
|
@ -894,6 +894,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||||
else if (std::strcmp(argv[i], "--version") == 0) {
|
else if (std::strcmp(argv[i], "--version") == 0) {
|
||||||
mShowVersion = true;
|
mShowVersion = true;
|
||||||
mExitAfterPrint = true;
|
mExitAfterPrint = true;
|
||||||
|
mSettings->loadCppcheckCfg();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,12 +109,16 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
if (parser.getShowVersion() && !parser.getShowErrorMessages()) {
|
if (parser.getShowVersion() && !parser.getShowErrorMessages()) {
|
||||||
const char * const extraVersion = CppCheck::extraVersion();
|
if (!settings.cppcheckCfgProductName.empty()) {
|
||||||
if (*extraVersion != 0)
|
std::cout << settings.cppcheckCfgProductName << std::endl;
|
||||||
std::cout << "Cppcheck " << CppCheck::version() << " ("
|
} else {
|
||||||
<< extraVersion << ')' << std::endl;
|
const char * const extraVersion = CppCheck::extraVersion();
|
||||||
else
|
if (*extraVersion != 0)
|
||||||
std::cout << "Cppcheck " << CppCheck::version() << std::endl;
|
std::cout << "Cppcheck " << CppCheck::version() << " ("
|
||||||
|
<< extraVersion << ')' << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "Cppcheck " << CppCheck::version() << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.getShowErrorMessages()) {
|
if (parser.getShowErrorMessages()) {
|
||||||
|
|
|
@ -67,6 +67,13 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
||||||
mExiting(false),
|
mExiting(false),
|
||||||
mIsLogfileLoaded(false)
|
mIsLogfileLoaded(false)
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
Settings tempSettings;
|
||||||
|
tempSettings.loadCppcheckCfg();
|
||||||
|
mCppcheckCfgProductName = QString::fromStdString(tempSettings.cppcheckCfgProductName);
|
||||||
|
mCppcheckCfgAbout = QString::fromStdString(tempSettings.cppcheckCfgAbout);
|
||||||
|
}
|
||||||
|
|
||||||
mUI.setupUi(this);
|
mUI.setupUi(this);
|
||||||
mThread = new ThreadHandler(this);
|
mThread = new ThreadHandler(this);
|
||||||
mThread->setDataDir(getDataDir());
|
mThread->setDataDir(getDataDir());
|
||||||
|
@ -1356,8 +1363,18 @@ void MainWindow::toggleAllChecked(bool checked)
|
||||||
|
|
||||||
void MainWindow::about()
|
void MainWindow::about()
|
||||||
{
|
{
|
||||||
AboutDialog *dlg = new AboutDialog(CppCheck::version(), CppCheck::extraVersion(), this);
|
if (!mCppcheckCfgAbout.isEmpty()) {
|
||||||
dlg->exec();
|
QMessageBox msg(QMessageBox::Information,
|
||||||
|
tr("About"),
|
||||||
|
mCppcheckCfgAbout,
|
||||||
|
QMessageBox::Ok,
|
||||||
|
this);
|
||||||
|
msg.exec();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AboutDialog *dlg = new AboutDialog(CppCheck::version(), CppCheck::extraVersion(), this);
|
||||||
|
dlg->exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showLicense()
|
void MainWindow::showLicense()
|
||||||
|
@ -1445,6 +1462,9 @@ void MainWindow::formatAndSetTitle(const QString &text)
|
||||||
nameWithVersion += " (" + extraVersion + ")";
|
nameWithVersion += " (" + extraVersion + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mCppcheckCfgProductName.isEmpty())
|
||||||
|
nameWithVersion = mCppcheckCfgProductName;
|
||||||
|
|
||||||
QString title;
|
QString title;
|
||||||
if (text.isEmpty())
|
if (text.isEmpty())
|
||||||
title = nameWithVersion;
|
title = nameWithVersion;
|
||||||
|
|
|
@ -472,6 +472,9 @@ private:
|
||||||
* List of MRU menu actions. Needs also to store the separator.
|
* List of MRU menu actions. Needs also to store the separator.
|
||||||
*/
|
*/
|
||||||
QAction *mRecentProjectActs[MaxRecentProjects + 1];
|
QAction *mRecentProjectActs[MaxRecentProjects + 1];
|
||||||
|
|
||||||
|
QString mCppcheckCfgAbout;
|
||||||
|
QString mCppcheckCfgProductName;
|
||||||
};
|
};
|
||||||
/// @}
|
/// @}
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -92,6 +92,10 @@ void Settings::loadCppcheckCfg(const std::string &executable)
|
||||||
if (!picojson::get_last_error().empty())
|
if (!picojson::get_last_error().empty())
|
||||||
return;
|
return;
|
||||||
picojson::object obj = json.get<picojson::object>();
|
picojson::object obj = json.get<picojson::object>();
|
||||||
|
if (obj.count("productName") && obj["productName"].is<std::string>())
|
||||||
|
cppcheckCfgProductName = obj["productName"].get<std::string>();
|
||||||
|
if (obj.count("about") && obj["about"].is<std::string>())
|
||||||
|
cppcheckCfgAbout = obj["about"].get<std::string>();
|
||||||
if (obj.count("addons") && obj["addons"].is<picojson::array>()) {
|
if (obj.count("addons") && obj["addons"].is<picojson::array>()) {
|
||||||
for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
|
for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
|
||||||
const std::string &s = v.get<std::string>();
|
const std::string &s = v.get<std::string>();
|
||||||
|
|
|
@ -156,6 +156,12 @@ public:
|
||||||
/** @brief include paths excluded from checking the configuration */
|
/** @brief include paths excluded from checking the configuration */
|
||||||
std::set<std::string> configExcludePaths;
|
std::set<std::string> configExcludePaths;
|
||||||
|
|
||||||
|
/** cppcheck.cfg: Custom product name */
|
||||||
|
std::string cppcheckCfgProductName;
|
||||||
|
|
||||||
|
/** cppcheck.cfg: About text */
|
||||||
|
std::string cppcheckCfgAbout;
|
||||||
|
|
||||||
/** @brief Are we running from DACA script? */
|
/** @brief Are we running from DACA script? */
|
||||||
bool daca;
|
bool daca;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue