Commit ce37f052 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

BaseFileWizard: Get rid of applyExtensionPageShortTitle(...)



That method was used to set a title in the progress view of the wizard
that is different from the page title. That is used exactly once and
there it adds more confusion than it helps. So get rid of the whole
thing.

Consistently set the "shortTitle" property instead for all wizards
that want to have a separate short title.

Change-Id: Ia4881e9c00891058629491f9e9de4ac421c59727
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent d0f00cc2
......@@ -47,8 +47,7 @@ FileWizardDialog::FileWizardDialog(QWidget *parent) :
Wizard(parent),
m_filePage(new FileWizardPage)
{
const int filePageId = addPage(m_filePage);
wizardProgress()->item(filePageId)->setTitle(tr("Location"));
addPage(m_filePage);
connect(m_filePage, SIGNAL(activated()), button(QWizard::FinishButton), SLOT(animateClick()));
}
......
......@@ -30,6 +30,8 @@
#include "filewizardpage.h"
#include "ui_filewizardpage.h"
#include "wizard.h"
/*!
\class Utils::FileWizardPage
......@@ -66,6 +68,8 @@ FileWizardPage::FileWizardPage(QWidget *parent) :
connect(d->m_ui.pathChooser, SIGNAL(returnPressed()), this, SLOT(slotActivated()));
connect(d->m_ui.nameLineEdit, SIGNAL(validReturnPressed()), this, SLOT(slotActivated()));
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Location"));
}
FileWizardPage::~FileWizardPage()
......
......@@ -30,6 +30,8 @@
#include "projectintropage.h"
#include "ui_projectintropage.h"
#include "wizard.h"
#include <QDir>
/*!
......@@ -96,6 +98,8 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) :
connect(d->m_ui.pathChooser, SIGNAL(returnPressed()), this, SLOT(slotActivated()));
connect(d->m_ui.nameLineEdit, SIGNAL(validReturnPressed()), this, SLOT(slotActivated()));
connect(d->m_ui.projectComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChanged()));
setProperty(SHORT_TITLE_PROPERTY, tr("Location"));
}
void ProjectIntroPage::insertControl(int row, QWidget *label, QWidget *control)
......
......@@ -32,6 +32,7 @@
#include <QMap>
#include <QHash>
#include <QVariant>
#include <QLabel>
#include <QVBoxLayout>
......@@ -389,7 +390,10 @@ void Wizard::_q_pageAdded(int pageId)
if (!d->m_automaticProgressCreation)
return;
WizardProgressItem *item = d->m_wizardProgress->addItem(page(pageId)->title());
QWizardPage *p = page(pageId);
QVariant property = p->property(SHORT_TITLE_PROPERTY);
const QString title = property.isNull() ? p->title() : property.toString();
WizardProgressItem *item = d->m_wizardProgress->addItem(title);
item->addPage(pageId);
d->m_wizardProgress->setStartPage(startId());
if (!d->m_wizardProgress->startItem())
......
......@@ -40,6 +40,8 @@ class Wizard;
class WizardProgress;
class WizardPrivate;
const char SHORT_TITLE_PROPERTY[] = "shortTitle";
class QTCREATOR_UTILS_EXPORT Wizard : public QWizard
{
Q_OBJECT
......
......@@ -329,26 +329,6 @@ bool BaseFileWizardFactory::writeFiles(const GeneratedFiles &files, QString *err
return true;
}
/*!
Reads the \c shortTitle dynamic property of \a pageId and applies it as
the title of corresponding progress item.
*/
void BaseFileWizardFactory::applyExtensionPageShortTitle(Utils::Wizard *wizard, int pageId)
{
if (pageId < 0)
return;
QWizardPage *p = wizard->page(pageId);
if (!p)
return;
Utils::WizardProgressItem *item = wizard->wizardProgress()->item(pageId);
if (!item)
return;
const QString shortTitle = p->property("shortTitle").toString();
if (!shortTitle.isEmpty())
item->setTitle(shortTitle);
}
/*!
Overwrite to perform steps to be done after files are actually created.
......@@ -529,7 +509,7 @@ BaseFileWizard *StandardFileWizardFactory::create(QWidget *parent, const WizardD
wizard->setWindowTitle(tr("New %1").arg(displayName()));
wizard->setPath(parameters.defaultPath());
foreach (QWizardPage *p, parameters.extensionPages())
BaseFileWizardFactory::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
wizard->addPage(p);
return wizard;
}
......
......@@ -112,7 +112,6 @@ public:
void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues);
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
static void applyExtensionPageShortTitle(Utils::Wizard *wizard, int pageId);
protected:
typedef QList<QWizardPage *> WizardPageList;
......
......@@ -39,6 +39,7 @@
#include <utils/codegeneration.h>
#include <utils/newclasswidget.h>
#include <utils/qtcassert.h>
#include <utils/wizard.h>
#include <QDebug>
#include <QTextStream>
......@@ -81,6 +82,8 @@ ClassNamePage::ClassNamePage(QWidget *parent) :
pageLayout->addItem(vSpacer);
initParameters();
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Details"));
}
// Retrieve settings of CppTools plugin.
......@@ -115,8 +118,7 @@ CppClassWizardDialog::CppClassWizardDialog(QWidget *parent) :
m_classNamePage(new ClassNamePage(this))
{
setWindowTitle(tr("C++ Class Wizard"));
const int classNameId = addPage(m_classNamePage);
wizardProgress()->item(classNameId)->setTitle(tr("Details"));
addPage(m_classNamePage);
}
void CppClassWizardDialog::setPath(const QString &path)
......@@ -157,7 +159,7 @@ Core::BaseFileWizard *CppClassWizard::create(QWidget *parent, const Core::Wizard
{
CppClassWizardDialog *wizard = new CppClassWizardDialog(parent);
foreach (QWizardPage *p, parameters.extensionPages())
BaseFileWizardFactory::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
wizard->addPage(p);
wizard->setPath(parameters.defaultPath());
return wizard;
}
......
......@@ -51,13 +51,10 @@ FormClassWizardDialog::FormClassWizardDialog(const WizardPageList &extensionPage
setWindowTitle(tr("Qt Designer Form Class"));
setPage(FormPageId, m_formPage);
wizardProgress()->item(FormPageId)->setTitle(tr("Form Template"));
setPage(ClassPageId, m_classPage);
wizardProgress()->item(ClassPageId)->setTitle(tr("Class Details"));
foreach (QWizardPage *p, extensionPages)
Core::BaseFileWizardFactory::applyExtensionPageShortTitle(this, addPage(p));
addPage(p);
}
QString FormClassWizardDialog::path() const
......
......@@ -31,6 +31,8 @@
#include "ui_formclasswizardpage.h"
#include "formclasswizardparameters.h"
#include <utils/wizard.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <cpptools/cpptoolsconstants.h>
......@@ -59,6 +61,8 @@ FormClassWizardPage::FormClassWizardPage(QWidget * parent) :
connect(m_ui->newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged()));
initFileGenerationSettings();
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Class Details"));
}
FormClassWizardPage::~FormClassWizardPage()
......
......@@ -30,6 +30,8 @@
#include "formtemplatewizardpage.h"
#include "formeditorw.h"
#include <utils/wizard.h>
#if QT_VERSION >= 0x050000
# include <QDesignerNewFormWidgetInterface>
#else
......@@ -71,6 +73,7 @@ FormTemplateWizardPage::FormTemplateWizardPage(QWidget * parent) :
layout->addWidget(m_newFormWidget);
setLayout(layout);
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Form Template"));
}
bool FormTemplateWizardPage::isComplete() const
......
......@@ -56,15 +56,11 @@ void FormWizardDialog::init(const WizardPageList &extensionPages)
{
setWindowTitle(tr("Qt Designer Form"));
setPage(FormPageId, m_formPage);
wizardProgress()->item(FormPageId)->setTitle(tr("Form Template"));
if (!extensionPages.empty()) {
int id = FirstExtensionPageId;
foreach (QWizardPage *p, extensionPages) {
setPage(id, p);
Core::BaseFileWizardFactory::applyExtensionPageShortTitle(this, id);
id++;
}
int id = FirstExtensionPageId;
foreach (QWizardPage *p, extensionPages) {
setPage(id, p);
++id;
}
}
......@@ -83,7 +79,6 @@ FormFileWizardDialog::FormFileWizardDialog(const WizardPageList &extensionPages,
m_filePage(new Utils::FileWizardPage)
{
setPage(FilePageId, m_filePage);
wizardProgress()->item(FilePageId)->setTitle(tr("Location"));
connect(m_filePage, SIGNAL(activated()),
button(QWizard::FinishButton), SLOT(animateClick()));
......
......@@ -36,6 +36,8 @@
#include <coreplugin/icore.h>
#include <projectexplorer/selectablefilesmodel.h>
#include <utils/wizard.h>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QPushButton>
......@@ -61,6 +63,8 @@ FilesSelectionWizardPage::FilesSelectionWizardPage(GenericProjectWizardDialog *g
layout->addWidget(m_view);
layout->addWidget(m_label);
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Files"));
}
void FilesSelectionWizardPage::createHideFileFilterControls(QVBoxLayout *layout)
......
......@@ -69,16 +69,12 @@ GenericProjectWizardDialog::GenericProjectWizardDialog(QWidget *parent) :
m_firstPage->setTitle(tr("Project Name and Location"));
m_firstPage->setFileNameLabel(tr("Project name:"));
m_firstPage->setPathLabel(tr("Location:"));
addPage(m_firstPage);
// second page
m_secondPage = new FilesSelectionWizardPage(this);
m_secondPage->setTitle(tr("File Selection"));
const int firstPageId = addPage(m_firstPage);
wizardProgress()->item(firstPageId)->setTitle(tr("Location"));
const int secondPageId = addPage(m_secondPage);
wizardProgress()->item(secondPageId)->setTitle(tr("Files"));
addPage(m_secondPage);
}
QString GenericProjectWizardDialog::path() const
......@@ -139,7 +135,7 @@ Core::BaseFileWizard *GenericProjectWizard::create(QWidget *parent, const Core::
wizard->setPath(parameters.defaultPath());
foreach (QWizardPage *p, parameters.extensionPages())
BaseFileWizardFactory::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
wizard->addPage(p);
return wizard;
}
......
......@@ -122,7 +122,7 @@ Core::BaseFileWizard *GLSLFileWizard::create(QWidget *parent, const Core::Wizard
wizard->setWindowTitle(tr("New %1").arg(displayName()));
wizard->setPath(parameters.defaultPath());
foreach (QWizardPage *p, parameters.extensionPages())
BaseFileWizardFactory::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
wizard->addPage(p);
return wizard;
}
......
......@@ -94,7 +94,6 @@ void BaseProjectWizardDialog::init()
d->introPageId = d->desiredIntroPageId;
setPage(d->desiredIntroPageId, d->introPage);
}
wizardProgress()->item(d->introPageId)->setTitle(tr("Location"));
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
connect(this, SIGNAL(nextClicked()), this, SLOT(nextClicked()));
}
......@@ -184,7 +183,7 @@ QString BaseProjectWizardDialog::uniqueProjectName(const QString &path)
void BaseProjectWizardDialog::addExtensionPages(const QList<QWizardPage *> &wizardPageList)
{
foreach (QWizardPage *p,wizardPageList)
Core::BaseFileWizardFactory::applyExtensionPageShortTitle(this, addPage(p));
addPage(p);
}
QString BaseProjectWizardDialog::selectedPlatform() const
......
......@@ -146,7 +146,7 @@ Core::BaseFileWizard *CustomWizard::create(QWidget *parent, const Core::WizardDi
if (!parameters()->fieldPageTitle.isEmpty())
customPage->setTitle(parameters()->fieldPageTitle);
foreach (QWizardPage *ep, p.extensionPages())
BaseFileWizardFactory::applyExtensionPageShortTitle(wizard, wizard->addPage(ep));
wizard->addPage(ep);
if (CustomWizardPrivate::verbose)
qDebug() << "initWizardDialog" << wizard << wizard->pageIds();
......@@ -525,7 +525,7 @@ void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
cp->setTitle(pa->fieldPageTitle);
}
foreach (QWizardPage *ep, extensionPages)
BaseFileWizardFactory::applyExtensionPageShortTitle(w, w->addPage(ep));
w->addPage(ep);
w->setPath(defaultPath);
w->setProjectName(BaseProjectWizardDialog::uniqueProjectName(defaultPath));
......
......@@ -33,6 +33,7 @@
#include <coreplugin/icore.h>
#include <utils/fileutils.h>
#include <utils/wizard.h>
#include <vcsbase/vcsbaseconstants.h>
#include <QDir>
......@@ -61,7 +62,7 @@ ProjectWizardPage::ProjectWizardPage(QWidget *parent) :
connect(m_ui->projectComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotProjectChanged(int)));
connect(m_ui->vcsManageButton, SIGNAL(clicked()), this, SLOT(slotManageVcs()));
setProperty("shortTitle", tr("Summary"));
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Summary"));
}
ProjectWizardPage::~ProjectWizardPage()
......
......@@ -43,6 +43,7 @@
#include <projectexplorer/ipotentialkit.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/wizard.h>
#include <QFileInfo>
#include <QLabel>
......@@ -179,6 +180,8 @@ TargetSetupPage::TargetSetupPage(QWidget *parent) :
this, SLOT(handleKitUpdate(ProjectExplorer::Kit*)));
connect(m_importWidget, SIGNAL(importFrom(Utils::FileName)),
this, SLOT(import(Utils::FileName)));
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Kits"));
}
void TargetSetupPage::initializePage()
......
......@@ -30,6 +30,8 @@
#include "pythonclassnamepage.h"
#include "../pythoneditorconstants.h"
#include <utils/wizard.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <utils/newclasswidget.h>
......@@ -72,6 +74,8 @@ ClassNamePage::ClassNamePage(QWidget *parent)
pageLayout->addItem(vSpacer);
initParameters();
setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Details"));
}
ClassNamePage::~ClassNamePage()
......
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