forked from qt-creator/qt-creator
Wizard: Make wizards report which type of projects they can support
Use that information to decide whether the wizard is a File or ProjectWizard Change-Id: Ie630e206317c7e01e77c811819cb95b360a04e09 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -64,7 +64,7 @@ public:
|
||||
Q_DECLARE_FLAGS(WizardFlags, WizardFlag)
|
||||
|
||||
Id id() const { return m_id; }
|
||||
WizardKind kind() const { return m_kind; }
|
||||
WizardKind kind() const { return m_supportedProjectTypes.isEmpty() ? FileWizard : ProjectWizard; }
|
||||
QIcon icon() const { return m_icon; }
|
||||
QString description() const { return m_description; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
@@ -73,9 +73,10 @@ public:
|
||||
QString descriptionImage() const { return m_descriptionImage; }
|
||||
QSet<Id> requiredFeatures() const { return m_requiredFeatures; }
|
||||
WizardFlags flags() const { return m_flags; }
|
||||
QSet<Id> supportedProjectTypes() const { return m_supportedProjectTypes; }
|
||||
|
||||
void setId(const Id id) { m_id = id; }
|
||||
void setWizardKind(WizardKind kind) { m_kind = kind; }
|
||||
void setSupportedProjectTypes(const QSet<Id> &projectTypes) { m_supportedProjectTypes = projectTypes; }
|
||||
void setIcon(const QIcon &icon) { m_icon = icon; }
|
||||
void setDescription(const QString &description) { m_description = description; }
|
||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||
@@ -132,10 +133,10 @@ private:
|
||||
QString m_category;
|
||||
QString m_displayCategory;
|
||||
QString m_descriptionImage;
|
||||
Id m_id;
|
||||
QSet<Id> m_requiredFeatures;
|
||||
WizardKind m_kind = FileWizard;
|
||||
QSet<Id> m_supportedProjectTypes;
|
||||
WizardFlags m_flags = 0;
|
||||
Id m_id;
|
||||
|
||||
friend class Internal::CorePlugin;
|
||||
};
|
||||
|
@@ -89,7 +89,6 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
IWizardFactory::registerFactoryCreator(
|
||||
[this]() -> 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"));
|
||||
|
@@ -29,6 +29,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "genericprojectwizard.h"
|
||||
#include "genericprojectconstants.h"
|
||||
#include "filesselectionwizardpage.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -114,7 +115,7 @@ QString GenericProjectWizardDialog::projectName() const
|
||||
|
||||
GenericProjectWizard::GenericProjectWizard()
|
||||
{
|
||||
setWizardKind(ProjectWizard);
|
||||
setSupportedProjectTypes({ Constants::GENERICPROJECT_ID });
|
||||
// TODO do something about the ugliness of standard icons in sizes different than 16, 32, 64, 128
|
||||
{
|
||||
QPixmap icon(22, 22);
|
||||
|
@@ -126,7 +126,8 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p)
|
||||
d->m_parameters = p;
|
||||
|
||||
setId(p->id);
|
||||
setWizardKind(p->kind);
|
||||
setSupportedProjectTypes((p->kind == Core::IWizardFactory::FileWizard)
|
||||
? QSet<Core::Id>() : QSet<Core::Id>() << "UNKNOWN_PROJECT");
|
||||
setIcon(p->icon);
|
||||
setDescription(p->description);
|
||||
setDisplayName(p->displayName);
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
#include <QUuid>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
@@ -68,6 +69,7 @@ static const char VERSION_KEY[] = "version";
|
||||
static const char ENABLED_EXPRESSION_KEY[] = "enabled";
|
||||
|
||||
static const char KIND_KEY[] = "kind";
|
||||
static const char SUPPORTED_PROJECTS[] = "supportedProjectTypes";
|
||||
static const char ID_KEY[] = "id";
|
||||
static const char CATEGORY_KEY[] = "category";
|
||||
static const char CATEGORY_NAME_KEY[] = "trDisplayCategory";
|
||||
@@ -521,17 +523,25 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
|
||||
|
||||
m_enabledExpression = data.value(QLatin1String(ENABLED_EXPRESSION_KEY), true);
|
||||
|
||||
QString strVal = data.value(QLatin1String(KIND_KEY)).toString();
|
||||
if (strVal != QLatin1String("class")
|
||||
QSet<Core::Id> projectTypes = Core::Id::fromStringList(data.value(QLatin1String(SUPPORTED_PROJECTS)).toStringList());
|
||||
// FIXME: "kind" was relevant up to and including Qt Creator 3.6:
|
||||
const QString unsetKind = QUuid::createUuid().toString();
|
||||
QString strVal = data.value(QLatin1String(KIND_KEY), unsetKind).toString();
|
||||
if (strVal != unsetKind
|
||||
&& strVal != QLatin1String("class")
|
||||
&& strVal != QLatin1String("file")
|
||||
&& strVal != QLatin1String("project")) {
|
||||
*errorMessage = tr("\"kind\" value \"%1\" is not \"class\" (deprecated), \"file\" or \"project\".").arg(strVal);
|
||||
return false;
|
||||
}
|
||||
IWizardFactory::WizardKind kind = IWizardFactory::ProjectWizard;
|
||||
if (strVal == QLatin1String("file") || strVal == QLatin1String("class"))
|
||||
kind = IWizardFactory::FileWizard;
|
||||
setWizardKind(kind);
|
||||
if ((strVal == QLatin1String("file") || strVal == QLatin1String("class")) && !projectTypes.isEmpty()) {
|
||||
*errorMessage = tr("\"kind\" is \"file\" or \"class\" (deprecated) and \"%1\" is also set.").arg(QLatin1String(SUPPORTED_PROJECTS));
|
||||
return false;
|
||||
}
|
||||
if (strVal == QLatin1String("project") && projectTypes.isEmpty())
|
||||
projectTypes.insert("UNKNOWN_PROJECT");
|
||||
// end of legacy code
|
||||
setSupportedProjectTypes(projectTypes);
|
||||
|
||||
strVal = data.value(QLatin1String(ID_KEY)).toString();
|
||||
if (strVal.isEmpty()) {
|
||||
|
@@ -60,7 +60,7 @@ using namespace QtSupport;
|
||||
// -------------------- QtWizard
|
||||
QtWizard::QtWizard()
|
||||
{
|
||||
setWizardKind(Core::IWizardFactory::ProjectWizard);
|
||||
setSupportedProjectTypes({ Constants::QMAKEPROJECT_ID });
|
||||
}
|
||||
|
||||
QString QtWizard::sourceSuffix()
|
||||
|
Reference in New Issue
Block a user