From ac02f6fb89c5adcfaa2e9ebdc6ccd46be69d552f Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 30 Sep 2014 12:13:13 +0200 Subject: [PATCH] JsonWizard: Replace TextFileWizard with JsonWizard Change-Id: Iae2833554529c2f333d9781eb0f7fa28f3bfde79 Reviewed-by: Daniel Teske --- .../templates/wizards/files/text/file.txt | 0 .../templates/wizards/files/text/wizard.json | 38 +++++++++++++ src/plugins/glsleditor/glsleditorplugin.cpp | 1 - .../pythoneditor/wizard/pythonfilewizard.cpp | 1 - src/plugins/qmljseditor/qmljseditorplugin.cpp | 1 - src/plugins/texteditor/texteditor.pro | 2 - src/plugins/texteditor/texteditor.qbs | 2 - src/plugins/texteditor/texteditorplugin.cpp | 21 ------- src/plugins/texteditor/textfilewizard.cpp | 52 ----------------- src/plugins/texteditor/textfilewizard.h | 57 ------------------- 10 files changed, 38 insertions(+), 137 deletions(-) create mode 100644 share/qtcreator/templates/wizards/files/text/file.txt create mode 100644 share/qtcreator/templates/wizards/files/text/wizard.json delete mode 100644 src/plugins/texteditor/textfilewizard.cpp delete mode 100644 src/plugins/texteditor/textfilewizard.h diff --git a/share/qtcreator/templates/wizards/files/text/file.txt b/share/qtcreator/templates/wizards/files/text/file.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/share/qtcreator/templates/wizards/files/text/wizard.json b/share/qtcreator/templates/wizards/files/text/wizard.json new file mode 100644 index 00000000000..4fc82586833 --- /dev/null +++ b/share/qtcreator/templates/wizards/files/text/wizard.json @@ -0,0 +1,38 @@ +{ + "version": 1, + "kind": "file", + "id": "F.Resource", + "category": "U.General", + "trDescription": "Creates a text file. The default file extension is .txt. You can specify a different extension as part of the filename.", + "trDisplayName": "Text File", + "trDisplayCategory": "General", + "icon": "../../global/genericfilewizard.png", + "platformIndependent": true, + "featuresRequired": [ "Plugin.TextEditor" ], + + "pages" : + [ + { + "trDisplayName": "Location", + "trShortTitle": "Location", + "typeId": "File" + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + "generators" : + [ + { + "typeId": "File", + "data": + { + "source": "file.txt", + "target": "%{JS: Util.fileName('%{TargetPath}', '%{JS: Util.preferredSuffix('text/plain')}')}", + "openInEditor": true + } + } + ] +} diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index 0b44779c197..92f51f345a0 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -51,7 +51,6 @@ #include #include -#include #include diff --git a/src/plugins/pythoneditor/wizard/pythonfilewizard.cpp b/src/plugins/pythoneditor/wizard/pythonfilewizard.cpp index 1c610457515..fad1497c11c 100644 --- a/src/plugins/pythoneditor/wizard/pythonfilewizard.cpp +++ b/src/plugins/pythoneditor/wizard/pythonfilewizard.cpp @@ -35,7 +35,6 @@ #include "../pythoneditorconstants.h" #include -#include #include #include diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 88499e86b24..92359c8cc1a 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -58,7 +58,6 @@ #include #include #include -#include #include #include #include diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro index 62586fd1ccd..92066eab39d 100644 --- a/src/plugins/texteditor/texteditor.pro +++ b/src/plugins/texteditor/texteditor.pro @@ -4,7 +4,6 @@ CONFIG += exceptions CONFIG += include_source_dir # For the highlighter autotest. include(../../qtcreatorplugin.pri) SOURCES += texteditorplugin.cpp \ - textfilewizard.cpp \ plaintexteditorfactory.cpp \ textdocument.cpp \ texteditor.cpp \ @@ -104,7 +103,6 @@ SOURCES += texteditorplugin.cpp \ marginsettings.cpp HEADERS += texteditorplugin.h \ - textfilewizard.h \ plaintexteditorfactory.h \ texteditor_p.h \ textdocument.h \ diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index b41bc6820d8..af44f3007d7 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -133,8 +133,6 @@ QtcPlugin { "texteditorplugin.h", "texteditorsettings.cpp", "texteditorsettings.h", - "textfilewizard.cpp", - "textfilewizard.h", "textmark.cpp", "textmark.h", "textmarkregistry.h", diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index 77e3529d22e..c709cd74569 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -41,7 +41,6 @@ #include "snippets/plaintextsnippetprovider.h" #include "texteditoractionhandler.h" #include "texteditorsettings.h" -#include "textfilewizard.h" #include "textmarkregistry.h" #include @@ -83,13 +82,6 @@ TextEditorPlugin::~TextEditorPlugin() m_instance = 0; } -static const char wizardCategoryC[] = "U.General"; - -static inline QString wizardDisplayCategory() -{ - return TextEditorPlugin::tr("General"); -} - // ExtensionSystem::PluginInterface bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage) { @@ -98,19 +90,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe if (!MimeDatabase::addMimeTypes(QLatin1String(":/texteditor/TextEditor.mimetypes.xml"), errorMessage)) return false; - TextFileWizard *wizard = new TextFileWizard(QLatin1String(Constants::C_TEXTEDITOR_MIMETYPE_TEXT), - QLatin1String("text$")); - wizard->setWizardKind(IWizardFactory::FileWizard); - wizard->setDescription(tr("Creates a text file. The default file extension is .txt. " - "You can specify a different extension as part of the filename.")); - wizard->setDisplayName(tr("Text File")); - wizard->setCategory(QLatin1String(wizardCategoryC)); - wizard->setDisplayCategory(wizardDisplayCategory()); - wizard->setFlags(IWizardFactory::PlatformIndependent); - - // Add text file wizard - addAutoReleasedObject(wizard); - m_settings = new TextEditorSettings(this); // Add plain text editor factory diff --git a/src/plugins/texteditor/textfilewizard.cpp b/src/plugins/texteditor/textfilewizard.cpp deleted file mode 100644 index cb933a22fa2..00000000000 --- a/src/plugins/texteditor/textfilewizard.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "textfilewizard.h" - -namespace TextEditor { - -TextFileWizard::TextFileWizard(const QString &mimeType, - const QString &suggestedFileName) : - m_mimeType(mimeType), - m_suggestedFileName(suggestedFileName) -{ -} - -Core::GeneratedFiles - TextFileWizard::generateFilesFromPath(const QString &path, const QString &name, - QString * /*errorMessage*/) const -{ - const QString suffix = preferredSuffix(m_mimeType); - const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, suffix); - Core::GeneratedFile file(fileName); - file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - return Core::GeneratedFiles() << file; -} - -} // namespace TextEditor diff --git a/src/plugins/texteditor/textfilewizard.h b/src/plugins/texteditor/textfilewizard.h deleted file mode 100644 index e8568fba9da..00000000000 --- a/src/plugins/texteditor/textfilewizard.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef TEXTFILEWIZARD_H -#define TEXTFILEWIZARD_H - -#include "texteditor_global.h" - -#include - -namespace TextEditor { - -class TEXTEDITOR_EXPORT TextFileWizard : public Core::StandardFileWizardFactory -{ - Q_OBJECT - -public: - TextFileWizard(const QString &mimeType, - const QString &suggestedFileName); - -protected: - Core::GeneratedFiles generateFilesFromPath(const QString &path, const QString &name, - QString *errorMessage) const; -private: - const QString m_mimeType; - const QString m_suggestedFileName; -}; - -} // namespace TextEditor - -#endif // TEXTFILEWIZARD_H