summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-04-18 11:07:45 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2019-04-25 08:46:51 +0000
commitdfeb0245838f0709e845ed264f343e4ac0bb2bfe (patch)
treef4b8eb56f06a49fd051d418d050d8ec8611bd824
parent09df30396f6b5ef13ca810a728363716d257745f (diff)
downloadqt-creator-dfeb0245838f0709e845ed264f343e4ac0bb2bfe.tar.gz
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>
-rw-r--r--share/qtcreator/templates/wizards/files/cppheader/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/cppsource/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/form/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json2
-rw-r--r--share/qtcreator/templates/wizards/files/qrc/wizard.json2
-rw-r--r--src/plugins/cpptools/cpptoolsjsextension.cpp43
-rw-r--r--src/plugins/cpptools/cpptoolsjsextension.h4
10 files changed, 30 insertions, 33 deletions
diff --git a/share/qtcreator/templates/wizards/files/cppheader/wizard.json b/share/qtcreator/templates/wizards/files/cppheader/wizard.json
index bda6770d09..94718b35d4 100644
--- a/share/qtcreator/templates/wizards/files/cppheader/wizard.json
+++ b/share/qtcreator/templates/wizards/files/cppheader/wizard.json
@@ -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" :
[
diff --git a/share/qtcreator/templates/wizards/files/cppsource/wizard.json b/share/qtcreator/templates/wizards/files/cppsource/wizard.json
index 7eebc282b5..88a2b8d7ef 100644
--- a/share/qtcreator/templates/wizards/files/cppsource/wizard.json
+++ b/share/qtcreator/templates/wizards/files/cppsource/wizard.json
@@ -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" :
[
diff --git a/share/qtcreator/templates/wizards/files/form/wizard.json b/share/qtcreator/templates/wizards/files/form/wizard.json
index 26d15d2b59..b098ff6923 100644
--- a/share/qtcreator/templates/wizards/files/form/wizard.json
+++ b/share/qtcreator/templates/wizards/files/form/wizard.json
@@ -41,7 +41,7 @@
"data":
{
"source": "file.ui",
- "target": "%{JS: Cpp.fileName('%{TargetPath}', '%{Extension}')}",
+ "target": "%{JS: Util.fileName('%{TargetPath}', '%{Extension}')}",
"openInEditor": true
}
}
diff --git a/share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json b/share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json
index eb5e994782..9f71526851 100644
--- a/share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json
+++ b/share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json
@@ -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
}
}
diff --git a/share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json b/share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json
index bd76a76d6b..a8024cf059 100644
--- a/share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json
+++ b/share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json
@@ -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
}
}
diff --git a/share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json b/share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json
index c95b336aea..bbaf2d0129 100644
--- a/share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json
+++ b/share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json
@@ -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
}
}
diff --git a/share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json b/share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json
index 68d430d29d..59865e7b55 100644
--- a/share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json
+++ b/share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json
@@ -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
}
}
diff --git a/share/qtcreator/templates/wizards/files/qrc/wizard.json b/share/qtcreator/templates/wizards/files/qrc/wizard.json
index bbbd8e98f9..ccf8a4fea8 100644
--- a/share/qtcreator/templates/wizards/files/qrc/wizard.json
+++ b/share/qtcreator/templates/wizards/files/qrc/wizard.json
@@ -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
}
}
diff --git a/src/plugins/cpptools/cpptoolsjsextension.cpp b/src/plugins/cpptools/cpptoolsjsextension.cpp
index 2d3b7f01ea..c1e98fcccc 100644
--- a/src/plugins/cpptools/cpptoolsjsextension.cpp
+++ b/src/plugins/cpptools/cpptoolsjsextension.cpp
@@ -38,33 +38,16 @@
namespace CppTools {
namespace Internal {
-QString CppToolsJsExtension::headerGuard(const QString &in) const
+static QString fileName(const QString &path, const QString &extension)
{
- return Utils::headerGuard(in);
+ return Utils::FileName::fromStringWithExtension(path, extension).toString();
}
-QString CppToolsJsExtension::fileName(const QString &path, const QString &extension) const
+QString CppToolsJsExtension::headerGuard(const QString &in) 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;
+ return Utils::headerGuard(in);
}
-
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
diff --git a/src/plugins/cpptools/cpptoolsjsextension.h b/src/plugins/cpptools/cpptoolsjsextension.h
index 16a4010f78..cc9dd08d9e 100644
--- a/src/plugins/cpptools/cpptoolsjsextension.h
+++ b/src/plugins/cpptools/cpptoolsjsextension.h
@@ -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;