diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2014-10-09 11:25:14 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2014-10-14 21:38:50 +0200 |
commit | cd0ff57e2f8cebccd3396f2155d1a360937140d9 (patch) | |
tree | b4de15860e291cab72427d0b98ee420c1e00acdb /src | |
parent | 86ecc7d13e72789e99787e30f50ffc2cb0773781 (diff) | |
download | qt-creator-cd0ff57e2f8cebccd3396f2155d1a360937140d9.tar.gz |
JsonWizard: Replace JsFileWizard with a JsonWizard
Change-Id: I4da3485ed83fda7f17f3fa9a1f3d59bfabb7ea4d
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmljseditor/jsfilewizard.cpp | 145 | ||||
-rw-r--r-- | src/plugins/qmljseditor/jsfilewizard.h | 55 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.pro | 2 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.qbs | 2 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorplugin.cpp | 10 |
5 files changed, 0 insertions, 214 deletions
diff --git a/src/plugins/qmljseditor/jsfilewizard.cpp b/src/plugins/qmljseditor/jsfilewizard.cpp deleted file mode 100644 index 113f234d2a..0000000000 --- a/src/plugins/qmljseditor/jsfilewizard.cpp +++ /dev/null @@ -1,145 +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://www.qt.io/licensing. For further information -** use the contact form at http://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** 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 "jsfilewizard.h" - -#include <qmljstools/qmljstoolsconstants.h> - -#include <coreplugin/basefilewizard.h> - -#include <utils/filewizardpage.h> -#include <utils/qtcassert.h> - -#include <QFileInfo> -#include <QTextStream> -#include <QWizard> -#include <QPushButton> -#include <QBoxLayout> -#include <QCheckBox> - -namespace { -class JsFileOptionsPage : public QWizardPage -{ - Q_OBJECT -public: - JsFileOptionsPage() - { - setTitle(tr("Options")); - - QVBoxLayout *layout = new QVBoxLayout; - m_library = new QCheckBox(tr("JavaScript library")); - m_library->setToolTip( - tr("Usually each QML component instance has a unique copy of\n" - "imported JavaScript libraries. Indicating that a JavaScript file is\n" - "a library means that a single instance will be shared among\n" - "all components. JavaScript libraries will not be able to access\n" - "QML component instance objects and properties directly.")); - layout->addWidget(m_library); - setLayout(layout); - } - - bool isLibrary() const - { - return m_library->isChecked(); - } - -private: - QCheckBox *m_library; -}; - -class JsFileWizardDialog : public Core::BaseFileWizard -{ - Q_OBJECT -public: - JsFileWizardDialog(QWidget *parent = 0) : - Core::BaseFileWizard(parent) - { - addPage(new Utils::FileWizardPage); - addPage(new JsFileOptionsPage); - } -}; -} // anonymous namespace - -using namespace QmlJSEditor; - -JsFileWizard::JsFileWizard() -{ -} - -Core::GeneratedFiles JsFileWizard::generateFiles(const QWizard *w, - QString * /*errorMessage*/) const -{ - const Core::BaseFileWizard *wizard = qobject_cast<const Core::BaseFileWizard *>(w); - Utils::FileWizardPage *filePage = wizard->find<Utils::FileWizardPage>(); - QTC_ASSERT(filePage, return Core::GeneratedFiles()); - JsFileOptionsPage *optionPage = wizard->find<JsFileOptionsPage>(); - QTC_ASSERT(optionPage, return Core::GeneratedFiles()); - - - const QString path = filePage->path(); - const QString name = filePage->fileName(); - - const QString mimeType = QLatin1String(QmlJSTools::Constants::JS_MIMETYPE); - const QString fileName = Core::BaseFileWizardFactory::buildFileName(path, name, preferredSuffix(mimeType)); - - Core::GeneratedFile file(fileName); - file.setContents(fileContents(fileName, optionPage->isLibrary())); - file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - return Core::GeneratedFiles() << file; -} - -QString JsFileWizard::fileContents(const QString &, bool isLibrary) const -{ - QString contents; - QTextStream str(&contents); - - if (isLibrary) - str << QLatin1String(".pragma library\n\n"); - str << QLatin1String("function func() {\n") - << QLatin1String("\n") - << QLatin1String("}\n"); - - return contents; -} - -Core::BaseFileWizard *JsFileWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - JsFileWizardDialog *wizard = new JsFileWizardDialog(parent); - wizard->setWindowTitle(tr("New %1").arg(displayName())); - - Utils::FileWizardPage *page = wizard->find<Utils::FileWizardPage>(); - page->setPath(parameters.defaultPath()); - - foreach (QWizardPage *p, parameters.extensionPages()) - wizard->addPage(p); - return wizard; -} - -#include "jsfilewizard.moc" diff --git a/src/plugins/qmljseditor/jsfilewizard.h b/src/plugins/qmljseditor/jsfilewizard.h deleted file mode 100644 index 8908cb52ed..0000000000 --- a/src/plugins/qmljseditor/jsfilewizard.h +++ /dev/null @@ -1,55 +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://www.qt.io/licensing. For further information -** use the contact form at http://www.qt.io/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 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** 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 JSFILEWIZARD_H -#define JSFILEWIZARD_H - -#include <coreplugin/basefilewizardfactory.h> - -namespace QmlJSEditor { - -class JsFileWizard: public Core::BaseFileWizardFactory -{ - Q_OBJECT - -public: - JsFileWizard(); - -private: - QString fileContents(const QString &baseName, bool isLibrary) const; - - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; -}; - -} // namespace QmlJSEditor - -#endif // JSFILEWIZARD_H diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro index 31b9006714..3cbd8cb59d 100644 --- a/src/plugins/qmljseditor/qmljseditor.pro +++ b/src/plugins/qmljseditor/qmljseditor.pro @@ -23,7 +23,6 @@ HEADERS += \ qmljscomponentnamedialog.h \ qmljsfindreferences.h \ qmljsautocompleter.h \ - jsfilewizard.h \ qmljssnippetprovider.h \ qmljsreuse.h \ qmljsquickfixassist.h \ @@ -53,7 +52,6 @@ SOURCES += \ qmljscomponentnamedialog.cpp \ qmljsfindreferences.cpp \ qmljsautocompleter.cpp \ - jsfilewizard.cpp \ qmljssnippetprovider.cpp \ qmljsreuse.cpp \ qmljsquickfixassist.cpp \ diff --git a/src/plugins/qmljseditor/qmljseditor.qbs b/src/plugins/qmljseditor/qmljseditor.qbs index dc53a7b31b..8cc532e62e 100644 --- a/src/plugins/qmljseditor/qmljseditor.qbs +++ b/src/plugins/qmljseditor/qmljseditor.qbs @@ -18,8 +18,6 @@ QtcPlugin { Depends { name: "QmlJSTools" } files: [ - "jsfilewizard.cpp", - "jsfilewizard.h", "qmlexpressionundercursor.cpp", "qmlexpressionundercursor.h", "qmljsautocompleter.cpp", diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 4f542be889..c3fe263f3b 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -33,7 +33,6 @@ #include "qmljseditor.h" #include "qmljseditorconstants.h" #include "qmljseditordocument.h" -#include "jsfilewizard.h" #include "qmljsoutline.h" #include "qmljspreviewrunner.h" #include "qmljssnippetprovider.h" @@ -124,15 +123,6 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e addAutoReleasedObject(new QmlJSEditorFactory); - IWizardFactory *wizard = new JsFileWizard; - wizard->setWizardKind(Core::IWizardFactory::FileWizard); - wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); - wizard->setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Core::Constants::WIZARD_TR_CATEGORY_QT)); - wizard->setDescription(tr("Creates a JavaScript file.")); - wizard->setDisplayName(tr("JS File")); - wizard->setId(QLatin1String("Z.Js")); - addAutoReleasedObject(wizard); - Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT); Core::ActionContainer *qmlToolsMenu = Core::ActionManager::actionContainer(Core::Id(QmlJSTools::Constants::M_TOOLS_QMLJS)); |