Commit 20c0817a authored by Jarek Kobus's avatar Jarek Kobus

Replace QWizard with Utils::Wizard

parent 9408378a
......@@ -35,13 +35,14 @@
namespace Utils {
FileWizardDialog::FileWizardDialog(QWidget *parent) :
QWizard(parent),
Wizard(parent),
m_filePage(new FileWizardPage)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setOption(QWizard::NoCancelButton, false);
setOption(QWizard::NoDefaultButton, false);
addPage(m_filePage);
const int filePageId = addPage(m_filePage);
wizardProgress()->item(filePageId)->setTitle(tr("Location"));
connect(m_filePage, SIGNAL(activated()), button(QWizard::FinishButton), SLOT(animateClick()));
}
......
......@@ -31,8 +31,7 @@
#define FILEWIZARDDIALOG_H
#include "utils_global.h"
#include <QtGui/QWizard>
#include "wizard.h"
namespace Utils {
......@@ -43,7 +42,7 @@ class FileWizardPage;
and path. Custom pages can be added via Core::IWizardExtension.
*/
class QTCREATOR_UTILS_EXPORT FileWizardDialog : public QWizard {
class QTCREATOR_UTILS_EXPORT FileWizardDialog : public Wizard {
Q_OBJECT
Q_DISABLE_COPY(FileWizardDialog)
public:
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="title">
<string>Choose the location</string>
<string>Choose the Location</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
......@@ -37,17 +37,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::FileNameValidatingLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">utils/filenamevalidatinglineedit.h</header>
</customwidget>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header>pathchooser.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>Utils::FileNameValidatingLineEdit</class>
<extends>QLineEdit</extends>
<header>filenamevalidatinglineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -33,6 +33,7 @@
#include <QHBoxLayout>
#include <QMap>
#include <QHash>
#include <QVariant>
namespace Utils {
......
......@@ -38,6 +38,7 @@
namespace Utils {
class Wizard;
class WizardProgress;
class WizardPrivate;
......
......@@ -84,6 +84,13 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
setPage(ShadowBuildPageId, new ShadowBuildPage(this));
setPage(CMakeRunPageId, new CMakeRunPage(this));
Utils::WizardProgress *wp = wizardProgress();
Utils::WizardProgressItem *inSourceItem = wp->item(InSourcePageId);
Utils::WizardProgressItem *shadowBuildItem = wp->item(ShadowBuildPageId);
Utils::WizardProgressItem *cmakeRunItem = wp->item(CMakeRunPageId);
inSourceItem->setNextItems(QList<Utils::WizardProgressItem *>() << cmakeRunItem);
shadowBuildItem->setNextItems(QList<Utils::WizardProgressItem *>() << cmakeRunItem);
setStartId(startid);
init();
}
......@@ -216,6 +223,7 @@ InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard)
"If you want a shadow build, clean your source directory and re-open the project.")
.arg(m_cmakeWizard->buildDirectory()));
layout()->addWidget(label);
setTitle(tr("Build Location"));
}
......@@ -239,6 +247,7 @@ ShadowBuildPage::ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool chang
m_pc->setPath(m_cmakeWizard->buildDirectory());
connect(m_pc, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged()));
fl->addRow(tr("Build directory:"), m_pc);
setTitle(tr("Build Location"));
}
void ShadowBuildPage::buildDirectoryChanged()
......@@ -312,6 +321,7 @@ void CMakeRunPage::initWidgets()
pl.setVerticalStretch(1);
m_output->setSizePolicy(pl);
fl->addRow(m_output);
setTitle(tr("Run CMake"));
}
void CMakeRunPage::initializePage()
......
......@@ -31,13 +31,13 @@
#define CMAKEOPENPROJECTWIZARD_H
#include <projectexplorer/environment.h>
#include <utils/wizard.h>
#include <QtCore/QProcess>
#include <QtGui/QPushButton>
#include <QtGui/QComboBox>
#include <QtGui/QLineEdit>
#include <QtGui/QLabel>
#include <QtGui/QWizard>
#include <QtGui/QPlainTextEdit>
namespace Utils {
......@@ -49,7 +49,7 @@ namespace Internal {
class CMakeManager;
class CMakeOpenProjectWizard : public QWizard
class CMakeOpenProjectWizard : public Utils::Wizard
{
Q_OBJECT
public:
......
......@@ -569,6 +569,21 @@ void BaseFileWizard::setupWizard(QWizard *w)
w->setOption(QWizard::NoBackButtonOnStartPage, true);
}
void BaseFileWizard::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);
}
bool BaseFileWizard::postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage)
{
Q_UNUSED(w);
......@@ -691,7 +706,7 @@ QWizard *StandardFileWizard::createWizardDialog(QWidget *parent,
setupWizard(standardWizardDialog);
standardWizardDialog->setPath(defaultPath);
foreach (QWizardPage *p, extensionPages)
standardWizardDialog->addPage(p);
BaseFileWizard::applyExtensionPageShortTitle(standardWizardDialog, standardWizardDialog->addPage(p));
return standardWizardDialog;
}
......
......@@ -44,6 +44,10 @@ class QWizardPage;
class QDebug;
QT_END_NAMESPACE
namespace Utils {
class Wizard;
}
namespace Core {
class IEditor;
......@@ -172,6 +176,9 @@ public:
// Sets some standard options on a QWizard
static void setupWizard(QWizard *);
// Read "shortTitle" dynamic property of the pageId and apply it as the title of corresponding progress item
static void applyExtensionPageShortTitle(Utils::Wizard *wizard, int pageId);
protected:
typedef QList<QWizardPage *> WizardPageList;
......
......@@ -60,7 +60,7 @@ ClassNamePage::ClassNamePage(QWidget *parent) :
QWizardPage(parent),
m_isValid(false)
{
setTitle(tr("Enter class name"));
setTitle(tr("Enter Class Name"));
setSubTitle(tr("The header and source file names will be derived from the class name"));
m_newClassWidget = new Utils::NewClassWidget;
......@@ -133,12 +133,13 @@ void ClassNamePage::slotValidChanged()
}
CppClassWizardDialog::CppClassWizardDialog(QWidget *parent) :
QWizard(parent),
Utils::Wizard(parent),
m_classNamePage(new ClassNamePage(this))
{
Core::BaseFileWizard::setupWizard(this);
setWindowTitle(tr("C++ Class Wizard"));
addPage(m_classNamePage);
const int classNameId = addPage(m_classNamePage);
wizardProgress()->item(classNameId)->setTitle(tr("Details"));
}
void CppClassWizardDialog::setPath(const QString &path)
......@@ -183,7 +184,7 @@ QWizard *CppClassWizard::createWizardDialog(QWidget *parent,
{
CppClassWizardDialog *wizard = new CppClassWizardDialog(parent);
foreach (QWizardPage *p, extensionPages)
wizard->addPage(p);
BaseFileWizard::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
wizard->setPath(defaultPath);
return wizard;
}
......
......@@ -31,10 +31,10 @@
#define CPPCLASSWIZARD_H
#include <coreplugin/basefilewizard.h>
#include <utils/wizard.h>
#include <QtCore/QStringList>
#include <QtGui/QWizardPage>
#include <QtGui/QWizard>
namespace Utils {
......@@ -77,7 +77,7 @@ struct CppClassWizardParameters
int classType;
};
class CppClassWizardDialog : public QWizard
class CppClassWizardDialog : public Utils::Wizard
{
Q_OBJECT
Q_DISABLE_COPY(CppClassWizardDialog)
......
......@@ -35,6 +35,7 @@ namespace Internal {
CheckoutWizardPage::CheckoutWizardPage(QWidget *parent) :
VCSBase::BaseCheckoutWizardPage(parent)
{
setTitle(tr("Location"));
setSubTitle(tr("Specify repository and path."));
setRepositoryLabel(tr("Repository:"));
setDirectoryVisible(false);
......
......@@ -32,6 +32,8 @@
#include "formclasswizardpage.h"
#include "formclasswizardparameters.h"
#include <coreplugin/basefilewizard.h>
#include <QtCore/QDebug>
#include <QtGui/QAbstractButton>
......@@ -43,20 +45,22 @@ namespace Internal {
// ----------------- FormClassWizardDialog
FormClassWizardDialog::FormClassWizardDialog(const WizardPageList &extensionPages,
QWidget *parent) :
QWizard(parent),
Utils::Wizard(parent),
m_formPage(new FormTemplateWizardPage),
m_classPage(new FormClassWizardPage)
{
setWindowTitle(tr("Qt Designer Form Class"));
setPage(FormPageId, m_formPage);
wizardProgress()->item(FormPageId)->setTitle(tr("Form Template"));
connect(m_formPage, SIGNAL(templateActivated()),
button(QWizard::NextButton), SLOT(animateClick()));
setPage(ClassPageId, m_classPage);
wizardProgress()->item(ClassPageId)->setTitle(tr("Class Details"));
foreach (QWizardPage *p, extensionPages)
addPage(p);
Core::BaseFileWizard::applyExtensionPageShortTitle(this, addPage(p));
}
QString FormClassWizardDialog::path() const
......
......@@ -30,7 +30,7 @@
#ifndef FORMCLASSWIZARDDIALOG_H
#define FORMCLASSWIZARDDIALOG_H
#include <QtGui/QWizard>
#include <utils/wizard.h>
namespace Designer {
......@@ -42,7 +42,7 @@ namespace Internal {
class FormClassWizardPage;
class FormTemplateWizardPage;
class FormClassWizardDialog : public QWizard
class FormClassWizardDialog : public Utils::Wizard
{
Q_DISABLE_COPY(FormClassWizardDialog)
Q_OBJECT
......
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="title">
<string>Choose a class name</string>
<string>Choose a Class Name</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
......@@ -21,7 +21,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="Utils::NewClassWidget" name="newClassWidget"/>
<widget class="Utils::NewClassWidget" name="newClassWidget" native="true"/>
</item>
</layout>
</widget>
......@@ -62,7 +62,4 @@
</customwidgets>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
......@@ -59,7 +59,7 @@ FormTemplateWizardPage::FormTemplateWizardPage(QWidget * parent) :
m_newFormWidget(QDesignerNewFormWidgetInterface::createNewFormWidget(FormEditorW::instance()->designerEditor())),
m_templateSelected(m_newFormWidget->hasCurrentTemplate())
{
setTitle(tr("Choose a form template"));
setTitle(tr("Choose a Form Template"));
QVBoxLayout *layout = new QVBoxLayout;
connect(m_newFormWidget, SIGNAL(currentTemplateChanged(bool)),
......
......@@ -48,7 +48,7 @@ namespace Internal {
// ----------------- FormWizardDialog
FormWizardDialog::FormWizardDialog(const WizardPageList &extensionPages,
QWidget *parent)
: QWizard(parent),
: Utils::Wizard(parent),
m_formPage(new FormTemplateWizardPage)
{
init(extensionPages);
......@@ -59,11 +59,15 @@ void FormWizardDialog::init(const WizardPageList &extensionPages)
Core::BaseFileWizard::setupWizard(this);
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);
foreach (QWizardPage *p, extensionPages) {
setPage(id, p);
Core::BaseFileWizard::applyExtensionPageShortTitle(this, id);
id++;
}
}
}
......@@ -82,6 +86,7 @@ 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()));
......
......@@ -30,7 +30,7 @@
#ifndef FORMWIZARDDIALOG_H
#define FORMWIZARDDIALOG_H
#include <QtGui/QWizard>
#include <utils/wizard.h>
namespace Utils {
class FileWizardPage;
......@@ -44,7 +44,7 @@ class FormTemplateWizardPage;
// Single-Page Wizard for new forms offering all types known to Qt Designer.
// To be used for Mode "CreateNewEditor" [not currently used]
class FormWizardDialog : public QWizard
class FormWizardDialog : public Utils::Wizard
{
Q_DISABLE_COPY(FormWizardDialog)
Q_OBJECT
......
......@@ -51,7 +51,7 @@ using namespace Utils;
//////////////////////////////////////////////////////////////////////////////
GenericProjectWizardDialog::GenericProjectWizardDialog(QWidget *parent)
: QWizard(parent)
: Utils::Wizard(parent)
{
setWindowTitle(tr("Import Existing Project"));
......@@ -61,7 +61,8 @@ GenericProjectWizardDialog::GenericProjectWizardDialog(QWidget *parent)
m_firstPage->setFileNameLabel(tr("Project name:"));
m_firstPage->setPathLabel(tr("Location:"));
addPage(m_firstPage);
const int firstPageId = addPage(m_firstPage);
wizardProgress()->item(firstPageId)->setTitle(tr("Location"));
}
GenericProjectWizardDialog::~GenericProjectWizardDialog()
......@@ -111,7 +112,7 @@ QWizard *GenericProjectWizard::createWizardDialog(QWidget *parent,
wizard->setPath(defaultPath);
foreach (QWizardPage *p, extensionPages)
wizard->addPage(p);
BaseFileWizard::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
return wizard;
}
......
......@@ -31,8 +31,7 @@
#define GENERICPROJECTWIZARD_H
#include <coreplugin/basefilewizard.h>
#include <QtGui/QWizard>
#include <utils/wizard.h>
QT_BEGIN_NAMESPACE
class QFileInfo;
......@@ -48,7 +47,7 @@ class FileWizardPage;
namespace GenericProjectManager {
namespace Internal {
class GenericProjectWizardDialog : public QWizard
class GenericProjectWizardDialog : public Utils::Wizard
{
Q_OBJECT
......
......@@ -55,6 +55,7 @@ CloneWizardPage::CloneWizardPage(QWidget *parent) :
VCSBase::BaseCheckoutWizardPage(parent),
d(new CloneWizardPagePrivate)
{
setTitle(tr("Location"));
setSubTitle(tr("Specify repository URL, checkout directory and path."));
setRepositoryLabel(tr("Clone URL:"));
}
......
......@@ -73,6 +73,7 @@ GitoriousHostWizardPage::GitoriousHostWizardPage(QWidget *parent) :
QVBoxLayout *lt = new QVBoxLayout;
lt->addWidget(m_widget);
setLayout(lt);
setTitle(tr("Host"));
setSubTitle(tr("Select a host."));
}
......
......@@ -50,6 +50,7 @@ GitoriousProjectWizardPage::GitoriousProjectWizardPage(const GitoriousHostWizard
QVBoxLayout *lt = new QVBoxLayout;
lt->addWidget(m_stackedWidget);
setLayout(lt);
setTitle(tr("Project"));
}
static inline QString msgChooseProject(const QString &h)
......
......@@ -97,6 +97,8 @@ GitoriousRepositoryWizardPage::GitoriousRepositoryWizardPage(const GitoriousProj
ui->repositoryTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
connect(ui->repositoryTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(slotCurrentChanged(QModelIndex,QModelIndex)));
setTitle(tr("Repository"));
}
GitoriousRepositoryWizardPage::~GitoriousRepositoryWizardPage()
......
......@@ -34,6 +34,8 @@ using namespace Mercurial::Internal;
CloneWizardPage::CloneWizardPage(QWidget *parent)
: VCSBase::BaseCheckoutWizardPage(parent)
{
setTitle(tr("Location"));
setSubTitle(tr("Specify repository URL, checkout directory and path."));
setRepositoryLabel(tr("Clone URL:"));
}
......
......@@ -56,7 +56,7 @@ BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectInt
}
BaseProjectWizardDialog::BaseProjectWizardDialog(QWidget *parent) :
QWizard(parent),
Utils::Wizard(parent),
d(new BaseProjectWizardDialogPrivate(new Utils::ProjectIntroPage))
{
init();
......@@ -65,7 +65,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(QWidget *parent) :
BaseProjectWizardDialog::BaseProjectWizardDialog(Utils::ProjectIntroPage *introPage,
int introId,
QWidget *parent) :
QWizard(parent),
Utils::Wizard(parent),
d(new BaseProjectWizardDialogPrivate(introPage, introId))
{
init();
......@@ -80,6 +80,7 @@ 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(currentIdChanged(int)), this, SLOT(slotBaseCurrentIdChanged(int)));
}
......
......@@ -31,6 +31,7 @@
#define BASEPROJECTWIZARDDIALOG_H
#include "projectexplorer_export.h"
#include <utils/wizard.h>
#include <QtGui/QWizard>
......@@ -46,7 +47,7 @@ struct BaseProjectWizardDialogPrivate;
* page and takes care of setting the directory as default
* should the user wish to do that. */
class PROJECTEXPLORER_EXPORT BaseProjectWizardDialog : public QWizard
class PROJECTEXPLORER_EXPORT BaseProjectWizardDialog : public Utils::Wizard
{
Q_OBJECT
......
......@@ -43,6 +43,7 @@
#include <QtCore/QMap>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
static const char templatePathC[] = "templates/wizards";
static const char configFileC[] = "wizard.xml";
......@@ -87,22 +88,25 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p)
}
// Add a wizard page with an id, visibly warn if something goes wrong.
static inline void addWizardPage(QWizard *w, QWizardPage *p, int id)
static inline void addWizardPage(Utils::Wizard *w, QWizardPage *p, int id)
{
int addedPageId = 0;
if (id == -1) {
w->addPage(p);
addedPageId = w->addPage(p);
} else {
if (w->pageIds().contains(id)) {
qWarning("Page %d already present in custom wizard dialog, defaulting to add.", id);
w->addPage(p);
addedPageId = w->addPage(p);
} else {
w->setPage(id, p);
addedPageId = id;
}
}
w->wizardProgress()->item(addedPageId)->setTitle(QCoreApplication::translate("ProjectExplorer::CustomWizard", "Details", "Default short title for custom wizard page to be shown in the progress pane of the wizard."));
}
// Initialize a wizard with a custom file page.
void CustomWizard::initWizardDialog(QWizard *wizard, const QString &defaultPath,
void CustomWizard::initWizardDialog(Utils::Wizard *wizard, const QString &defaultPath,
const WizardPageList &extensionPages) const
{
QTC_ASSERT(!parameters().isNull(), return);
......@@ -114,7 +118,7 @@ void CustomWizard::initWizardDialog(QWizard *wizard, const QString &defaultPath,
if (!parameters()->fieldPageTitle.isEmpty())
customPage->setTitle(parameters()->fieldPageTitle);
foreach(QWizardPage *ep, extensionPages)
wizard->addPage(ep);
BaseFileWizard::applyExtensionPageShortTitle(wizard, wizard->addPage(ep));
Core::BaseFileWizard::setupWizard(wizard);
if (CustomWizardPrivate::verbose)
qDebug() << "initWizardDialog" << wizard << wizard->pageIds();
......@@ -125,7 +129,7 @@ QWizard *CustomWizard::createWizardDialog(QWidget *parent,
const WizardPageList &extensionPages) const
{