Commit b38a9545 authored by Tobias Hunger's avatar Tobias Hunger

Old-style wizards: Handle line continuation in license templates

This is necessary to have the same template work in the old-style
wizards and the JSON wizard, which supports inserting \n, \t as well
as line continuation for everything.

Change-Id: I11c310998b92650003206484de8f1ecfc6000034
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <>
parent bd5becfe
......@@ -63,7 +63,30 @@ QString AbstractEditorSupport::licenseTemplate(const QString &file, const QStrin
expander.registerVariable("Cpp:License:ClassName", tr("The class name"),
[className]() { return className; });
return expander.expand(license);
QString out = expander.expand(license);
// Expand \n, \t and handle line continuation:
QString result;
bool isEscaped = false;
for (int i = 0; i < out.count(); ++i) {
const QChar c =;
if (isEscaped) {
if (c == QLatin1Char('n'))
else if (c == QLatin1Char('t'))
else if (c != QLatin1Char('\n'))
isEscaped = false;
} else {
if (c == QLatin1Char('\\'))
isEscaped = true;
return result;
} // namespace CppTools
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment