diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp index c1e49a4a1b0..3733f668cc5 100644 --- a/src/plugins/cpptools/abstracteditorsupport.cpp +++ b/src/plugins/cpptools/abstracteditorsupport.cpp @@ -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; + result.reserve(out.count()); + bool isEscaped = false; + for (int i = 0; i < out.count(); ++i) { + const QChar c = out.at(i); + + if (isEscaped) { + if (c == QLatin1Char('n')) + result.append(QLatin1Char('\n')); + else if (c == QLatin1Char('t')) + result.append(QLatin1Char('\t')); + else if (c != QLatin1Char('\n')) + result.append(c); + isEscaped = false; + } else { + if (c == QLatin1Char('\\')) + isEscaped = true; + else + result.append(c); + } + } + return result; } } // namespace CppTools