Fix replacement of variables in wizard parameters.

This was broken in case of no targets page being used, and using
the project name variable in default values for wizard parameters in the
page following the intro page (like it is done in the hello world
wizard).

Reviewed-by: Friedemann Kleint
This commit is contained in:
con
2010-10-27 12:51:33 +02:00
parent 54569c0624
commit 6954d89893
8 changed files with 23 additions and 15 deletions

View File

@@ -337,6 +337,12 @@ WizardProgress *Wizard::wizardProgress() const
return d->m_wizardProgress; return d->m_wizardProgress;
} }
bool Wizard::validateCurrentPage()
{
emit nextClicked();
return QWizard::validateCurrentPage();
}
void Wizard::_q_currentPageChanged(int pageId) void Wizard::_q_currentPageChanged(int pageId)
{ {
Q_D(Wizard); Q_D(Wizard);

View File

@@ -57,6 +57,11 @@ public:
void setStartId(int pageId); void setStartId(int pageId);
WizardProgress *wizardProgress() const; WizardProgress *wizardProgress() const;
virtual bool validateCurrentPage();
signals:
void nextClicked(); /* workaround for QWizard behavior where page->initialize is
called before currentIdChanged */
private slots: private slots:
void _q_currentPageChanged(int pageId); void _q_currentPageChanged(int pageId);

View File

@@ -44,14 +44,12 @@ struct BaseProjectWizardDialogPrivate {
const int desiredIntroPageId; const int desiredIntroPageId;
Utils::ProjectIntroPage *introPage; Utils::ProjectIntroPage *introPage;
int introPageId; int introPageId;
int lastId;
}; };
BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id) : BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id) :
desiredIntroPageId(id), desiredIntroPageId(id),
introPage(page), introPage(page),
introPageId(-1), introPageId(-1)
lastId(-1)
{ {
} }
@@ -82,7 +80,7 @@ void BaseProjectWizardDialog::init()
} }
wizardProgress()->item(d->introPageId)->setTitle(tr("Location")); wizardProgress()->item(d->introPageId)->setTitle(tr("Location"));
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted())); connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotBaseCurrentIdChanged(int))); connect(this, SIGNAL(nextClicked()), this, SLOT(nextClicked()));
} }
BaseProjectWizardDialog::~BaseProjectWizardDialog() BaseProjectWizardDialog::~BaseProjectWizardDialog()
@@ -125,12 +123,11 @@ void BaseProjectWizardDialog::slotAccepted()
} }
} }
void BaseProjectWizardDialog::slotBaseCurrentIdChanged(int id) void BaseProjectWizardDialog::nextClicked()
{ {
if (d->lastId == d->introPageId) { if (currentId() == d->introPageId) {
emit introPageLeft(d->introPage->projectName(), d->introPage->path()); emit projectParametersChanged(d->introPage->projectName(), d->introPage->path());
} }
d->lastId = id;
} }
Utils::ProjectIntroPage *BaseProjectWizardDialog::introPage() const Utils::ProjectIntroPage *BaseProjectWizardDialog::introPage() const

View File

@@ -73,14 +73,14 @@ public slots:
void setProjectName(const QString &name); void setProjectName(const QString &name);
signals: signals:
void introPageLeft(const QString &projectName, const QString &path); void projectParametersChanged(const QString &projectName, const QString &path);
protected: protected:
Utils::ProjectIntroPage *introPage() const; Utils::ProjectIntroPage *introPage() const;
private slots: private slots:
void slotAccepted(); void slotAccepted();
void slotBaseCurrentIdChanged(int); void nextClicked();
private: private:
void init(); void init();

View File

@@ -503,7 +503,7 @@ void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
w->setPath(defaultPath); w->setPath(defaultPath);
w->setProjectName(BaseProjectWizardDialog::uniqueProjectName(defaultPath)); w->setProjectName(BaseProjectWizardDialog::uniqueProjectName(defaultPath));
connect(w, SIGNAL(introPageLeft(QString,QString)), this, SLOT(introPageLeft(QString,QString))); connect(w, SIGNAL(projectParametersChanged(QString,QString)), this, SLOT(projectParametersChanged(QString,QString)));
if (CustomWizardPrivate::verbose) if (CustomWizardPrivate::verbose)
qDebug() << "initProjectWizardDialog" << w << w->pageIds(); qDebug() << "initProjectWizardDialog" << w << w->pageIds();
@@ -549,7 +549,7 @@ bool CustomProjectWizard::postGenerateFiles(const QWizard *, const Core::Generat
return CustomProjectWizard::postGenerateOpen(l, errorMessage); return CustomProjectWizard::postGenerateOpen(l, errorMessage);
} }
void CustomProjectWizard::introPageLeft(const QString &project, const QString & path) void CustomProjectWizard::projectParametersChanged(const QString &project, const QString & path)
{ {
// Make '%ProjectName%' available in base replacements. // Make '%ProjectName%' available in base replacements.
context()->baseReplacements.insert(QLatin1String("ProjectName"), project); context()->baseReplacements.insert(QLatin1String("ProjectName"), project);

View File

@@ -170,7 +170,7 @@ protected:
const WizardPageList &extensionPages) const; const WizardPageList &extensionPages) const;
private slots: private slots:
void introPageLeft(const QString &project, const QString &path); void projectParametersChanged(const QString &project, const QString &path);
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -72,7 +72,7 @@ QWizard *AbstractMobileAppWizard::createWizardDialog(QWidget *parent,
wdlg->m_optionsPage->setMaemoPngIcon(app()->maemoPngIcon()); wdlg->m_optionsPage->setMaemoPngIcon(app()->maemoPngIcon());
wdlg->m_optionsPage->setOrientation(app()->orientation()); wdlg->m_optionsPage->setOrientation(app()->orientation());
wdlg->m_optionsPage->setNetworkEnabled(app()->networkEnabled()); wdlg->m_optionsPage->setNetworkEnabled(app()->networkEnabled());
connect(wdlg, SIGNAL(introPageLeft(QString, QString)), connect(wdlg, SIGNAL(projectParametersChanged(QString, QString)),
SLOT(useProjectPath(QString, QString))); SLOT(useProjectPath(QString, QString)));
foreach (QWizardPage *p, extensionPages) foreach (QWizardPage *p, extensionPages)
BaseFileWizard::applyExtensionPageShortTitle(wdlg, wdlg->addPage(p)); BaseFileWizard::applyExtensionPageShortTitle(wdlg, wdlg->addPage(p));

View File

@@ -212,7 +212,7 @@ void BaseQt4ProjectWizardDialog::init(bool showModulesPage)
{ {
if (showModulesPage) if (showModulesPage)
m_modulesPage = new ModulesPage; m_modulesPage = new ModulesPage;
connect(this, SIGNAL(introPageLeft(QString,QString)), connect(this, SIGNAL(projectParametersChanged(QString,QString)),
this, SLOT(generateProfileName(QString,QString))); this, SLOT(generateProfileName(QString,QString)));
} }