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. ...@@ -37,7 +37,7 @@ the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page. 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> <icon>console.png</icon>
<description>Creates a plain C project using CMake, not using the Qt library.</description> <description>Creates a plain C project using CMake, not using the Qt library.</description>
<displayname>Plain C Project (CMake Build)</displayname>; <displayname>Plain C Project (CMake Build)</displayname>;
......
...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page. ...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
--> -->
<wizard version="1" kind="project" <wizard version="1" kind="project"
class="qt4project" firstpage="10" class="qt4project" firstpage="10"
id="R.Plain C" category="I.Projects" id="R.Plain C" category="H.QtProjects"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint"> featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint">
<icon>console.png</icon> <icon>console.png</icon>
<description>Creates a plain C project using qmake, not using the Qt library.</description> <description>Creates a plain C project using qmake, not using the Qt library.</description>
<displayname>Plain C Project</displayname>; <displayname>Plain C Project</displayname>;
<displaycategory>Non-Qt Project</displaycategory> <displaycategory>Other Projects</displaycategory>
<files> <files>
<file source="main.c" openeditor="true"/> <file source="main.c" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/> <file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
......
...@@ -37,7 +37,7 @@ the project file goes last. ...@@ -37,7 +37,7 @@ the project file goes last.
The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and The "class" and "firstpage" attributes specify that it is a Qt 4 wizard and
leave room for the Qt 4 target page. 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> <icon>console.png</icon>
<description>Creates a plain C++ project using CMake, not using the Qt library.</description> <description>Creates a plain C++ project using CMake, not using the Qt library.</description>
<displayname>Plain C++ Project (CMake Build)</displayname>; <displayname>Plain C++ Project (CMake Build)</displayname>;
......
...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page. ...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
--> -->
<wizard version="1" kind="project" <wizard version="1" kind="project"
class="qt4project" firstpage="10" class="qt4project" firstpage="10"
id="R.Plain C++" category="I.Projects" id="R.Plain C++" category="H.QtProjects"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint"> featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint">
<icon>console.png</icon> <icon>console.png</icon>
<description>Creates a plain C++ project using qmake, not using the Qt library.</description> <description>Creates a plain C++ project using qmake, not using the Qt library.</description>
<displayname>Plain C++ Project</displayname>; <displayname>Plain C++ Project</displayname>;
<displaycategory>Non-Qt Project</displaycategory> <displaycategory>Other Projects</displaycategory>
<files> <files>
<file source="main.cpp" openeditor="true"/> <file source="main.cpp" openeditor="true"/>
<file source="project.pro" target="%ProjectName%.pro" openproject="true"/> <file source="project.pro" target="%ProjectName%.pro" openproject="true"/>
......
...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page. ...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
--> -->
<wizard version="1" kind="project" <wizard version="1" kind="project"
class="qt4project" firstpage="10" class="qt4project" firstpage="10"
id="QmlExtensionPlugin" category="C.Projects" id="QmlExtensionPlugin" category="G.Libraries"
featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1"> featuresRequired="QtSupport.Wizards.FeatureQtQuick,QtSupport.Wizards.FeatureQtQuick.1">
<icon>lib.png</icon> <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> <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> <displayname>Custom QML Extension Plugin</displayname>
<displaycategory>QML Extension Plugin</displaycategory> <displaycategory>Libraries</displaycategory>
<files> <files>
<file source="qmldir" target="qmldir"/> <file source="qmldir" target="qmldir"/>
<file source="plugin.h" target="%ProjectName:l%_plugin.%CppHeaderSuffix%"/> <file source="plugin.h" target="%ProjectName:l%_plugin.%CppHeaderSuffix%"/>
......
...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page. ...@@ -39,12 +39,12 @@ leave room for the Qt 4 target page.
--> -->
<wizard version="1" kind="project" <wizard version="1" kind="project"
class="qt4project" firstpage="10" class="qt4project" firstpage="10"
id="R.QtCreatorPlugin" category="F.QtProjects" id="R.QtCreatorPlugin" category="G.Libraries"
featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint,QtSupport.Wizards.FeatureQt"> featuresRequired="QtSupport.Wizards.FeatureGenericCppEntryPoint,QtSupport.Wizards.FeatureQt,QtSupport.Wizards.FeatureDesktop">
<icon>qtcreator_logo_24.png</icon> <icon>qtcreator_logo_24.png</icon>
<description>Creates a custom Qt Creator plugin.</description> <description>Creates a custom Qt Creator plugin.</description>
<displayname>Qt Creator Plugin</displayname>; <displayname>Qt Creator Plugin</displayname>;
<displaycategory>Other Qt Project</displaycategory> <displaycategory>Libraries</displaycategory>
<files> <files>
<file source="myplugin.pro" target="%PluginName:l%.pro" openproject="true"/> <file source="myplugin.pro" target="%PluginName:l%.pro" openproject="true"/>
<file source="MyPlugin.pluginspec.in" target="%PluginName%.pluginspec.in" openeditor="true"/> <file source="MyPlugin.pluginspec.in" target="%PluginName%.pluginspec.in" openeditor="true"/>
......
...@@ -87,6 +87,7 @@ public: ...@@ -87,6 +87,7 @@ public:
QString category; QString category;
QString displayCategory; QString displayCategory;
Core::FeatureSet requiredFeatures; Core::FeatureSet requiredFeatures;
Core::IWizard::WizardFlags flags;
}; };
BaseFileWizardParameterData::BaseFileWizardParameterData(IWizard::WizardKind k) : BaseFileWizardParameterData::BaseFileWizardParameterData(IWizard::WizardKind k) :
...@@ -232,6 +233,15 @@ void BaseFileWizardParameters::setDisplayCategory(const QString &v) ...@@ -232,6 +233,15 @@ void BaseFileWizardParameters::setDisplayCategory(const QString &v)
m_d->displayCategory = 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 \class Core::Internal::WizardEventLoop
\brief Special event loop that runs a QWizard and terminates if the page changes. \brief Special event loop that runs a QWizard and terminates if the page changes.
...@@ -407,7 +417,7 @@ QString BaseFileWizard::displayCategory() const ...@@ -407,7 +417,7 @@ QString BaseFileWizard::displayCategory() const
return d->m_parameters.displayCategory(); 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); QTC_ASSERT(!path.isEmpty(), return);
...@@ -437,11 +447,10 @@ void BaseFileWizard::runWizard(const QString &path, QWidget *parent) ...@@ -437,11 +447,10 @@ void BaseFileWizard::runWizard(const QString &path, QWidget *parent)
// Create dialog and run it. Ensure that the dialog is deleted when // Create dialog and run it. Ensure that the dialog is deleted when
// leaving the func, but not before the IFileWizardExtension::process // leaving the func, but not before the IFileWizardExtension::process
// has been called // has been called
const QScopedPointer<QWizard> wizard(createWizardDialog(parent, const QScopedPointer<QWizard> wizard(createWizardDialog(parent, WizardDialogParameters(path,
WizardDialogParameters(path, allExtensionPages,
allExtensionPages, platform,
QString(), requiredFeatures())));
requiredFeatures())));
QTC_ASSERT(!wizard.isNull(), return); QTC_ASSERT(!wizard.isNull(), return);
GeneratedFiles files; GeneratedFiles files;
...@@ -525,6 +534,11 @@ Core::FeatureSet BaseFileWizard::requiredFeatures() const ...@@ -525,6 +534,11 @@ Core::FeatureSet BaseFileWizard::requiredFeatures() const
return d->m_parameters.requiredFeatures(); return d->m_parameters.requiredFeatures();
} }
Core::IWizard::WizardFlags BaseFileWizard::flags() const
{
return d->m_parameters.flags();
}
/*! /*!
\fn virtual QWizard *Core::BaseFileWizard::createWizardDialog(QWidget *parent, \fn virtual QWizard *Core::BaseFileWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath, const QString &defaultPath,
......
...@@ -94,6 +94,8 @@ public: ...@@ -94,6 +94,8 @@ public:
Core::FeatureSet requiredFeatures() const; Core::FeatureSet requiredFeatures() const;
void setRequiredFeatures(Core::FeatureSet features); void setRequiredFeatures(Core::FeatureSet features);
Core::IWizard::WizardFlags flags() const;
void setFlags(Core::IWizard::WizardFlags flags);
private: private:
QSharedDataPointer<BaseFileWizardParameterData> m_d; QSharedDataPointer<BaseFileWizardParameterData> m_d;
}; };
...@@ -148,8 +150,9 @@ public: ...@@ -148,8 +150,9 @@ public:
virtual QString category() const; virtual QString category() const;
virtual QString displayCategory() 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 Core::FeatureSet requiredFeatures() const;
virtual WizardFlags flags() const;
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension); static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
static void setupWizard(QWizard *); static void setupWizard(QWizard *);
......
...@@ -178,14 +178,52 @@ QList<IWizard*> IWizard::wizardsOfKind(WizardKind kind) ...@@ -178,14 +178,52 @@ QList<IWizard*> IWizard::wizardsOfKind(WizardKind kind)
return findWizards(WizardKindPredicate(kind)); return findWizards(WizardKindPredicate(kind));
} }
bool IWizard::isAvailable() const bool IWizard::isAvailable(const QString &platformName) const
{ {
FeatureSet availableFeatures; FeatureSet availableFeatures;
const QList<Core::IFeatureProvider*> featureManagers = ExtensionSystem::PluginManager::instance()->getObjects<Core::IFeatureProvider>(); const QList<Core::IFeatureProvider*> featureManagers = ExtensionSystem::PluginManager::instance()->getObjects<Core::IFeatureProvider>();
foreach (const Core::IFeatureProvider *featureManager, featureManagers) foreach (const Core::IFeatureProvider *featureManager, featureManagers)
availableFeatures |= featureManager->availableFeatures(); availableFeatures |= featureManager->availableFeatures(platformName);
return availableFeatures.contains(requiredFeatures()); 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: ...@@ -55,6 +55,10 @@ public:
ProjectWizard = 0x04 ProjectWizard = 0x04
}; };
Q_DECLARE_FLAGS(WizardKinds, WizardKind) Q_DECLARE_FLAGS(WizardKinds, WizardKind)
enum WizardFlag {
PlatformIndependent = 0x01
};
Q_DECLARE_FLAGS(WizardFlags, WizardFlag)
IWizard(QObject *parent = 0) : QObject(parent) {} IWizard(QObject *parent = 0) : QObject(parent) {}
virtual ~IWizard() {} virtual ~IWizard() {}
...@@ -69,19 +73,24 @@ public: ...@@ -69,19 +73,24 @@ public:
virtual QString displayCategory() const = 0; virtual QString displayCategory() const = 0;
virtual FeatureSet requiredFeatures() 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 // Utility to find all registered wizards
static QList<IWizard*> allWizards(); static QList<IWizard*> allWizards();
// Utility to find all registered wizards of a certain kind // Utility to find all registered wizards of a certain kind
static QList<IWizard*> wizardsOfKind(WizardKind kind); static QList<IWizard*> wizardsOfKind(WizardKind kind);
static QStringList allAvailablePlatforms();
static QString displayNameForPlatform(const QString &string);
}; };
} // namespace Core } // namespace Core
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizard::WizardKinds) Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizard::WizardKinds)
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizard::WizardFlags)
#endif // IWIZARD_H #endif // IWIZARD_H
...@@ -36,11 +36,13 @@ ...@@ -36,11 +36,13 @@
#include "iwizard.h" #include "iwizard.h"
#include <QtGui/QDialog> #include <QtGui/QDialog>
#include <QtGui/QIcon>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QModelIndex> #include <QtCore/QModelIndex>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAbstractProxyModel; class QAbstractProxyModel;
class QSortFilterProxyModel;
class QPushButton; class QPushButton;
class QStandardItem; class QStandardItem;
class QStandardItemModel; class QStandardItemModel;
...@@ -66,20 +68,26 @@ public: ...@@ -66,20 +68,26 @@ public:
void setWizards(QList<IWizard*> wizards); void setWizards(QList<IWizard*> wizards);
Core::IWizard *showDialog(); Core::IWizard *showDialog();
QString selectedPlatform() const;
int selectedWizardOption() const;
private slots: private slots:
void currentCategoryChanged(const QModelIndex &); void currentCategoryChanged(const QModelIndex &);
void currentItemChanged(const QModelIndex &); void currentItemChanged(const QModelIndex &);
void okButtonClicked(); void okButtonClicked();
void updateOkButton(); void updateOkButton();
void setSelectedPlatform(const QString &platform);
private: private:
Core::IWizard *currentWizard() const; Core::IWizard *currentWizard() const;
void addItem(QStandardItem *topLEvelCategoryItem, IWizard *wizard);
Ui::NewDialog *m_ui; Ui::NewDialog *m_ui;
QStandardItemModel *m_model; QStandardItemModel *m_model;
QAbstractProxyModel *m_proxyModel; QAbstractProxyModel *m_twoLevelProxyModel;
QSortFilterProxyModel *m_filterProxyModel;
QPushButton *m_okButton; QPushButton *m_okButton;
QPixmap m_dummyIcon; QIcon m_dummyIcon;
QList<QStandardItem*> m_categoryItems; QList<QStandardItem*> m_categoryItems;
}; };
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>554</width> <width>880</width>
<height>412</height> <height>520</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
<string>New Project</string> <string>New Project</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
...@@ -36,7 +33,43 @@ ...@@ -36,7 +33,43 @@
</property> </property>
</widget> </widget>
</item> </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"> <widget class="QTreeView" name="templateCategoryView">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
...@@ -46,10 +79,47 @@ ...@@ -46,10 +79,47 @@
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>225</width> <width>1000</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </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"> <property name="focusPolicy">
<enum>Qt::StrongFocus</enum> <enum>Qt::StrongFocus</enum>
</property> </property>
...@@ -75,7 +145,7 @@ ...@@ -75,7 +145,7 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="1" column="1" rowspan="2"> <item row="1" column="1">
<widget class="QListView" name="templatesView"> <widget class="QListView" name="templatesView">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
...@@ -100,20 +170,7 @@ ...@@ -100,20 +170,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="2" column="1" colspan="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="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -125,11 +182,6 @@ ...@@ -125,11 +182,6 @@
</item> </item>
</layout> </layout>