Wizards: Support using #pragma once instead of include guards

Allow users to choose #pragma once instead of #ifndef include guards in
generated header files.

Fixes: QTCREATORBUG-12166
Change-Id: I3ba41c7570beb9c5958e174b5581fcc25855050f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Filip Bucek <fbucek@atlas.cz>
This commit is contained in:
Filip Bucek
2019-01-03 10:56:36 +01:00
parent 2781c2a900
commit aaa8beab88
31 changed files with 235 additions and 52 deletions

View File

@@ -140,6 +140,11 @@ QString CppToolsPlugin::licenseTemplate()
return m_instance->m_fileSettings->licenseTemplate();
}
bool CppToolsPlugin::usePragmaOnce()
{
return m_instance->m_fileSettings->headerPragmaOnce;
}
const QStringList &CppToolsPlugin::headerSearchPaths()
{
return m_instance->m_fileSettings->headerSearchPaths;
@@ -204,6 +209,11 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
tr("The configured path to the license template"),
[]() { return CppToolsPlugin::licenseTemplatePath().toString(); });
expander->registerVariable(
"Cpp:PragmaOnce",
tr("Insert #pragma once instead of #ifndef include guards into header file"),
[] { return usePragmaOnce() ? QString("true") : QString(); });
return true;
}