GUI: Refactoring handling of setting for c++/c std

This commit is contained in:
Daniel Marjamäki 2019-04-12 12:12:12 +02:00
parent f7be03fcbc
commit d7e08ce75f
3 changed files with 32 additions and 37 deletions

View File

@ -170,6 +170,9 @@ void CheckThread::runAddonsAndTools(const ImportProject::FileSettings *fileSetti
case Standards::CPP14: case Standards::CPP14:
args << "-std=c++14"; args << "-std=c++14";
break; break;
case Standards::CPP17:
args << "-std=c++17";
break;
}; };
} }

View File

@ -59,13 +59,8 @@
#define SETTINGS_SHOW_PORTABILITY "Show portability" #define SETTINGS_SHOW_PORTABILITY "Show portability"
// Standards support // Standards support
#define SETTINGS_STD_CPP03 "Platform CPP03" #define SETTINGS_STD_CPP "Standard CPP"
#define SETTINGS_STD_CPP11 "Platform CPP11" #define SETTINGS_STD_C "Standard C"
#define SETTINGS_STD_CPP14 "Platform CPP14"
#define SETTINGS_STD_CPP17 "Platform CPP17"
#define SETTINGS_STD_C89 "Platform C89"
#define SETTINGS_STD_C99 "Platform C99"
#define SETTINGS_STD_C11 "Platform C11"
// Language enforcement // Language enforcement
#define SETTINGS_ENFORCED_LANGUAGE "Enforced language" #define SETTINGS_ENFORCED_LANGUAGE "Enforced language"

View File

@ -282,20 +282,16 @@ void MainWindow::loadSettings()
mUI.mActionShowCppcheck->setChecked(true); mUI.mActionShowCppcheck->setChecked(true);
mUI.mActionShowClang->setChecked(true); mUI.mActionShowClang->setChecked(true);
const bool stdCpp03 = mSettings->value(SETTINGS_STD_CPP03, false).toBool(); Standards standards;
mUI.mActionCpp03->setChecked(stdCpp03); standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
const bool stdCpp11 = mSettings->value(SETTINGS_STD_CPP11, false).toBool(); mUI.mActionC89->setChecked(standards.c == Standards::C89);
mUI.mActionCpp11->setChecked(stdCpp11 && !stdCpp03); mUI.mActionC99->setChecked(standards.c == Standards::C99);
const bool stdCpp14 = mSettings->value(SETTINGS_STD_CPP14, false).toBool(); mUI.mActionC11->setChecked(standards.c == Standards::C11);
mUI.mActionCpp14->setChecked(stdCpp14 && !stdCpp03 && !stdCpp11); standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString());
const bool stdCpp17 = mSettings->value(SETTINGS_STD_CPP17, true).toBool(); mUI.mActionCpp03->setChecked(standards.cpp == Standards::CPP03);
mUI.mActionCpp17->setChecked(stdCpp17 && !stdCpp03 && !stdCpp11 && !stdCpp14); mUI.mActionCpp11->setChecked(standards.cpp == Standards::CPP11);
const bool stdC89 = mSettings->value(SETTINGS_STD_C89, false).toBool(); mUI.mActionCpp14->setChecked(standards.cpp == Standards::CPP14);
mUI.mActionC89->setChecked(stdC89); mUI.mActionCpp17->setChecked(standards.cpp == Standards::CPP17);
const bool stdC11 = mSettings->value(SETTINGS_STD_C11, false).toBool();
mUI.mActionC11->setChecked(stdC11);
const bool stdC99 = mSettings->value(SETTINGS_STD_C99, true).toBool();
mUI.mActionC99->setChecked(stdC99 || (!stdC89 && !stdC11));
// Main window settings // Main window settings
const bool showMainToolbar = mSettings->value(SETTINGS_TOOLBARS_MAIN_SHOW, true).toBool(); const bool showMainToolbar = mSettings->value(SETTINGS_TOOLBARS_MAIN_SHOW, true).toBool();
@ -359,13 +355,21 @@ void MainWindow::saveSettings() const
mSettings->setValue(SETTINGS_SHOW_PERFORMANCE, mUI.mActionShowPerformance->isChecked()); mSettings->setValue(SETTINGS_SHOW_PERFORMANCE, mUI.mActionShowPerformance->isChecked());
mSettings->setValue(SETTINGS_SHOW_INFORMATION, mUI.mActionShowInformation->isChecked()); mSettings->setValue(SETTINGS_SHOW_INFORMATION, mUI.mActionShowInformation->isChecked());
mSettings->setValue(SETTINGS_STD_CPP03, mUI.mActionCpp03->isChecked()); if (mUI.mActionC89->isChecked())
mSettings->setValue(SETTINGS_STD_CPP11, mUI.mActionCpp11->isChecked()); mSettings->setValue(SETTINGS_STD_C, "C89");
mSettings->setValue(SETTINGS_STD_CPP14, mUI.mActionCpp14->isChecked()); if (mUI.mActionC99->isChecked())
mSettings->setValue(SETTINGS_STD_CPP17, mUI.mActionCpp17->isChecked()); mSettings->setValue(SETTINGS_STD_C, "C99");
mSettings->setValue(SETTINGS_STD_C89, mUI.mActionC89->isChecked()); if (mUI.mActionC11->isChecked())
mSettings->setValue(SETTINGS_STD_C99, mUI.mActionC99->isChecked()); mSettings->setValue(SETTINGS_STD_C, "C11");
mSettings->setValue(SETTINGS_STD_C11, mUI.mActionC11->isChecked());
if (mUI.mActionCpp03->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++03");
if (mUI.mActionCpp11->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++11");
if (mUI.mActionCpp14->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++14");
if (mUI.mActionCpp17->isChecked())
mSettings->setValue(SETTINGS_STD_CPP, "C++17");
// Main window settings // Main window settings
mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI.mToolBarMain->isVisible()); mSettings->setValue(SETTINGS_TOOLBARS_MAIN_SHOW, mUI.mToolBarMain->isVisible());
@ -926,15 +930,8 @@ Settings MainWindow::getCppcheckSettings()
result.inconclusive = mSettings->value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool(); result.inconclusive = mSettings->value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool();
if (result.platformType == cppcheck::Platform::Unspecified) if (result.platformType == cppcheck::Platform::Unspecified)
result.platform((cppcheck::Platform::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt()); result.platform((cppcheck::Platform::PlatformType) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt());
if (mSettings->value(SETTINGS_STD_CPP03, false).toBool()) result.standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString());
result.standards.cpp = Standards::CPP03; result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
else if (mSettings->value(SETTINGS_STD_CPP11, false).toBool())
result.standards.cpp = Standards::CPP11;
else if (mSettings->value(SETTINGS_STD_CPP14, false).toBool())
result.standards.cpp = Standards::CPP14;
else if (mSettings->value(SETTINGS_STD_CPP17, true).toBool())
result.standards.cpp = Standards::CPP17;
result.standards.c = mSettings->value(SETTINGS_STD_C99, true).toBool() ? Standards::C99 : (mSettings->value(SETTINGS_STD_C11, false).toBool() ? Standards::C11 : Standards::C89);
result.enforcedLang = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt(); result.enforcedLang = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
if (result.jobs <= 1) { if (result.jobs <= 1) {