diff --git a/share/qtcreator/templates/wizards/files/form/file.ui b/share/qtcreator/templates/wizards/files/form/file.ui new file mode 100644 index 00000000000..a12c1fffb0a --- /dev/null +++ b/share/qtcreator/templates/wizards/files/form/file.ui @@ -0,0 +1 @@ +%{FormContents}\ diff --git a/share/qtcreator/templates/wizards/files/form/wizard.json b/share/qtcreator/templates/wizards/files/form/wizard.json new file mode 100644 index 00000000000..510f2d0ae1c --- /dev/null +++ b/share/qtcreator/templates/wizards/files/form/wizard.json @@ -0,0 +1,49 @@ +{ + "version": 1, + "kind": "file", + "id": "D.Form", + "category": "R.Qt", + "trDescription": "Creates a Qt Designer form that you can add to a Qt Widget Project. This is useful if you already have an existing class for the UI business logic.", + "trDisplayName": "Qt Designer Form", + "trDisplayCategory": "Qt", + "icon": "../../global/genericfilewizard.png", + "featuresRequired": [ "Plugin.Designer" ], + + "options": [ + { "key": "UiClass", "value": "%{JS: QtSupport.uiClassName('%{FormContents}') }" }, + { "key": "Extension", "value": "%{JS: Util.preferredSuffix('application/x-designer')}"}, + { "key": "InitialFileName", "value": "%{JS: Cpp.classToFileName('%{UiClass}', '%{Extension}') }" } + ], + + "pages": + [ + { + "trDisplayName": "Choose a Form Template", + "trShortTitle": "Form Template", + "typeId": "Form" + }, + { + "trDisplayName": "Location", + "trShortTitle": "Location", + "typeId": "File" + }, + { + "trDisplayName": "Project Management", + "trShortTitle": "Summary", + "typeId": "Summary" + } + ], + + "generators": + [ + { + "typeId": "File", + "data": + { + "source": "file.ui", + "target": "%{JS: Cpp.fileName('%{TargetPath}', '%{Extension}')}", + "openInEditor": true + } + } + ] +} diff --git a/src/plugins/designer/designer.pro b/src/plugins/designer/designer.pro index c4148d0aa7f..dc7743ab8dc 100644 --- a/src/plugins/designer/designer.pro +++ b/src/plugins/designer/designer.pro @@ -10,7 +10,6 @@ HEADERS += formeditorplugin.h \ formeditorfactory.h \ formwindoweditor.h \ formwindowfile.h \ - formwizard.h \ qtcreatorintegration.h \ designerconstants.h \ settingspage.h \ @@ -18,7 +17,6 @@ HEADERS += formeditorplugin.h \ formeditorw.h \ settingsmanager.h \ formtemplatewizardpage.h \ - formwizarddialog.h \ codemodelhelpers.h \ designer_export.h \ designercontext.h \ @@ -31,14 +29,12 @@ SOURCES += formeditorplugin.cpp \ formeditorfactory.cpp \ formwindoweditor.cpp \ formwindowfile.cpp \ - formwizard.cpp \ qtcreatorintegration.cpp \ settingspage.cpp \ editorwidget.cpp \ formeditorw.cpp \ settingsmanager.cpp \ formtemplatewizardpage.cpp \ - formwizarddialog.cpp \ codemodelhelpers.cpp \ designercontext.cpp \ formeditorstack.cpp \ diff --git a/src/plugins/designer/designer.qbs b/src/plugins/designer/designer.qbs index c8fc2fc9464..272622afd04 100644 --- a/src/plugins/designer/designer.qbs +++ b/src/plugins/designer/designer.qbs @@ -40,8 +40,6 @@ QtcPlugin { "formtemplatewizardpage.cpp", "formtemplatewizardpage.h", "formwindoweditor.cpp", "formwindoweditor.h", "formwindowfile.cpp", "formwindowfile.h", - "formwizard.cpp", "formwizard.h", - "formwizarddialog.cpp", "formwizarddialog.h", "qtcreatorintegration.cpp", "qtcreatorintegration.h", "qtdesignerformclasscodegenerator.cpp", "qtdesignerformclasscodegenerator.h", "resourcehandler.cpp", "resourcehandler.h", diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index f7a0fc965b9..771775242c8 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -33,7 +33,6 @@ #include "formeditorw.h" #include "formtemplatewizardpage.h" #include "formwindoweditor.h" -#include "formwizard.h" #ifdef CPP_ENABLED # include "cpp/formclasswizard.h" @@ -131,18 +130,8 @@ void FormEditorPlugin::extensionsInitialized() void FormEditorPlugin::initializeTemplates() { - IWizardFactory *wizard = new FormWizard; - wizard->setWizardKind(IWizardFactory::FileWizard); - wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); - wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT)); - wizard->setDisplayName(tr("Qt Designer Form")); - wizard->setId(QLatin1String("D.Form")); - wizard->setDescription(tr("Creates a Qt Designer form that you can add to a Qt Widget Project. " - "This is useful if you already have an existing class for the UI business logic.")); - addAutoReleasedObject(wizard); - #ifdef CPP_ENABLED - wizard = new FormClassWizard; + IWizardFactory *wizard = new FormClassWizard; wizard->setWizardKind(IWizardFactory::ClassWizard); wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT)); diff --git a/src/plugins/designer/formwizard.cpp b/src/plugins/designer/formwizard.cpp deleted file mode 100644 index ec364fdbe89..00000000000 --- a/src/plugins/designer/formwizard.cpp +++ /dev/null @@ -1,71 +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 "formwizard.h" -#include "formwizarddialog.h" -#include "designerconstants.h" -#include - -#include - -using namespace Designer; -using namespace Designer::Internal; - -FormWizard::FormWizard() -{ - addRequiredFeature(Core::Id(QtSupport::Constants::FEATURE_QWIDGETS)); -} - -Core::BaseFileWizard *FormWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - FormFileWizardDialog *wizardDialog = new FormFileWizardDialog(parameters.extensionPages(), - parent); - wizardDialog->setPath(parameters.defaultPath()); - return wizardDialog; -} - -Core::GeneratedFiles FormWizard::generateFiles(const QWizard *w, - QString *errorMessage) const -{ - const FormFileWizardDialog *wizard = qobject_cast(w); - const QString fileName = Core::BaseFileWizardFactory::buildFileName(wizard->path(), wizard->fileName(), - preferredSuffix(QLatin1String(Constants::FORM_MIMETYPE))); - - const QString formTemplate = wizard->templateContents(); - if (formTemplate.isEmpty()) { - *errorMessage = QLatin1String("Internal error: FormWizard::generateFiles: empty template contents"); - return Core::GeneratedFiles(); - } - - Core::GeneratedFile file(fileName); - file.setContents(formTemplate); - file.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - return Core::GeneratedFiles() << file; -} diff --git a/src/plugins/designer/formwizard.h b/src/plugins/designer/formwizard.h deleted file mode 100644 index 565eb0c2cd3..00000000000 --- a/src/plugins/designer/formwizard.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 FORMWIZARD_H -#define FORMWIZARD_H - -#include - -namespace Designer { -namespace Internal { - -class FormWizard : public Core::BaseFileWizardFactory -{ - Q_OBJECT - -public: - FormWizard(); - -private: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; -}; - -} // namespace Internal -} // namespace Designer - -#endif // FORMWIZARD_H diff --git a/src/plugins/designer/formwizarddialog.cpp b/src/plugins/designer/formwizarddialog.cpp deleted file mode 100644 index 2e4d3a19e8d..00000000000 --- a/src/plugins/designer/formwizarddialog.cpp +++ /dev/null @@ -1,119 +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 "formwizarddialog.h" -#include "formtemplatewizardpage.h" - -#include - -#include - -#include - -// Make sure there is a gap before the extension pages -enum { FormPageId, FilePageId, FirstExtensionPageId = 10 }; - -namespace Designer { -namespace Internal { - -// ----------------- FormWizardDialog -FormWizardDialog::FormWizardDialog(const WizardPageList &extensionPages, - QWidget *parent) : - Core::BaseFileWizard(parent), - m_formPage(new FormTemplateWizardPage) -{ - init(extensionPages); -} - -void FormWizardDialog::init(const WizardPageList &extensionPages) -{ - setWindowTitle(tr("Qt Designer Form")); - setPage(FormPageId, m_formPage); - - int id = FirstExtensionPageId; - foreach (QWizardPage *p, extensionPages) { - setPage(id, p); - ++id; - } -} - -QString FormWizardDialog::templateContents() const -{ - // Template is expensive, cache - if (m_templateContents.isEmpty()) - m_templateContents = m_formPage->templateContents(); - return m_templateContents; -} - -// ----------------- FormFileWizardDialog -FormFileWizardDialog::FormFileWizardDialog(const WizardPageList &extensionPages, - QWidget *parent) - : FormWizardDialog(extensionPages, parent), - m_filePage(new Utils::FileWizardPage) -{ - setPage(FilePageId, m_filePage); - connect(m_filePage, SIGNAL(activated()), - button(QWizard::FinishButton), SLOT(animateClick())); - - connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int))); -} - -QString FormFileWizardDialog::path() const -{ - return m_filePage->path(); -} - -void FormFileWizardDialog::setPath(const QString &path) -{ - m_filePage->setPath(path); -} - -QString FormFileWizardDialog::fileName() const -{ - return m_filePage->fileName(); -} - -void FormFileWizardDialog::slotCurrentIdChanged(int id) -{ - if (id == FilePageId) { - // Change from form to file: Store template and Suggest a name based on - // the ui class - QString formBaseClass; - QString uiClassName; - if (QtSupport::CodeGenerator::uiData(templateContents(), &formBaseClass, &uiClassName)) { - QString fileName = FormTemplateWizardPage::stripNamespaces(uiClassName).toLower(); - fileName += QLatin1String(".ui"); - m_filePage->setFileName(fileName); - } - } -} - -} // namespace Internal -} // namespace Designer diff --git a/src/plugins/designer/formwizarddialog.h b/src/plugins/designer/formwizarddialog.h deleted file mode 100644 index 9f52c888571..00000000000 --- a/src/plugins/designer/formwizarddialog.h +++ /dev/null @@ -1,92 +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 FORMWIZARDDIALOG_H -#define FORMWIZARDDIALOG_H - -#include - -namespace Utils { class FileWizardPage; } - -namespace Designer { -namespace Internal { - -class FormTemplateWizardPage; - -// Single-Page Wizard for new forms offering all types known to Qt Designer. -// To be used for Mode "CreateNewEditor" [not currently used] - -class FormWizardDialog : public Core::BaseFileWizard -{ - Q_OBJECT - -public: - typedef QList WizardPageList; - explicit FormWizardDialog(const WizardPageList &extensionPages, - QWidget *parent = 0); - - QString templateContents() const; - -private: - void init(const WizardPageList &extensionPages); - - FormTemplateWizardPage *m_formPage; - mutable QString m_templateContents; -}; - -// Two-Page Wizard for new forms for mode "CreateNewFile". Gives -// FormWizardDialog an additional page with file and path fields, -// initially determined from the UI class chosen on page one. - -class FormFileWizardDialog : public FormWizardDialog -{ - Q_OBJECT - -public: - explicit FormFileWizardDialog(const WizardPageList &extensionPages, - QWidget *parent = 0); - - QString path() const; - QString fileName() const; - -public slots: - void setPath(const QString &path); - -private slots: - void slotCurrentIdChanged(int id); - -private: - Utils::FileWizardPage *m_filePage; -}; - -} // namespace Internal -} // namespace Designer - -#endif // FORMWIZARDDIALOG_H