diff --git a/share/qtcreator/templates/wizards/files/cppheader/wizard.json b/share/qtcreator/templates/wizards/files/cppheader/wizard.json index efb0ea81190..6d4de509757 100644 --- a/share/qtcreator/templates/wizards/files/cppheader/wizard.json +++ b/share/qtcreator/templates/wizards/files/cppheader/wizard.json @@ -9,7 +9,10 @@ "iconText": "h", "enabled": "%{JS: value('Plugins').indexOf('CppEditor') >= 0}", - "options": { "key": "FileName", "value": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-c++hdr'))}" }, + "options": [ + { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-c++hdr')}" }, + { "key": "FileName", "value": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}" } + ], "pages" : [ diff --git a/share/qtcreator/templates/wizards/files/cppsource/wizard.json b/share/qtcreator/templates/wizards/files/cppsource/wizard.json index 775cd892ab0..e9af17a913c 100644 --- a/share/qtcreator/templates/wizards/files/cppsource/wizard.json +++ b/share/qtcreator/templates/wizards/files/cppsource/wizard.json @@ -9,7 +9,10 @@ "iconText": "cpp", "enabled": "%{JS: value('Plugins').indexOf('CppEditor') >= 0}", - "options": { "key": "FileName", "value": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-c++src'))}" }, + "options": [ + { "key": "FileName", "value": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}" }, + { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-c++src')}" } + ], "pages" : [ 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 900e4f8f68f..28a018945b2 100644 --- a/share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json +++ b/share/qtcreator/templates/wizards/files/glsl/gl/fragment/wizard.json @@ -10,6 +10,8 @@ "platformIndependent": true, "enabled": "%{JS: value('Plugins').indexOf('GLSLEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-glsl-frag')}" }, + "pages" : [ { @@ -30,7 +32,7 @@ "data": { "source": "file.frag", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-glsl-frag'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "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 38d2df2947b..48f1f68afde 100644 --- a/share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json +++ b/share/qtcreator/templates/wizards/files/glsl/gl/vertex/wizard.json @@ -10,6 +10,8 @@ "platformIndependent": true, "enabled": "%{JS: value('Plugins').indexOf('GLSLEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-glsl-vert')}" }, + "pages" : [ { @@ -30,7 +32,7 @@ "data": { "source": "file.vert", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-glsl-vert'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "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 a993a3cfcee..d636d0eb21c 100644 --- a/share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json +++ b/share/qtcreator/templates/wizards/files/glsl/gles/fragment/wizard.json @@ -10,6 +10,8 @@ "platformIndependent": true, "enabled": "%{JS: value('Plugins').indexOf('GLSLEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-glsl-es-frag')}" }, + "pages" : [ { @@ -30,7 +32,7 @@ "data": { "source": "file.fsh", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-glsl-es-frag'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "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 54231aadd51..83a042d91b6 100644 --- a/share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json +++ b/share/qtcreator/templates/wizards/files/glsl/gles/vertex/wizard.json @@ -10,6 +10,8 @@ "platformIndependent": true, "enabled": "%{JS: value('Plugins').indexOf('GLSLEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-glsl-es-vert')}" }, + "pages" : [ { @@ -30,7 +32,7 @@ "data": { "source": "file.vsh", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-glsl-es-vert'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/java/wizard.json b/share/qtcreator/templates/wizards/files/java/wizard.json index 5a8fae5dc16..ec1da4e164e 100644 --- a/share/qtcreator/templates/wizards/files/java/wizard.json +++ b/share/qtcreator/templates/wizards/files/java/wizard.json @@ -9,7 +9,10 @@ "iconText": "java", "enabled": "%{JS: value('Plugins').indexOf('Android') >= 0}", - "options": [ { "key": "ClassName", "value": "%{JS: value('FileName').charAt(0).toUpperCase() + value('FileName').substr(1).replace(/[.]java$/,'')}" } ], + "options": [ + { "key": "ClassName", "value": "%{JS: value('FileName').charAt(0).toUpperCase() + value('FileName').substr(1).replace(/[.]java$/,'')}" }. + { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-java')}" } + ], "pages" : [ @@ -31,7 +34,7 @@ "data": { "source": "source.java", - "target": "%{JS: Util.fileName(value('Path') + '/' + value('ClassName'), Util.preferredSuffix('text/x-java'))}", + "target": "%{JS: Util.fileName(value('Path') + '/' + value('ClassName'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/js/wizard.json b/share/qtcreator/templates/wizards/files/js/wizard.json index d47721bb464..505ca578170 100644 --- a/share/qtcreator/templates/wizards/files/js/wizard.json +++ b/share/qtcreator/templates/wizards/files/js/wizard.json @@ -9,6 +9,8 @@ "iconText": "js", "enabled": "%{JS: value('Plugins').indexOf('QmlJSEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('application/javascript')}" }, + "pages" : [ { @@ -47,7 +49,7 @@ "data": { "source": "file.js", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('application/javascript'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/nim/wizard.json b/share/qtcreator/templates/wizards/files/nim/wizard.json index 723531ced59..1baf376aa41 100644 --- a/share/qtcreator/templates/wizards/files/nim/wizard.json +++ b/share/qtcreator/templates/wizards/files/nim/wizard.json @@ -9,6 +9,8 @@ "icon": "../../projects/nim/icon.png", "enabled": "%{JS: value('Plugins').indexOf('Nim') >= 0}", + "options": { "key": "DefaultSuffix", "value": "nim" }, + "pages" : [ { @@ -29,7 +31,7 @@ "data": { "source": "file.nim", - "target": "%{JS: Util.fileName(value('TargetPath'), 'nim')}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/nimscript/wizard.json b/share/qtcreator/templates/wizards/files/nimscript/wizard.json index 15f366773b6..94012a7167f 100644 --- a/share/qtcreator/templates/wizards/files/nimscript/wizard.json +++ b/share/qtcreator/templates/wizards/files/nimscript/wizard.json @@ -9,6 +9,8 @@ "icon": "../../projects/nim/icon.png", "enabled": "%{JS: value('Plugins').indexOf('Nim') >= 0}", + "options": { "key": "DefaultSuffix", "value": "nims" }, + "pages" : [ { @@ -29,7 +31,7 @@ "data": { "source": "file.nims", - "target": "%{JS: Util.fileName(value('TargetPath'), 'nims')}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/python/wizard.json b/share/qtcreator/templates/wizards/files/python/wizard.json index f3bff037b51..a01e32bf4a6 100644 --- a/share/qtcreator/templates/wizards/files/python/wizard.json +++ b/share/qtcreator/templates/wizards/files/python/wizard.json @@ -9,6 +9,8 @@ "icon": "icon.png", "enabled": "%{JS: value('Plugins').indexOf('Python') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-python')}" }, + "pages" : [ { @@ -29,7 +31,7 @@ "data": { "source": "file.py", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-python'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/qrc/wizard.json b/share/qtcreator/templates/wizards/files/qrc/wizard.json index 578eed58a11..fe8ea73d172 100644 --- a/share/qtcreator/templates/wizards/files/qrc/wizard.json +++ b/share/qtcreator/templates/wizards/files/qrc/wizard.json @@ -9,6 +9,8 @@ "iconText": "qrc", "enabled": "%{JS: value('Plugins').indexOf('ResourceEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('application/vnd.qt.xml.resource')}" }, + "pages" : [ { @@ -29,7 +31,7 @@ "data": { "source": "file.qrc", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('application/vnd.qt.xml.resource'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/share/qtcreator/templates/wizards/files/qtquick2/wizard.json b/share/qtcreator/templates/wizards/files/qtquick2/wizard.json index ead52b16873..0fa070cf934 100644 --- a/share/qtcreator/templates/wizards/files/qtquick2/wizard.json +++ b/share/qtcreator/templates/wizards/files/qtquick2/wizard.json @@ -9,6 +9,8 @@ "iconText": "qml", "enabled": "%{JS: value('Plugins').indexOf('QmlJSEditor') >= 0}", + "options": { "key": "DefaultSuffix", "value": "%{JS: Util.preferredSuffix('text/x-qml')}" }, + "pages" : [ { @@ -29,7 +31,7 @@ "data": { "source": "file.qml.tpl", - "target": "%{JS: Util.fileName(value('TargetPath'), Util.preferredSuffix('text/x-qml'))}", + "target": "%{JS: Util.fileName(value('TargetPath'), value('DefaultSuffix'))}", "openInEditor": true } } diff --git a/src/libs/utils/filewizardpage.cpp b/src/libs/utils/filewizardpage.cpp index cd9f3b345b1..f4862292533 100644 --- a/src/libs/utils/filewizardpage.cpp +++ b/src/libs/utils/filewizardpage.cpp @@ -110,6 +110,19 @@ void FileWizardPage::setPathLabel(const QString &label) d->m_ui.pathLabel->setText(label); } +void FileWizardPage::setDefaultSuffix(const QString &suffix) +{ + if (suffix.isEmpty()) { + const auto layout = qobject_cast(this->layout()); + if (layout->rowCount() == 3) + layout->removeRow(0); + } else { + d->m_ui.defaultSuffixLabel->setText( + tr("The default suffix if you do not explicitly specify a file extension is \".%1\".") + .arg(suffix)); + } +} + bool FileWizardPage::forceFirstCapitalLetterForFileName() const { return d->m_ui.nameLineEdit->forceFirstCapitalLetter(); diff --git a/src/libs/utils/filewizardpage.h b/src/libs/utils/filewizardpage.h index ede6c4d3abb..0ce3287bef5 100644 --- a/src/libs/utils/filewizardpage.h +++ b/src/libs/utils/filewizardpage.h @@ -50,6 +50,7 @@ public: void setFileNameLabel(const QString &label); void setPathLabel(const QString &label); + void setDefaultSuffix(const QString &suffix); bool forceFirstCapitalLetterForFileName() const; void setForceFirstCapitalLetterForFileName(bool b); diff --git a/src/libs/utils/filewizardpage.ui b/src/libs/utils/filewizardpage.ui index e8b3ca1b4b9..9d3f09abe4b 100644 --- a/src/libs/utils/filewizardpage.ui +++ b/src/libs/utils/filewizardpage.ui @@ -6,34 +6,41 @@ 0 0 - 196 - 68 + 368 + 102 Choose the Location - + - Name: + File name: - + - + Path: - + + + + + + + + diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp index 865ee828655..19615f929ae 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfilepage.cpp @@ -45,6 +45,7 @@ void JsonFilePage::initializePage() setFileName(wiz->stringValue(QLatin1String("InitialFileName"))); if (path().isEmpty()) setPath(wiz->stringValue(QLatin1String("InitialPath"))); + setDefaultSuffix(wiz->stringValue("DefaultSuffix")); } bool JsonFilePage::validatePage()