Commit 95a028e8 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Alessandro Portale

Wizards: changes the structure of Wizards

This patch introduces platforms as a top level topic when choosing
a wizard. Also I changed the categories and priorities.

Details:

1. I did change the way the dialog/view is structured in newdialog.cpp

2. I added platformName() and supportsPlatform() to BaseQtVersion.
   I needed two functions because the Simulator does not provide a platform
   and therefore has no platformName but supports two platforms.
   I still have to turn the platform names into proper constants.

3. I changed the categories and priorities to get the layout that was
   discussed. (I had to touch quite alot of files but this is mostly trivial)

4. I added a combobox that allows filtering for platforms.

5. I added flags() to IWizard to indicate that a wizard is platform independent.

Change-Id: I86c7ad628a431ad06505c76580885c6e6c3ddc23
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@nokia.com>
parent ea234868
......@@ -37,7 +37,7 @@ the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project" firstpage="10" id="S.Plain C (CMake)" category="I.Projects" featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint">
<wizard version="1" kind="project" firstpage="10" id="S.Plain C (CMake)" category="I.Projects" featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint" platformIndependent="true">
<icon>console.png</icon>
<description>Creates a plain C project using CMake, not using the Qt library.</description>
<displayname>Plain C Project (CMake Build)</displayname>;
......
......@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="R.Plain C" category="I.Projects"
id="R.Plain C" category="H.QtProjects"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint">
<icon>console.png</icon>
<description>Creates a plain C project using qmake, not using the Qt library.</description>
<displayname>Plain C Project</displayname>;
<displaycategory>Non-Qt Project</displaycategory>
<displaycategory>Other Projects</displaycategory>
<files>
<file source="main.c" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
......
......@@ -37,7 +37,7 @@ the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project" firstpage="10" id="S.Plain C++ (CMake)" category="I.Projects" featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint">
<wizard version="1" kind="project" firstpage="10" id="S.Plain C++ (CMake)" category="I.Projects" featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint" platformIndependent="true">
<icon>console.png</icon>
<description>Creates a plain C++ project using CMake, not using the Qt library.</description>
<displayname>Plain C++ Project (CMake Build)</displayname>;
......
......@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="R.Plain C++" category="I.Projects"
id="R.Plain C++" category="H.QtProjects"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint">
<icon>console.png</icon>
<description>Creates a plain C++ project using qmake, not using the Qt library.</description>
<displayname>Plain C++ Project</displayname>;
<displaycategory>Non-Qt Project</displaycategory>
<displaycategory>Other Projects</displaycategory>
<files>
<file source="main.cpp" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
......
......@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="QmlExtensionPlugin" category="C.Projects"
id="QmlExtensionPlugin" category="G.Libraries"
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1">
<icon>lib.png</icon>
<description>Creates a C++ plugin that makes it possible to offer extensions that can be loaded dynamically into applications using the QDeclarativeEngine class.</description>
<displayname>Custom QML Extension Plugin</displayname>
<displaycategory>QML Extension Plugin</displaycategory>
<displaycategory>Libraries</displaycategory>
<files>
<file source="qmldir" target="qmldir"/>
<file source="plugin.h" target="%ProjectName:l%_plugin.%CppHeaderSuffix%"/>
......
......@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
-->
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="R.QtCreatorPlugin" category="F.QtProjects"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint,QtSupport.Wizards.FeatureQt">
id="R.QtCreatorPlugin" category="G.Libraries"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint,QtSupport.Wizards.FeatureQt,QtSupport.Wizards.FeatureDesktop">
<icon>qtcreator_logo_24.png</icon>
<description>Creates a custom Qt Creator plugin.</description>
<displayname>Qt Creator Plugin</displayname>;
<displaycategory>Other Qt Project</displaycategory>
<displaycategory>Libraries</displaycategory>
<files>
<file source="myplugin.pro" target="%PluginName:l%.pro" openproject="true"/>
<file source="MyPlugin.pluginspec.in" target="%PluginName%.pluginspec.in" openeditor="true"/>
......
......@@ -87,6 +87,7 @@ public:
QString category;
QString displayCategory;
Core::FeatureSet requiredFeatures;
Core::IWizard::WizardFlags flags;
};
BaseFileWizardParameterData::BaseFileWizardParameterData(IWizard::WizardKind k) :
......@@ -232,6 +233,15 @@ void BaseFileWizardParameters::setDisplayCategory(const QString &v)
m_d->displayCategory = v;
}
Core::IWizard::WizardFlags BaseFileWizardParameters::flags() const
{
return m_d->flags;
}
void BaseFileWizardParameters::setFlags(Core::IWizard::WizardFlags flags)
{
m_d->flags = flags;
}
/*!
\class Core::Internal::WizardEventLoop
\brief Special event loop that runs a QWizard and terminates if the page changes.
......@@ -407,7 +417,7 @@ QString BaseFileWizard::displayCategory() const
return d->m_parameters.displayCategory();
}
void BaseFileWizard::runWizard(const QString &path, QWidget *parent)
void BaseFileWizard::runWizard(const QString &path, QWidget *parent, const QString &platform)
{
QTC_ASSERT(!path.isEmpty(), return);
......@@ -437,10 +447,9 @@ void BaseFileWizard::runWizard(const QString &path, QWidget *parent)
// Create dialog and run it. Ensure that the dialog is deleted when
// leaving the func, but not before the IFileWizardExtension::process
// has been called
const QScopedPointer<QWizard> wizard(createWizardDialog(parent,
WizardDialogParameters(path,
const QScopedPointer<QWizard> wizard(createWizardDialog(parent, WizardDialogParameters(path,
allExtensionPages,
QString(),
platform,
requiredFeatures())));
QTC_ASSERT(!wizard.isNull(), return);
......@@ -525,6 +534,11 @@ Core::FeatureSet BaseFileWizard::requiredFeatures() const
return d->m_parameters.requiredFeatures();
}
Core::IWizard::WizardFlags BaseFileWizard::flags() const
{
return d->m_parameters.flags();
}
/*!
\fn virtual QWizard *Core::BaseFileWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath,
......
......@@ -94,6 +94,8 @@ public:
Core::FeatureSet requiredFeatures() const;
void setRequiredFeatures(Core::FeatureSet features);
Core::IWizard::WizardFlags flags() const;
void setFlags(Core::IWizard::WizardFlags flags);
private:
QSharedDataPointer<BaseFileWizardParameterData> m_d;
};
......@@ -148,8 +150,9 @@ public:
virtual QString category() const;
virtual QString displayCategory() const;
virtual void runWizard(const QString &path, QWidget *parent);
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform);
virtual Core::FeatureSet requiredFeatures() const;
virtual WizardFlags flags() const;
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
static void setupWizard(QWizard *);
......
......@@ -178,14 +178,52 @@ QList<IWizard*> IWizard::wizardsOfKind(WizardKind kind)
return findWizards(WizardKindPredicate(kind));
}
bool IWizard::isAvailable() const
bool IWizard::isAvailable(const QString &platformName) const
{
FeatureSet availableFeatures;
const QList<Core::IFeatureProvider*> featureManagers = ExtensionSystem::PluginManager::instance()->getObjects<Core::IFeatureProvider>();
foreach (const Core::IFeatureProvider *featureManager, featureManagers)
availableFeatures |= featureManager->availableFeatures();
availableFeatures |= featureManager->availableFeatures(platformName);
return availableFeatures.contains(requiredFeatures());
}
QStringList IWizard::supportedPlatforms() const
{
QStringList stringList;
foreach (const QString &platform, allAvailablePlatforms()) {
if (isAvailable(platform))
stringList.append(platform);
}
return stringList;
}
QStringList IWizard::allAvailablePlatforms()
{
QStringList platforms;
const QList<Core::IFeatureProvider*> featureManagers =
ExtensionSystem::PluginManager::instance()->getObjects<Core::IFeatureProvider>();
foreach (const Core::IFeatureProvider *featureManager, featureManagers)
platforms.append(featureManager->availablePlatforms());
return platforms;
}
QString IWizard::displayNameForPlatform(const QString &string)
{
const QList<Core::IFeatureProvider*> featureManagers =
ExtensionSystem::PluginManager::instance()->getObjects<Core::IFeatureProvider>();
foreach (const Core::IFeatureProvider *featureManager, featureManagers) {
QString displayName = featureManager->displayNameForPlatform(string);
if (!displayName.isEmpty())
return displayName;
}
return QString();
}
......@@ -55,6 +55,10 @@ public:
ProjectWizard = 0x04
};
Q_DECLARE_FLAGS(WizardKinds, WizardKind)
enum WizardFlag {
PlatformIndependent = 0x01
};
Q_DECLARE_FLAGS(WizardFlags, WizardFlag)
IWizard(QObject *parent = 0) : QObject(parent) {}
virtual ~IWizard() {}
......@@ -69,19 +73,24 @@ public:
virtual QString displayCategory() const = 0;
virtual FeatureSet requiredFeatures() const = 0;
virtual WizardFlags flags() const = 0;
virtual void runWizard(const QString &path, QWidget *parent) = 0;
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform) = 0;
bool isAvailable() const;
bool isAvailable(const QString &platformName) const;
QStringList supportedPlatforms() const;
// Utility to find all registered wizards
static QList<IWizard*> allWizards();
// Utility to find all registered wizards of a certain kind
static QList<IWizard*> wizardsOfKind(WizardKind kind);
static QStringList allAvailablePlatforms();
static QString displayNameForPlatform(const QString &string);
};
} // namespace Core
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizard::WizardKinds)
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizard::WizardFlags)
#endif // IWIZARD_H
......@@ -36,11 +36,13 @@
#include "iwizard.h"
#include <QtGui/QDialog>
#include <QtGui/QIcon>
#include <QtCore/QList>
#include <QtCore/QModelIndex>
QT_BEGIN_NAMESPACE
class QAbstractProxyModel;
class QSortFilterProxyModel;
class QPushButton;
class QStandardItem;
class QStandardItemModel;
......@@ -66,20 +68,26 @@ public:
void setWizards(QList<IWizard*> wizards);
Core::IWizard *showDialog();
QString selectedPlatform() const;
int selectedWizardOption() const;
private slots:
void currentCategoryChanged(const QModelIndex &);
void currentItemChanged(const QModelIndex &);
void okButtonClicked();
void updateOkButton();
void setSelectedPlatform(const QString &platform);
private:
Core::IWizard *currentWizard() const;
void addItem(QStandardItem *topLEvelCategoryItem, IWizard *wizard);
Ui::NewDialog *m_ui;
QStandardItemModel *m_model;
QAbstractProxyModel *m_proxyModel;
QAbstractProxyModel *m_twoLevelProxyModel;
QSortFilterProxyModel *m_filterProxyModel;
QPushButton *m_okButton;
QPixmap m_dummyIcon;
QIcon m_dummyIcon;
QList<QStandardItem*> m_categoryItems;
};
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>554</width>
<height>412</height>
<width>880</width>
<height>520</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -26,9 +26,6 @@
<string>New Project</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
......@@ -36,7 +33,43 @@
</property>
</widget>
</item>
<item row="1" column="0" rowspan="3">
<item row="1" column="2">
<widget class="QTextBrowser" name="templateDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTreeView" name="templateCategoryView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
......@@ -46,10 +79,47 @@
</property>
<property name="maximumSize">
<size>
<width>225</width>
<width>1000</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>97</red>
<green>97</green>
<blue>97</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>97</red>
<green>97</green>
<blue>97</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
......@@ -75,7 +145,7 @@
</attribute>
</widget>
</item>
<item row="1" column="1" rowspan="2">
<item row="1" column="1">
<widget class="QListView" name="templatesView">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
......@@ -100,20 +170,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTextBrowser" name="templateDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="2" column="1" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -125,11 +182,6 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>templateCategoryView</tabstop>
<tabstop>templatesView</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -57,7 +57,9 @@ class CORE_EXPORT IFeatureProvider : public QObject
public:
IFeatureProvider() {}
virtual ~IFeatureProvider() {}
virtual FeatureSet availableFeatures() const = 0;
virtual FeatureSet availableFeatures(const QString &platform) const = 0;
virtual QStringList availablePlatforms() const = 0;
virtual QString displayNameForPlatform(const QString &string) const = 0;
};
class CORE_EXPORT Feature : public Id
......
......@@ -942,6 +942,7 @@ void MainWindow::showNewItemDialog(const QString &title,
// Scan for wizards matching the filter and pick one. Don't show
// dialog if there is only one.
IWizard *wizard = 0;
QString selectedPlatform;
switch (wizards.size()) {
case 0:
break;
......@@ -953,6 +954,7 @@ void MainWindow::showNewItemDialog(const QString &title,
dlg.setWizards(wizards);
dlg.setWindowTitle(title);
wizard = dlg.showDialog();
selectedPlatform = dlg.selectedPlatform();
}
break;
}
......@@ -976,7 +978,7 @@ void MainWindow::showNewItemDialog(const QString &title,
break;
}
}
wizard->runWizard(path, this);
wizard->runWizard(path, this, selectedPlatform);
}
bool MainWindow::showOptionsDialog(const QString &category,
......
......@@ -138,6 +138,7 @@ Core::BaseFileWizardParameters GenericProjectWizard::parameters()
"This allows you to use Qt Creator as a code editor."));
parameters.setCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY));
parameters.setDisplayCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY_DISPLAY));
parameters.setFlags(Core::IWizard::PlatformIndependent);
return parameters;
}
......
......@@ -68,6 +68,11 @@ Core::FeatureSet GLSLFileWizard::requiredFeatures() const
return Core::FeatureSet();
}
Core::IWizard::WizardFlags GLSLFileWizard::flags() const
{
return Core::IWizard::PlatformIndependent;
}
Core::GeneratedFiles GLSLFileWizard::generateFiles(const QWizard *w,
QString * /*errorMessage*/) const
{
......
......@@ -56,6 +56,7 @@ public:
ShaderType shaderType, QObject *parent = 0);
virtual Core::FeatureSet requiredFeatures() const;
virtual WizardFlags flags() const;
protected:
QString fileContents(const QString &baseName, ShaderType shaderType) const;
......
......@@ -190,9 +190,19 @@ Core::FeatureSet MaemoQtVersion::availableFeatures() const
Core::FeatureSet features = QtSupport::BaseQtVersion::availableFeatures();
if (qtVersion() >= QtSupport::QtVersionNumber(4, 7, 4)) //no reliable test for components, yet.
features |= Core::FeatureSet(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO);
features |= Core::FeatureSet(QtSupport::Constants::FEATURE_MOBILE);
return features;
}
QString MaemoQtVersion::platformName() const
{
return QLatin1String(QtSupport::Constants::MEEGO_HARMATTAN_PLATFORM);
}
QString MaemoQtVersion::platformDisplayName() const
{
return QLatin1String(QtSupport::Constants::MEEGO_HARMATTAN_PLATFORM_TR);
}
void MaemoQtVersion::addToEnvironment(Utils::Environment &env) const
{
......
......@@ -61,6 +61,8 @@ public:
bool supportsShadowBuilds() const;
QString osType() const;
Core::FeatureSet availableFeatures() const;
QString platformName() const;
QString platformDisplayName() const;
private:
mutable QString m_systemRoot;
......
......@@ -56,6 +56,8 @@ struct BaseProjectWizardDialogPrivate {
const int desiredIntroPageId;
Utils::ProjectIntroPage *introPage;
int introPageId;
QString selectedPlatform;
Core::FeatureSet requiredFeatureSet;
};
BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id) :
......@@ -66,20 +68,24 @@ BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectInt
}
BaseProjectWizardDialog::BaseProjectWizardDialog(QWidget *parent,
const Core::WizardDialogParameters & /*parameters*/) :
const Core::WizardDialogParameters &parameters) :
Utils::Wizard(parent),
d(new BaseProjectWizardDialogPrivate(new Utils::ProjectIntroPage))
{
setSelectedPlatform(parameters.selectedPlatform());
setRequiredFeatures(parameters.requiredFeatures());
init();
}
BaseProjectWizardDialog::BaseProjectWizardDialog(Utils::ProjectIntroPage *introPage,
int introId,
QWidget *parent,
const Core::WizardDialogParameters & /*parameters*/) :
const Core::WizardDialogParameters &parameters) :
Utils::Wizard(parent),
d(new BaseProjectWizardDialogPrivate(introPage, introId))
{
setSelectedPlatform(parameters.selectedPlatform());
setRequiredFeatures(parameters.requiredFeatures());
init();
}
......@@ -164,4 +170,25 @@ QString BaseProjectWizardDialog::uniqueProjectName(const QString &path)
}
return prefix;
}
QString BaseProjectWizardDialog::selectedPlatform() const
{
return d->selectedPlatform;
}
void BaseProjectWizardDialog::setSelectedPlatform(const QString &platform)
{
d->selectedPlatform = platform;
}
Core::FeatureSet BaseProjectWizardDialog::requiredFeatures() const
{
return d->requiredFeatureSet;
}
void BaseProjectWizardDialog::setRequiredFeatures(const Core::FeatureSet &featureSet)
{