forked from qt-creator/qt-creator
C++: Do not apply "Lower-case file names" setting to file wizards
This setting is intended to derive file names from class names. It is not relevant if the user explicitly provides a file name. Fixes: QTCREATORBUG-14711 Change-Id: Ic31f8727220d99692286adf9ad0434ce06aa7c62 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
"iconText": "h",
|
||||
"enabled": "%{JS: [ %{Plugins} ].indexOf('CppEditor') >= 0}",
|
||||
|
||||
"options": { "key": "FileName", "value": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
|
||||
"options": { "key": "FileName", "value": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-c++hdr')}')}" },
|
||||
|
||||
"pages" :
|
||||
[
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"iconText": "cpp",
|
||||
"enabled": "%{JS: [ %{Plugins} ].indexOf('CppEditor') >= 0}",
|
||||
|
||||
"options": { "key": "FileName", "value": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-c++src')}')}" },
|
||||
"options": { "key": "FileName", "value": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-c++src')}')}" },
|
||||
|
||||
"pages" :
|
||||
[
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"data":
|
||||
{
|
||||
"source": "file.ui",
|
||||
"target": "%{JS: Cpp.fileName('%{TargetPath}', '%{Extension}')}",
|
||||
"target": "%{JS: Util.fileName('%{TargetPath}', '%{Extension}')}",
|
||||
"openInEditor": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"data":
|
||||
{
|
||||
"source": "file.frag",
|
||||
"target": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-frag')}')}",
|
||||
"target": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-frag')}')}",
|
||||
"openInEditor": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"data":
|
||||
{
|
||||
"source": "file.vert",
|
||||
"target": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-vert')}')}",
|
||||
"target": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-vert')}')}",
|
||||
"openInEditor": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"data":
|
||||
{
|
||||
"source": "file.fsh",
|
||||
"target": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-es-frag')}')}",
|
||||
"target": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-es-frag')}')}",
|
||||
"openInEditor": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"data":
|
||||
{
|
||||
"source": "file.vsh",
|
||||
"target": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-es-vert')}')}",
|
||||
"target": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/x-glsl-es-vert')}')}",
|
||||
"openInEditor": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"data":
|
||||
{
|
||||
"source": "file.qrc",
|
||||
"target": "%{JS: Cpp.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('application/vnd.qt.xml.resource')}')}",
|
||||
"target": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('application/vnd.qt.xml.resource')}')}",
|
||||
"openInEditor": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,33 +38,16 @@
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
static QString fileName(const QString &path, const QString &extension)
|
||||
{
|
||||
return Utils::FileName::fromStringWithExtension(path, extension).toString();
|
||||
}
|
||||
|
||||
QString CppToolsJsExtension::headerGuard(const QString &in) const
|
||||
{
|
||||
return Utils::headerGuard(in);
|
||||
}
|
||||
|
||||
QString CppToolsJsExtension::fileName(const QString &path, const QString &extension) const
|
||||
{
|
||||
QString raw = Utils::FileName::fromStringWithExtension(path, extension).toString();
|
||||
CppFileSettings settings;
|
||||
settings.fromSettings(Core::ICore::settings());
|
||||
if (!settings.lowerCaseFiles)
|
||||
return raw;
|
||||
|
||||
QFileInfo fi = QFileInfo(raw);
|
||||
QString finalPath = fi.path();
|
||||
if (finalPath == QStringLiteral("."))
|
||||
finalPath.clear();
|
||||
if (!finalPath.isEmpty() && !finalPath.endsWith(QLatin1Char('/')))
|
||||
finalPath += QLatin1Char('/');
|
||||
QString name = fi.baseName().toLower();
|
||||
QString ext = fi.completeSuffix();
|
||||
if (!ext.isEmpty())
|
||||
ext = QString(QLatin1Char('.')) + ext;
|
||||
return finalPath + name + ext;
|
||||
}
|
||||
|
||||
|
||||
static QStringList parts(const QString &klass)
|
||||
{
|
||||
return klass.split(QStringLiteral("::"));
|
||||
@@ -85,7 +68,23 @@ QString CppToolsJsExtension::className(const QString &klass) const
|
||||
|
||||
QString CppToolsJsExtension::classToFileName(const QString &klass, const QString &extension) const
|
||||
{
|
||||
return fileName(className(klass), extension);
|
||||
const QString raw = fileName(className(klass), extension);
|
||||
CppFileSettings settings;
|
||||
settings.fromSettings(Core::ICore::settings());
|
||||
if (!settings.lowerCaseFiles)
|
||||
return raw;
|
||||
|
||||
QFileInfo fi = QFileInfo(raw);
|
||||
QString finalPath = fi.path();
|
||||
if (finalPath == QStringLiteral("."))
|
||||
finalPath.clear();
|
||||
if (!finalPath.isEmpty() && !finalPath.endsWith(QLatin1Char('/')))
|
||||
finalPath += QLatin1Char('/');
|
||||
QString name = fi.baseName().toLower();
|
||||
QString ext = fi.completeSuffix();
|
||||
if (!ext.isEmpty())
|
||||
ext = QString(QLatin1Char('.')) + ext;
|
||||
return finalPath + name + ext;
|
||||
}
|
||||
|
||||
QString CppToolsJsExtension::classToHeaderGuard(const QString &klass, const QString &extension) const
|
||||
|
||||
@@ -45,12 +45,10 @@ public:
|
||||
// Generate header guard:
|
||||
Q_INVOKABLE QString headerGuard(const QString &in) const;
|
||||
|
||||
// Fix the filename casing as configured in C++/File Naming:
|
||||
Q_INVOKABLE QString fileName(const QString &path, const QString &extension) const;
|
||||
|
||||
// Work with classes:
|
||||
Q_INVOKABLE QStringList namespaces(const QString &klass) const;
|
||||
Q_INVOKABLE QString className(const QString &klass) const;
|
||||
// Fix the filename casing as configured in C++/File Naming:
|
||||
Q_INVOKABLE QString classToFileName(const QString &klass,
|
||||
const QString &extension) const;
|
||||
Q_INVOKABLE QString classToHeaderGuard(const QString &klass, const QString &extension) const;
|
||||
|
||||
Reference in New Issue
Block a user