Commit 4fde1b55 authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent cc817d50
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
Q_DECLARE_FLAGS(WizardFlags, WizardFlag) Q_DECLARE_FLAGS(WizardFlags, WizardFlag)
Id id() const { return m_id; } 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; } QIcon icon() const { return m_icon; }
QString description() const { return m_description; } QString description() const { return m_description; }
QString displayName() const { return m_displayName; } QString displayName() const { return m_displayName; }
...@@ -73,9 +73,10 @@ public: ...@@ -73,9 +73,10 @@ public:
QString descriptionImage() const { return m_descriptionImage; } QString descriptionImage() const { return m_descriptionImage; }
QSet<Id> requiredFeatures() const { return m_requiredFeatures; } QSet<Id> requiredFeatures() const { return m_requiredFeatures; }
WizardFlags flags() const { return m_flags; } WizardFlags flags() const { return m_flags; }
QSet<Id> supportedProjectTypes() const { return m_supportedProjectTypes; }
void setId(const Id id) { m_id = id; } 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 setIcon(const QIcon &icon) { m_icon = icon; }
void setDescription(const QString &description) { m_description = description; } void setDescription(const QString &description) { m_description = description; }
void setDisplayName(const QString &displayName) { m_displayName = displayName; } void setDisplayName(const QString &displayName) { m_displayName = displayName; }
...@@ -132,10 +133,10 @@ private: ...@@ -132,10 +133,10 @@ private:
QString m_category; QString m_category;
QString m_displayCategory; QString m_displayCategory;
QString m_descriptionImage; QString m_descriptionImage;
Id m_id;
QSet<Id> m_requiredFeatures; QSet<Id> m_requiredFeatures;
WizardKind m_kind = FileWizard; QSet<Id> m_supportedProjectTypes;
WizardFlags m_flags = 0; WizardFlags m_flags = 0;
Id m_id;
friend class Internal::CorePlugin; friend class Internal::CorePlugin;
}; };
......
...@@ -89,7 +89,6 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) ...@@ -89,7 +89,6 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
IWizardFactory::registerFactoryCreator( IWizardFactory::registerFactoryCreator(
[this]() -> QList<IWizardFactory *> { [this]() -> QList<IWizardFactory *> {
IWizardFactory *wizard = new FormClassWizard; IWizardFactory *wizard = new FormClassWizard;
wizard->setWizardKind(IWizardFactory::FileWizard);
wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT));
wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT)); wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT));
wizard->setDisplayName(tr("Qt Designer Form Class")); wizard->setDisplayName(tr("Qt Designer Form Class"));
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
****************************************************************************/ ****************************************************************************/
#include "genericprojectwizard.h" #include "genericprojectwizard.h"
#include "genericprojectconstants.h"
#include "filesselectionwizardpage.h" #include "filesselectionwizardpage.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
...@@ -114,7 +115,7 @@ QString GenericProjectWizardDialog::projectName() const ...@@ -114,7 +115,7 @@ QString GenericProjectWizardDialog::projectName() const
GenericProjectWizard::GenericProjectWizard() 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 // TODO do something about the ugliness of standard icons in sizes different than 16, 32, 64, 128
{ {
QPixmap icon(22, 22); QPixmap icon(22, 22);
......
...@@ -126,7 +126,8 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p) ...@@ -126,7 +126,8 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p)
d->m_parameters = p; d->m_parameters = p;
setId(p->id); setId(p->id);
setWizardKind(p->kind); setSupportedProjectTypes((p->kind == Core::IWizardFactory::FileWizard)
? QSet<Core::Id>() : QSet<Core::Id>() << "UNKNOWN_PROJECT");
setIcon(p->icon); setIcon(p->icon);
setDescription(p->description); setDescription(p->description);
setDisplayName(p->displayName); setDisplayName(p->displayName);
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
#include <QJsonParseError> #include <QJsonParseError>
#include <QUuid>
namespace ProjectExplorer { namespace ProjectExplorer {
...@@ -68,6 +69,7 @@ static const char VERSION_KEY[] = "version"; ...@@ -68,6 +69,7 @@ static const char VERSION_KEY[] = "version";
static const char ENABLED_EXPRESSION_KEY[] = "enabled"; static const char ENABLED_EXPRESSION_KEY[] = "enabled";
static const char KIND_KEY[] = "kind"; static const char KIND_KEY[] = "kind";
static const char SUPPORTED_PROJECTS[] = "supportedProjectTypes";
static const char ID_KEY[] = "id"; static const char ID_KEY[] = "id";
static const char CATEGORY_KEY[] = "category"; static const char CATEGORY_KEY[] = "category";
static const char CATEGORY_NAME_KEY[] = "trDisplayCategory"; static const char CATEGORY_NAME_KEY[] = "trDisplayCategory";
...@@ -521,17 +523,25 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir, ...@@ -521,17 +523,25 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir,
m_enabledExpression = data.value(QLatin1String(ENABLED_EXPRESSION_KEY), true); m_enabledExpression = data.value(QLatin1String(ENABLED_EXPRESSION_KEY), true);
QString strVal = data.value(QLatin1String(KIND_KEY)).toString(); QSet<Core::Id> projectTypes = Core::Id::fromStringList(data.value(QLatin1String(SUPPORTED_PROJECTS)).toStringList());
if (strVal != QLatin1String("class") // 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("file")
&& strVal != QLatin1String("project")) { && strVal != QLatin1String("project")) {
*errorMessage = tr("\"kind\" value \"%1\" is not \"class\" (deprecated), \"file\" or \"project\".").arg(strVal); *errorMessage = tr("\"kind\" value \"%1\" is not \"class\" (deprecated), \"file\" or \"project\".").arg(strVal);
return false; return false;
} }
IWizardFactory::WizardKind kind = IWizardFactory::ProjectWizard; if ((strVal == QLatin1String("file") || strVal == QLatin1String("class")) && !projectTypes.isEmpty()) {
if (strVal == QLatin1String("file") || strVal == QLatin1String("class")) *errorMessage = tr("\"kind\" is \"file\" or \"class\" (deprecated) and \"%1\" is also set.").arg(QLatin1String(SUPPORTED_PROJECTS));
kind = IWizardFactory::FileWizard; return false;
setWizardKind(kind); }
if (strVal == QLatin1String("project") && projectTypes.isEmpty())
projectTypes.insert("UNKNOWN_PROJECT");
// end of legacy code
setSupportedProjectTypes(projectTypes);
strVal = data.value(QLatin1String(ID_KEY)).toString(); strVal = data.value(QLatin1String(ID_KEY)).toString();
if (strVal.isEmpty()) { if (strVal.isEmpty()) {
......
...@@ -60,7 +60,7 @@ using namespace QtSupport; ...@@ -60,7 +60,7 @@ using namespace QtSupport;
// -------------------- QtWizard // -------------------- QtWizard
QtWizard::QtWizard() QtWizard::QtWizard()
{ {
setWizardKind(Core::IWizardFactory::ProjectWizard); setSupportedProjectTypes({ Constants::QMAKEPROJECT_ID });
} }
QString QtWizard::sourceSuffix() QString QtWizard::sourceSuffix()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment