forked from qt-creator/qt-creator
IWizardFactory: Create wizards with factoryCreators
Do not use the object pool to hold potential wizards. Register FactoryCreator functions with IWizardFactory instead and use those to create the wizards when necessary. This saves us a couple of cycles during startup since we can now delay construction of all wizards and it makes us more flexible wrt. managing the lifecycle of the wizard factories. Change-Id: I95d6a6dfcdf0fd995e1934a9fefcd96c6a676753 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -85,7 +85,21 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
|
||||
initializeTemplates();
|
||||
#ifdef CPP_ENABLED
|
||||
IWizardFactory::registerFactoryCreator(
|
||||
[]() -> QList<IWizardFactory *> {
|
||||
IWizardFactory *wizard = new FormClassWizard;
|
||||
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 Class"));
|
||||
wizard->setId("C.FormClass");
|
||||
wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) "
|
||||
"for implementation purposes. You can add the form and class to an existing Qt Widget Project."));
|
||||
|
||||
return QList<IWizardFactory *>() << wizard;
|
||||
});
|
||||
#endif
|
||||
|
||||
ProjectExplorer::JsonWizardFactory::registerPageFactory(new Internal::FormPageFactory);
|
||||
addAutoReleasedObject(new FormEditorFactory);
|
||||
@@ -130,21 +144,6 @@ void FormEditorPlugin::extensionsInitialized()
|
||||
//
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
void FormEditorPlugin::initializeTemplates()
|
||||
{
|
||||
#ifdef CPP_ENABLED
|
||||
IWizardFactory *wizard = new FormClassWizard;
|
||||
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 Class"));
|
||||
wizard->setId("C.FormClass");
|
||||
wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) "
|
||||
"for implementation purposes. You can add the form and class to an existing Qt Widget Project."));
|
||||
addAutoReleasedObject(wizard);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Find out current existing editor file
|
||||
static QString currentFile()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user