Commit c760f6d4 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

Wizards: splitting QtQuickAppWizard



QtQuickAppWizard currently has a combobox representing the choice of
Qt Quick Components + the option to import .qml.

After this patch instead of deciding this inside the wizard the decicion
is made by choosing one of 4 instances of QtQuickAppWizard.

Change-Id: If2f295b1dfc760d195dee83c59794104935016ce
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@nokia.com>
parent cc76f6ea
......@@ -38,6 +38,8 @@
#include <coreplugin/dialogs/iwizard.h>
#include <extensionsystem/iplugin.h>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QList>
......@@ -204,6 +206,18 @@ protected:
QString *errorMessage) const = 0;
};
template <class WizardClass>
QList<WizardClass*> createMultipleBaseFileWizardInstances(const QList<BaseFileWizardParameters> &parametersList, ExtensionSystem::IPlugin *plugin)
{
QList<WizardClass*> list;
foreach (const BaseFileWizardParameters &parameters, parametersList) {
WizardClass *wc = new WizardClass(parameters, 0);
plugin->addAutoReleasedObject(wc);
list << wc;
}
return list;
}
} // namespace Core
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::GeneratedFile::Attributes)
......
......@@ -139,7 +139,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
addAutoReleasedObject(new GuiAppWizard);
addAutoReleasedObject(new ConsoleAppWizard);
addAutoReleasedObject(new MobileAppWizard);
addAutoReleasedObject(new QtQuickAppWizard);
QtQuickAppWizard::createInstances(this); //creates several instances with different options
addAutoReleasedObject(new Html5AppWizard);
addAutoReleasedObject(new LibraryWizard);
addAutoReleasedObject(new TestWizard);
......
......@@ -44,6 +44,7 @@
#include <QtCore/QCoreApplication>
#include <QtGui/QIcon>
#include <QtCore/QDebug>
namespace Qt4ProjectManager {
namespace Internal {
......@@ -53,13 +54,14 @@ class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog
Q_OBJECT
public:
explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters &parameters);
explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters &parameters,
QtQuickAppWizard::Kind kind);
protected:
bool validateCurrentPage();
private:
class QtQuickComponentSetOptionsPage *m_componentOptionsPage;
QtQuickComponentSetOptionsPage *m_componentOptionsPage;
int m_componentOptionsPageId;
Utils::WizardProgressItem *m_componentItem;
......@@ -68,7 +70,8 @@ private:
};
QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
const Core::WizardDialogParameters &parameters)
const Core::WizardDialogParameters &parameters,
QtQuickAppWizard::Kind kind)
: AbstractMobileAppWizardDialog(parent,
QtSupport::QtVersionNumber(4, 7, 0),
QtSupport::QtVersionNumber(4, INT_MAX, INT_MAX), parameters)
......@@ -76,29 +79,24 @@ QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent,
setWindowTitle(tr("New Qt Quick Application"));
setIntroDescription(tr("This wizard generates a Qt Quick application project."));
if (kind == QtQuickAppWizard::ImportQml) { //Choose existing qml file
m_componentOptionsPage = new Internal::QtQuickComponentSetOptionsPage;
m_componentOptionsPageId = addPageWithTitle(m_componentOptionsPage, tr("Application Type"));
m_componentOptionsPageId = addPageWithTitle(m_componentOptionsPage, tr("Select existing QML file"));
m_componentItem = wizardProgress()->item(m_componentOptionsPageId);
}
AbstractMobileAppWizardDialog::addMobilePages();
if (kind == QtQuickAppWizard::ImportQml) {
m_componentItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< targetsPageItem());
}
}
bool QtQuickAppWizardDialog::validateCurrentPage()
{
if (currentPage() == m_componentOptionsPage) {
setIgnoreGenericOptionsPage(false);
if (m_componentOptionsPage->componentSet() == QtQuickApp::Symbian11Components) {
setIgnoreGenericOptionsPage(true);
targetsPage()->setRequiredQtFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO));
} else if (m_componentOptionsPage->componentSet() == QtQuickApp::Meego10Components) {
targetsPage()->setRequiredQtFeatures(Core::FeatureSet(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO));
} else {
targetsPage()->setMinimumQtVersion(QtSupport::QtVersionNumber(4, 7, 0));
targetsPage()->setRequiredQtFeatures(Core::FeatureSet());
}
}
return AbstractMobileAppWizardDialog::validateCurrentPage();
}
......@@ -107,11 +105,20 @@ class QtQuickAppWizardPrivate
{
class QtQuickApp *app;
class QtQuickAppWizardDialog *wizardDialog;
QtQuickAppWizard::Kind kind;
friend class QtQuickAppWizard;
};
QtQuickAppWizard::QtQuickAppWizard()
: AbstractMobileAppWizard(parameters())
: AbstractMobileAppWizard(baseParameters())
, d(new QtQuickAppWizardPrivate)
{
d->app = new QtQuickApp;
d->wizardDialog = 0;
}
QtQuickAppWizard::QtQuickAppWizard(const Core::BaseFileWizardParameters &params, QObject *parent)
: AbstractMobileAppWizard(params, parent)
, d(new QtQuickAppWizardPrivate)
{
d->app = new QtQuickApp;
......@@ -124,35 +131,103 @@ QtQuickAppWizard::~QtQuickAppWizard()
delete d;
}
Core::FeatureSet QtQuickAppWizard::requiredFeatures() const
void QtQuickAppWizard::createInstances(ExtensionSystem::IPlugin *plugin)
{
return Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK);
Core::BaseFileWizardParameters base = baseParameters();
QList<Core::BaseFileWizardParameters> list;
Core::BaseFileWizardParameters parameter;
const QString basicDescription = tr("Creates a Qt Quick application project that can contain "
"both QML and C++ code and includes a QDeclarativeView.\n\n");
Core::FeatureSet basicFeatures;
basicFeatures = Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK_1_1);
parameter = base;
parameter.setDisplayName(tr("Qt Quick Application (Built-in elements)"));
parameter.setDescription(basicDescription + tr("The built-in elements in the QtQuick namespace allow "
"you to write cross-platform applications with "
"a custom look and feel.\n\nRequires Qt 4.7.1 or newer."));
parameter.setRequiredFeatures(basicFeatures);
list << parameter;
parameter = base;
parameter.setDisplayName(tr("Qt Quick Application for Symbian"));
parameter.setDescription(basicDescription + tr("The Qt Quick Components for Symbian are a set of "
"ready-made components that are designed with specific "
"native appearance for the Symbian platform.\n\nRequires "
"Qt 4.7.4 or newer, and the component set installed for "
"your Qt version."));
parameter.setRequiredFeatures(basicFeatures | Core::Feature(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_SYMBIAN));
list << parameter;
parameter = base;
parameter.setDisplayName(tr("Qt Quick Application for MeeGo/Harmattan"));
parameter.setDescription(basicDescription + tr("The Qt Quick Components for MeeGo/Harmattan are "
"a set of ready-made components that are designed "
"with specific native appearance for the MeeGo/Harmattan "
"platform.\n\nRequires Qt 4.7.4 or newer, and the "
"component set installed for your Qt version."));
parameter.setRequiredFeatures(basicFeatures | Core::Feature(QtSupport::Constants::FEATURE_QTQUICK_COMPONENTS_MEEGO));
list << parameter;
parameter = base;
parameter.setDisplayName(tr("Qt Quick Application (from existing .qml file)"));
parameter.setDescription(basicDescription + tr("Creates a deployable Qt Quick application from "
"existing QML files. All files and directories that "
"reside in the same directory as the main QML file "
"are deployed. You can modify the contents of the "
"directory any time before deploying."));
parameter.setRequiredFeatures(basicFeatures);
list << parameter;
QList<QtQuickAppWizard*> wizardList = Core::createMultipleBaseFileWizardInstances<QtQuickAppWizard>(list, plugin);
Q_ASSERT(wizardList.count() == 4);
for (int i = 0; i < wizardList.count(); i++) {
wizardList.at(i)->setQtQuickKind(Kind(i));
}
}
Core::BaseFileWizardParameters QtQuickAppWizard::parameters()
Core::BaseFileWizardParameters QtQuickAppWizard::baseParameters()
{
Core::BaseFileWizardParameters parameters(ProjectWizard);
parameters.setIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_QTQUICK_APP)));
parameters.setDisplayName(tr("Qt Quick Application"));
parameters.setId(QLatin1String("QA.QMLA Application"));
parameters.setDescription(tr("Creates a Qt Quick application project that can contain "
"both QML and C++ code and includes a QDeclarativeView.\n\n"
"You can build the application and deploy it on desktop and "
"mobile target platforms. For example, you can create signed "
"Symbian Installation System (SIS) packages for this type of "
"projects. Moreover, you can select to use a set of premade "
"UI components in your Qt Quick application. "
"To utilize the components, Qt 4.7.4 or newer is required."));
parameters.setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY));
parameters.setDisplayCategory(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY);
return parameters;
}
AbstractMobileAppWizardDialog *QtQuickAppWizard::createWizardDialogInternal(QWidget *parent,
const Core::WizardDialogParameters &parameters) const
{
d->wizardDialog = new QtQuickAppWizardDialog(parent, parameters);
d->wizardDialog->m_componentOptionsPage->setComponentSet(d->app->componentSet());
d->wizardDialog = new QtQuickAppWizardDialog(parent, parameters, qtQuickKind());
switch (qtQuickKind()) {
case QtQuick1_1:
d->app->setComponentSet(QtQuickApp::QtQuick10Components);
d->app->setMainQml(QtQuickApp::ModeGenerate);
break;
case SymbianComponents:
d->app->setComponentSet(QtQuickApp::Symbian11Components);
d->app->setMainQml(QtQuickApp::ModeGenerate);
break;
case MeegoComponents:
d->app->setComponentSet(QtQuickApp::Meego10Components);
d->app->setMainQml(QtQuickApp::ModeGenerate);
break;
case ImportQml:
d->app->setComponentSet(QtQuickApp::QtQuick10Components);
d->app->setMainQml(QtQuickApp::ModeImport);
break;
default:
qWarning() << "QtQuickAppWizard illegal subOption:" << qtQuickKind();
break;
}
return d->wizardDialog;
}
......@@ -166,15 +241,23 @@ void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w,
{
Q_UNUSED(errorMessage)
const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w);
if (wizard->m_componentOptionsPage->mainQmlMode() == QtQuickApp::ModeGenerate) {
if (d->app->mainQmlMode() == QtQuickApp::ModeGenerate) {
d->app->setMainQml(QtQuickApp::ModeGenerate);
} else {
const QString mainQmlFile = wizard->m_componentOptionsPage->mainQmlFile();
d->app->setMainQml(QtQuickApp::ModeImport, mainQmlFile);
}
d->app->setComponentSet(wizard->m_componentOptionsPage->componentSet());
if (d->app->componentSet() == QtQuickApp::Symbian11Components)
d->app->setOrientation(AbstractMobileApp::ScreenOrientationImplicit);
}
void QtQuickAppWizard::setQtQuickKind(QtQuickAppWizard::Kind kind)
{
d->kind = kind;
}
QtQuickAppWizard::Kind QtQuickAppWizard::qtQuickKind() const
{
return d->kind;
}
QString QtQuickAppWizard::fileToOpenPostGeneration() const
......
......@@ -41,25 +41,35 @@ namespace Internal {
class QtQuickAppWizard : public AbstractMobileAppWizard
{
Q_OBJECT
public:
enum Kind {
QtQuick1_1 = 0,
SymbianComponents = 1,
MeegoComponents = 2,
ImportQml = 3
};
QtQuickAppWizard();
explicit QtQuickAppWizard(const Core::BaseFileWizardParameters &params, QObject *parent = 0);
virtual ~QtQuickAppWizard();
virtual Core::FeatureSet requiredFeatures() const;
static void createInstances(ExtensionSystem::IPlugin *plugin);
protected:
QString fileToOpenPostGeneration() const;
private:
static Core::BaseFileWizardParameters parameters();
static Core::BaseFileWizardParameters baseParameters();
virtual AbstractMobileApp *app() const;
virtual AbstractMobileAppWizardDialog *wizardDialog() const;
virtual AbstractMobileAppWizardDialog *createWizardDialogInternal(QWidget *parent,
const Core::WizardDialogParameters &parameters) const;
const Core::WizardDialogParameters &baseParameters) const;
virtual void projectPathChanged(const QString &path) const;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const;
void setQtQuickKind(Kind kind);
Kind qtQuickKind() const;
class QtQuickAppWizardPrivate *d;
};
......
......@@ -58,19 +58,8 @@ QtQuickComponentSetOptionsPage::QtQuickComponentSetOptionsPage(QWidget *parent)
d->ui.importLineEdit->setPromptDialogFilter(QLatin1String("*.qml"));
d->ui.importLineEdit->setPromptDialogTitle(tr("Select QML File"));
connect(d->ui.importLineEdit, SIGNAL(changed(QString)), SIGNAL(completeChanged()));
connect(d->ui.importRadioButton,
SIGNAL(toggled(bool)), SIGNAL(completeChanged()));
connect(d->ui.importRadioButton, SIGNAL(toggled(bool)),
d->ui.importLineEdit, SLOT(setEnabled(bool)));
d->ui.buttonGroup->setId(d->ui.qtquick10RadioButton, 0);
d->ui.buttonGroup->setId(d->ui.symbian10RadioButton, 1);
d->ui.buttonGroup->setId(d->ui.meego10RadioButton, 2);
d->ui.buttonGroup->setId(d->ui.importRadioButton, 3);
connect(d->ui.buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(radioButtonChecked(int)));
setTitle(tr("Qt Quick Application Type"));
setTitle(tr("Select Existing QML file"));
}
QtQuickComponentSetOptionsPage::~QtQuickComponentSetOptionsPage()
......@@ -78,47 +67,14 @@ QtQuickComponentSetOptionsPage::~QtQuickComponentSetOptionsPage()
delete d;
}
QtQuickApp::ComponentSet QtQuickComponentSetOptionsPage::componentSet() const
{
switch (d->ui.buttonGroup->checkedId()) {
case 2: return QtQuickApp::Meego10Components;
case 1: return QtQuickApp::Symbian11Components;
case 0:
default: return QtQuickApp::QtQuick10Components;
}
}
void QtQuickComponentSetOptionsPage::setComponentSet(QtQuickApp::ComponentSet componentSet)
{
switch (componentSet) {
case QtQuickApp::Meego10Components: d->ui.meego10RadioButton->click(); break;
case QtQuickApp::Symbian11Components: d->ui.symbian10RadioButton->click(); break;
case QtQuickApp::QtQuick10Components:
default: d->ui.qtquick10RadioButton->click(); break;
}
}
void QtQuickComponentSetOptionsPage::radioButtonChecked(int index)
{
d->ui.descriptionStackedWidget->setCurrentIndex(index);
}
QtQuickApp::Mode QtQuickComponentSetOptionsPage::mainQmlMode() const
{
return d->ui.importRadioButton->isChecked() ? QtQuickApp::ModeImport
: QtQuickApp::ModeGenerate;
}
QString QtQuickComponentSetOptionsPage::mainQmlFile() const
{
return mainQmlMode() == QtQuickApp::ModeImport ?
d->ui.importLineEdit->path() : QString();
return d->ui.importLineEdit->path();
}
bool QtQuickComponentSetOptionsPage::isComplete() const
{
return mainQmlMode() != QtQuickApp::ModeImport
|| d->ui.importLineEdit->isValid();
return d->ui.importLineEdit->isValid();
}
} // namespace Internal
......
......@@ -48,16 +48,9 @@ public:
explicit QtQuickComponentSetOptionsPage(QWidget *parent = 0);
virtual ~QtQuickComponentSetOptionsPage();
QtQuickApp::Mode mainQmlMode() const;
QString mainQmlFile() const;
virtual bool isComplete() const;
QtQuickApp::ComponentSet componentSet() const;
void setComponentSet(QtQuickApp::ComponentSet componentSet);
private slots:
void radioButtonChecked(int index);
private:
class QtQuickComponentSetOptionsPagePrivate *d;
};
......
......@@ -17,157 +17,14 @@
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="qtquick10RadioButton">
<property name="text">
<string>Built-in elements only (for all platforms)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="symbian10RadioButton">
<property name="text">
<string>Qt Quick Components for Symbian</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="meego10RadioButton">
<property name="text">
<string>Qt Quick Components for MeeGo/Harmattan</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="importRadioButton">
<property name="text">
<string>Use an existing .qml file</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Utils::PathChooser" name="importLineEdit" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QStackedWidget" name="descriptionStackedWidget">
<property name="currentIndex">
<number>3</number>
</property>
<widget class="QWidget" name="qtquick10DescriptionWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="qtquick10DescriptionLabel">
<property name="text">
<string>The built-in elements in the QtQuick namespace allow you to write cross-platform applications with a custom look and feel.
Requires Qt 4.7.1 or newer.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="symbian10DescriptionWidget">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="symbian10DescriptionLabel">
<property name="text">
<string>The Qt Quick Components for Symbian are a set of ready-made components that are designed with specific native appearance for the Symbian platform.
Requires Qt 4.7.4 or newer, and the component set installed for your Qt version.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="meego10DescriptionWidget">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="meego1DescriptionLabel">
<property name="text">
<string>The Qt Quick Components for MeeGo/Harmattan are a set of ready-made components that are designed with specific native appearance for the MeeGo/Harmattan platform.
Requires Qt 4.7.4 or newer, and the component set installed for your Qt version.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="importDescriptionWidget">
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<item>
<widget class="QLabel" name="importDescriptionLabel">
<property name="text">
<string>All files and directories that reside in the same directory as the main QML file are deployed. You can modify the contents of the directory any time before deploying.</string>
......@@ -182,10 +39,6 @@ Requires Qt 4.7.4 or newer, and the component set installed for your Qt version.
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
......@@ -200,7 +53,4 @@ Requires Qt 4.7.4 or newer, and the component set installed for your Qt version.
</customwidgets>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
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