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

Replace QWizard with Utils::Wizard

parent 9408378a
...@@ -35,13 +35,14 @@ ...@@ -35,13 +35,14 @@
namespace Utils { namespace Utils {
FileWizardDialog::FileWizardDialog(QWidget *parent) : FileWizardDialog::FileWizardDialog(QWidget *parent) :
QWizard(parent), Wizard(parent),
m_filePage(new FileWizardPage) m_filePage(new FileWizardPage)
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setOption(QWizard::NoCancelButton, false); setOption(QWizard::NoCancelButton, false);
setOption(QWizard::NoDefaultButton, 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())); connect(m_filePage, SIGNAL(activated()), button(QWizard::FinishButton), SLOT(animateClick()));
} }
......
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
#define FILEWIZARDDIALOG_H #define FILEWIZARDDIALOG_H
#include "utils_global.h" #include "utils_global.h"
#include "wizard.h"
#include <QtGui/QWizard>
namespace Utils { namespace Utils {
...@@ -43,7 +42,7 @@ class FileWizardPage; ...@@ -43,7 +42,7 @@ class FileWizardPage;
and path. Custom pages can be added via Core::IWizardExtension. 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_OBJECT
Q_DISABLE_COPY(FileWizardDialog) Q_DISABLE_COPY(FileWizardDialog)
public: public:
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>Choose the location</string> <string>Choose the Location</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<item row="0" column="0"> <item row="0" column="0">
...@@ -37,17 +37,17 @@ ...@@ -37,17 +37,17 @@
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>Utils::FileNameValidatingLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">utils/filenamevalidatinglineedit.h</header>
</customwidget>
<customwidget> <customwidget>
<class>Utils::PathChooser</class> <class>Utils::PathChooser</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>pathchooser.h</header> <header>pathchooser.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>Utils::FileNameValidatingLineEdit</class>
<extends>QLineEdit</extends>
<header>filenamevalidatinglineedit.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QMap> #include <QMap>
#include <QHash> #include <QHash>
#include <QVariant>
namespace Utils { namespace Utils {
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
namespace Utils { namespace Utils {
class Wizard;
class WizardProgress; class WizardProgress;
class WizardPrivate; class WizardPrivate;
......
...@@ -84,6 +84,13 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const ...@@ -84,6 +84,13 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
setPage(ShadowBuildPageId, new ShadowBuildPage(this)); setPage(ShadowBuildPageId, new ShadowBuildPage(this));
setPage(CMakeRunPageId, new CMakeRunPage(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); setStartId(startid);
init(); init();
} }
...@@ -216,6 +223,7 @@ InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard) ...@@ -216,6 +223,7 @@ InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard)
"If you want a shadow build, clean your source directory and re-open the project.") "If you want a shadow build, clean your source directory and re-open the project.")
.arg(m_cmakeWizard->buildDirectory())); .arg(m_cmakeWizard->buildDirectory()));
layout()->addWidget(label); layout()->addWidget(label);
setTitle(tr("Build Location"));
} }
...@@ -239,6 +247,7 @@ ShadowBuildPage::ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool chang ...@@ -239,6 +247,7 @@ ShadowBuildPage::ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool chang
m_pc->setPath(m_cmakeWizard->buildDirectory()); m_pc->setPath(m_cmakeWizard->buildDirectory());
connect(m_pc, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged())); connect(m_pc, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged()));
fl->addRow(tr("Build directory:"), m_pc); fl->addRow(tr("Build directory:"), m_pc);
setTitle(tr("Build Location"));
} }
void ShadowBuildPage::buildDirectoryChanged() void ShadowBuildPage::buildDirectoryChanged()
...@@ -312,6 +321,7 @@ void CMakeRunPage::initWidgets() ...@@ -312,6 +321,7 @@ void CMakeRunPage::initWidgets()
pl.setVerticalStretch(1); pl.setVerticalStretch(1);
m_output->setSizePolicy(pl); m_output->setSizePolicy(pl);
fl->addRow(m_output); fl->addRow(m_output);
setTitle(tr("Run CMake"));
} }
void CMakeRunPage::initializePage() void CMakeRunPage::initializePage()
......
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
#define CMAKEOPENPROJECTWIZARD_H #define CMAKEOPENPROJECTWIZARD_H
#include <projectexplorer/environment.h> #include <projectexplorer/environment.h>
#include <utils/wizard.h>
#include <QtCore/QProcess> #include <QtCore/QProcess>
#include <QtGui/QPushButton> #include <QtGui/QPushButton>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QLabel> #include <QtGui/QLabel>
#include <QtGui/QWizard>
#include <QtGui/QPlainTextEdit> #include <QtGui/QPlainTextEdit>
namespace Utils { namespace Utils {
...@@ -49,7 +49,7 @@ namespace Internal { ...@@ -49,7 +49,7 @@ namespace Internal {
class CMakeManager; class CMakeManager;
class CMakeOpenProjectWizard : public QWizard class CMakeOpenProjectWizard : public Utils::Wizard
{ {
Q_OBJECT Q_OBJECT
public: public:
......
...@@ -569,6 +569,21 @@ void BaseFileWizard::setupWizard(QWizard *w) ...@@ -569,6 +569,21 @@ void BaseFileWizard::setupWizard(QWizard *w)
w->setOption(QWizard::NoBackButtonOnStartPage, true); 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) bool BaseFileWizard::postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage)
{ {
Q_UNUSED(w); Q_UNUSED(w);
...@@ -691,7 +706,7 @@ QWizard *StandardFileWizard::createWizardDialog(QWidget *parent, ...@@ -691,7 +706,7 @@ QWizard *StandardFileWizard::createWizardDialog(QWidget *parent,
setupWizard(standardWizardDialog); setupWizard(standardWizardDialog);
standardWizardDialog->setPath(defaultPath); standardWizardDialog->setPath(defaultPath);
foreach (QWizardPage *p, extensionPages) foreach (QWizardPage *p, extensionPages)
standardWizardDialog->addPage(p); BaseFileWizard::applyExtensionPageShortTitle(standardWizardDialog, standardWizardDialog->addPage(p));
return standardWizardDialog; return standardWizardDialog;
} }
......
...@@ -44,6 +44,10 @@ class QWizardPage; ...@@ -44,6 +44,10 @@ class QWizardPage;
class QDebug; class QDebug;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils {
class Wizard;
}
namespace Core { namespace Core {
class IEditor; class IEditor;
...@@ -172,6 +176,9 @@ public: ...@@ -172,6 +176,9 @@ public:
// Sets some standard options on a QWizard // Sets some standard options on a QWizard
static void setupWizard(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: protected:
typedef QList<QWizardPage *> WizardPageList; typedef QList<QWizardPage *> WizardPageList;
......
...@@ -60,7 +60,7 @@ ClassNamePage::ClassNamePage(QWidget *parent) : ...@@ -60,7 +60,7 @@ ClassNamePage::ClassNamePage(QWidget *parent) :
QWizardPage(parent), QWizardPage(parent),
m_isValid(false) 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")); setSubTitle(tr("The header and source file names will be derived from the class name"));
m_newClassWidget = new Utils::NewClassWidget; m_newClassWidget = new Utils::NewClassWidget;
...@@ -133,12 +133,13 @@ void ClassNamePage::slotValidChanged() ...@@ -133,12 +133,13 @@ void ClassNamePage::slotValidChanged()
} }
CppClassWizardDialog::CppClassWizardDialog(QWidget *parent) : CppClassWizardDialog::CppClassWizardDialog(QWidget *parent) :
QWizard(parent), Utils::Wizard(parent),
m_classNamePage(new ClassNamePage(this)) m_classNamePage(new ClassNamePage(this))
{ {
Core::BaseFileWizard::setupWizard(this); Core::BaseFileWizard::setupWizard(this);
setWindowTitle(tr("C++ Class Wizard")); 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) void CppClassWizardDialog::setPath(const QString &path)
...@@ -183,7 +184,7 @@ QWizard *CppClassWizard::createWizardDialog(QWidget *parent, ...@@ -183,7 +184,7 @@ QWizard *CppClassWizard::createWizardDialog(QWidget *parent,
{ {
CppClassWizardDialog *wizard = new CppClassWizardDialog(parent); CppClassWizardDialog *wizard = new CppClassWizardDialog(parent);
foreach (QWizardPage *p, extensionPages) foreach (QWizardPage *p, extensionPages)
wizard->addPage(p); BaseFileWizard::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
wizard->setPath(defaultPath); wizard->setPath(defaultPath);
return wizard; return wizard;
} }
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
#define CPPCLASSWIZARD_H #define CPPCLASSWIZARD_H
#include <coreplugin/basefilewizard.h> #include <coreplugin/basefilewizard.h>
#include <utils/wizard.h>
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtGui/QWizardPage> #include <QtGui/QWizardPage>
#include <QtGui/QWizard>
namespace Utils { namespace Utils {
...@@ -77,7 +77,7 @@ struct CppClassWizardParameters ...@@ -77,7 +77,7 @@ struct CppClassWizardParameters
int classType; int classType;
}; };
class CppClassWizardDialog : public QWizard class CppClassWizardDialog : public Utils::Wizard
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(CppClassWizardDialog) Q_DISABLE_COPY(CppClassWizardDialog)
......
...@@ -35,6 +35,7 @@ namespace Internal { ...@@ -35,6 +35,7 @@ namespace Internal {
CheckoutWizardPage::CheckoutWizardPage(QWidget *parent) : CheckoutWizardPage::CheckoutWizardPage(QWidget *parent) :
VCSBase::BaseCheckoutWizardPage(parent) VCSBase::BaseCheckoutWizardPage(parent)
{ {
setTitle(tr("Location"));
setSubTitle(tr("Specify repository and path.")); setSubTitle(tr("Specify repository and path."));
setRepositoryLabel(tr("Repository:")); setRepositoryLabel(tr("Repository:"));
setDirectoryVisible(false); setDirectoryVisible(false);
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include "formclasswizardpage.h" #include "formclasswizardpage.h"
#include "formclasswizardparameters.h" #include "formclasswizardparameters.h"
#include <coreplugin/basefilewizard.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtGui/QAbstractButton> #include <QtGui/QAbstractButton>
...@@ -43,20 +45,22 @@ namespace Internal { ...@@ -43,20 +45,22 @@ namespace Internal {
// ----------------- FormClassWizardDialog // ----------------- FormClassWizardDialog
FormClassWizardDialog::FormClassWizardDialog(const WizardPageList &extensionPages, FormClassWizardDialog::FormClassWizardDialog(const WizardPageList &extensionPages,
QWidget *parent) : QWidget *parent) :
QWizard(parent), Utils::Wizard(parent),
m_formPage(new FormTemplateWizardPage), m_formPage(new FormTemplateWizardPage),
m_classPage(new FormClassWizardPage) m_classPage(new FormClassWizardPage)
{ {
setWindowTitle(tr("Qt Designer Form Class")); setWindowTitle(tr("Qt Designer Form Class"));
setPage(FormPageId, m_formPage); setPage(FormPageId, m_formPage);
wizardProgress()->item(FormPageId)->setTitle(tr("Form Template"));
connect(m_formPage, SIGNAL(templateActivated()), connect(m_formPage, SIGNAL(templateActivated()),
button(QWizard::NextButton), SLOT(animateClick())); button(QWizard::NextButton), SLOT(animateClick()));
setPage(ClassPageId, m_classPage); setPage(ClassPageId, m_classPage);
wizardProgress()->item(ClassPageId)->setTitle(tr("Class Details"));
foreach (QWizardPage *p, extensionPages) foreach (QWizardPage *p, extensionPages)
addPage(p); Core::BaseFileWizard::applyExtensionPageShortTitle(this, addPage(p));
} }
QString FormClassWizardDialog::path() const QString FormClassWizardDialog::path() const
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef FORMCLASSWIZARDDIALOG_H #ifndef FORMCLASSWIZARDDIALOG_H
#define FORMCLASSWIZARDDIALOG_H #define FORMCLASSWIZARDDIALOG_H
#include <QtGui/QWizard> #include <utils/wizard.h>
namespace Designer { namespace Designer {
...@@ -42,7 +42,7 @@ namespace Internal { ...@@ -42,7 +42,7 @@ namespace Internal {
class FormClassWizardPage; class FormClassWizardPage;
class FormTemplateWizardPage; class FormTemplateWizardPage;
class FormClassWizardDialog : public QWizard class FormClassWizardDialog : public Utils::Wizard
{ {
Q_DISABLE_COPY(FormClassWizardDialog) Q_DISABLE_COPY(FormClassWizardDialog)
Q_OBJECT Q_OBJECT
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
<string>Choose a class name</string> <string>Choose a Class Name</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="0">
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="Utils::NewClassWidget" name="newClassWidget"/> <widget class="Utils::NewClassWidget" name="newClassWidget" native="true"/>
</item> </item>
</layout> </layout>
</widget> </widget>
...@@ -62,7 +62,4 @@ ...@@ -62,7 +62,4 @@
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui> </ui>
...@@ -59,7 +59,7 @@ FormTemplateWizardPage::FormTemplateWizardPage(QWidget * parent) : ...@@ -59,7 +59,7 @@ FormTemplateWizardPage::FormTemplateWizardPage(QWidget * parent) :
m_newFormWidget(QDesignerNewFormWidgetInterface::createNewFormWidget(FormEditorW::instance()->designerEditor())), m_newFormWidget(QDesignerNewFormWidgetInterface::createNewFormWidget(FormEditorW::instance()->designerEditor())),
m_templateSelected(m_newFormWidget->hasCurrentTemplate()) m_templateSelected(m_newFormWidget->hasCurrentTemplate())
{ {
setTitle(tr("Choose a form template")); setTitle(tr("Choose a Form Template"));
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
connect(m_newFormWidget, SIGNAL(currentTemplateChanged(bool)), connect(m_newFormWidget, SIGNAL(currentTemplateChanged(bool)),
......
...@@ -48,7 +48,7 @@ namespace Internal { ...@@ -48,7 +48,7 @@ namespace Internal {
// ----------------- FormWizardDialog // ----------------- FormWizardDialog
FormWizardDialog::FormWizardDialog(const WizardPageList &extensionPages, FormWizardDialog::FormWizardDialog(const WizardPageList &extensionPages,
QWidget *parent) QWidget *parent)
: QWizard(parent), : Utils::Wizard(parent),
m_formPage(new FormTemplateWizardPage) m_formPage(new FormTemplateWizardPage)
{ {
init(extensionPages); init(extensionPages);
...@@ -59,11 +59,15 @@ void FormWizardDialog::init(const WizardPageList &extensionPages) ...@@ -59,11 +59,15 @@ void FormWizardDialog::init(const WizardPageList &extensionPages)
Core::BaseFileWizard::setupWizard(this); Core::BaseFileWizard::setupWizard(this);
setWindowTitle(tr("Qt Designer Form")); setWindowTitle(tr("Qt Designer Form"));
setPage(FormPageId, m_formPage); setPage(FormPageId, m_formPage);
wizardProgress()->item(FormPageId)->setTitle(tr("Form Template"));
if (!extensionPages.empty()) { if (!extensionPages.empty()) {
int id = FirstExtensionPageId; int id = FirstExtensionPageId;
foreach (QWizardPage *p, extensionPages) foreach (QWizardPage *p, extensionPages) {
setPage(id++, p); setPage(id, p);
Core::BaseFileWizard::applyExtensionPageShortTitle(this, id);
id++;
}
} }
} }
...@@ -82,6 +86,7 @@ FormFileWizardDialog::FormFileWizardDialog(const WizardPageList &extensionPages, ...@@ -82,6 +86,7 @@ FormFileWizardDialog::FormFileWizardDialog(const WizardPageList &extensionPages,
m_filePage(new Utils::FileWizardPage) m_filePage(new Utils::FileWizardPage)
{ {
setPage(FilePageId, m_filePage); setPage(FilePageId, m_filePage);
wizardProgress()->item(FilePageId)->setTitle(tr("Location"));
connect(m_filePage, SIGNAL(activated()), connect(m_filePage, SIGNAL(activated()),
button(QWizard::FinishButton), SLOT(animateClick())); button(QWizard::FinishButton), SLOT(animateClick()));
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef FORMWIZARDDIALOG_H #ifndef FORMWIZARDDIALOG_H
#define FORMWIZARDDIALOG_H #define FORMWIZARDDIALOG_H
#include <QtGui/QWizard> #include <utils/wizard.h>