Commit b735b433 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QML/Mobile wizard: Final redundancy removal.

Task-number: QTCREATORBUG-2341 (en passant)
Reviewed-by: Alessandro Portale
parent 8fc775eb
......@@ -38,6 +38,7 @@ HEADERS += qt4deployconfiguration.h \
wizards/qmlstandaloneappwizardpages.h \
wizards/abstractmobileapp.h \
wizards/qmlstandaloneapp.h \
wizards/abstractmobileappwizard.h \
qt4projectmanagerconstants.h \
makestep.h \
qmakestep.h \
......@@ -54,7 +55,7 @@ HEADERS += qt4deployconfiguration.h \
qt4buildconfiguration.h \
qt4target.h \
qmakeparser.h \
qtoutputformatter.h \
qtoutputformatter.h \
addlibrarywizard.h \
librarydetailscontroller.h \
findqt4profiles.h \
......@@ -93,6 +94,7 @@ SOURCES += qt4projectmanagerplugin.cpp \
wizards/qmlstandaloneappwizardpages.cpp \
wizards/abstractmobileapp.cpp \
wizards/qmlstandaloneapp.cpp \
wizards/abstractmobileappwizard.cpp \
makestep.cpp \
qmakestep.cpp \
qt4runconfiguration.cpp \
......
......@@ -108,11 +108,17 @@ public:
QString symbianTargetUid() const;
void setNetworkEnabled(bool enabled);
bool networkEnabled() const;
QString path(int fileType) const;
QString error() const;
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
static QString symbianUidForPath(const QString &path);
static int makeStubVersion(int minor);
QString path(int fileType) const;
QString error() const;
static const QString DeploymentPriFileName;
protected:
......@@ -122,15 +128,13 @@ protected:
static void insertParameter(QString &line, const QString &parameter);
QByteArray readBlob(const QString &filePath, QString *errorMsg) const;
QByteArray generateFile(int fileType, QString *errorMessage) const;
QString outputPathBase() const;
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
static Core::GeneratedFile file(const QByteArray &data,
const QString &targetFile);
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
QByteArray generateFile(int fileType, QString *errorMessage) const;
QString outputPathBase() const;
static const QString CFileComment;
static const QString ProFileComment;
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "abstractmobileappwizard.h"
#include "abstractmobileapp.h"
#include "mobileappwizardpages.h"
#include <QtGui/QIcon>
namespace Qt4ProjectManager {
namespace Internal {
AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent)
: ProjectExplorer::BaseProjectWizardDialog(parent)
{
m_optionsPage = new MobileAppWizardOptionsPage;
const int pageId = addPage(m_optionsPage);
wizardProgress()->item(pageId)->setTitle(tr("Application options"));
}
AbstractMobileAppWizard::AbstractMobileAppWizard(const Core::BaseFileWizardParameters &params,
QObject *parent) : Core::BaseFileWizard(params, parent)
{
}
QWizard *AbstractMobileAppWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath, const WizardPageList &extensionPages) const
{
AbstractMobileAppWizardDialog * const wdlg
= createWizardDialogInternal(parent);
wdlg->setPath(defaultPath);
wdlg->setProjectName(ProjectExplorer::BaseProjectWizardDialog::uniqueProjectName(defaultPath));
wdlg->m_optionsPage->setSymbianSvgIcon(app()->symbianSvgIcon());
wdlg->m_optionsPage->setMaemoPngIcon(app()->maemoPngIcon());
wdlg->m_optionsPage->setOrientation(app()->orientation());
wdlg->m_optionsPage->setNetworkEnabled(app()->networkEnabled());
connect(wdlg, SIGNAL(introPageLeft(QString, QString)),
SLOT(useProjectPath(QString, QString)));
foreach (QWizardPage *p, extensionPages)
BaseFileWizard::applyExtensionPageShortTitle(wdlg, wdlg->addPage(p));
return wdlg;
}
Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizard,
QString *errorMessage) const
{
prepareGenerateFiles(wizard, errorMessage);
const AbstractMobileAppWizardDialog *wdlg
= qobject_cast<const AbstractMobileAppWizardDialog*>(wizard);
app()->setProjectName(wdlg->projectName());
app()->setProjectPath(wdlg->path());
app()->setSymbianTargetUid(wdlg->m_optionsPage->symbianUid());
app()->setSymbianSvgIcon(wdlg->m_optionsPage->symbianSvgIcon());
app()->setOrientation(wdlg->m_optionsPage->orientation());
app()->setNetworkEnabled(wdlg->m_optionsPage->networkEnabled());
return app()->generateFiles(errorMessage);
}
void AbstractMobileAppWizard::useProjectPath(const QString &projectName,
const QString &projectPath)
{
wizardDialog()->m_optionsPage->setSymbianUid(app()->symbianUidForPath(projectPath + projectName));
}
} // end of namespace Internal
} // end of namespace Qt4ProjectManager
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef ABSTRACTMOBILEAPPWIZARD_H
#define ABSTRACTMOBILEAPPWIZARD_H
#include <coreplugin/basefilewizard.h>
#include <projectexplorer/baseprojectwizarddialog.h>
namespace Qt4ProjectManager {
namespace Internal {
class AbstractMobileApp;
class AbstractMobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
{
Q_OBJECT
friend class AbstractMobileAppWizard;
protected:
explicit AbstractMobileAppWizardDialog(QWidget *parent = 0);
private:
class MobileAppWizardOptionsPage *m_optionsPage;
};
class AbstractMobileAppWizard : public Core::BaseFileWizard
{
Q_OBJECT
protected:
explicit AbstractMobileAppWizard(const Core::BaseFileWizardParameters &params,
QObject *parent = 0);
private slots:
void useProjectPath(const QString &projectName, const QString &projectPath);
private:
virtual QWizard *createWizardDialog(QWidget *parent,
const QString &defaultPath, const WizardPageList &extensionPages) const;
virtual Core::GeneratedFiles generateFiles(const QWizard *wizard,
QString *errorMessage) const;
virtual AbstractMobileApp *app() const=0;
virtual AbstractMobileAppWizardDialog *wizardDialog() const=0;
virtual AbstractMobileAppWizardDialog *createWizardDialogInternal(QWidget *parent) const=0;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const=0;
};
} // end of namespace Internal
} // end of namespace Qt4ProjectManager
#endif // ABSTRACTMOBILEAPPWIZARD_H
......@@ -33,17 +33,12 @@
#include "qt4projectmanagerconstants.h"
#include <projectexplorer/baseprojectwizarddialog.h>
#include <projectexplorer/customwizard/customwizard.h>
#include <projectexplorer/projectexplorer.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtGui/QIcon>
#include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtGui/QIcon>
namespace Qt4ProjectManager {
namespace Internal {
......@@ -57,28 +52,18 @@ const QString Description
"Preselects Qt for Simulator and mobile targets if available.");
}
class MobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
class MobileAppWizardDialog : public AbstractMobileAppWizardDialog
{
Q_OBJECT
public:
explicit MobileAppWizardDialog(QWidget *parent = 0);
private:
class MobileAppWizardOptionsPage *m_optionsPage;
friend class MobileAppWizard;
explicit MobileAppWizardDialog(QWidget *parent = 0)
: AbstractMobileAppWizardDialog(parent)
{
setWindowTitle(DisplayName);
setIntroDescription(Description);
}
};
MobileAppWizardDialog::MobileAppWizardDialog(QWidget *parent)
: ProjectExplorer::BaseProjectWizardDialog(parent)
{
setWindowTitle(DisplayName);
setIntroDescription(Description);
m_optionsPage = new MobileAppWizardOptionsPage;
const int optionsPagePageId = addPage(m_optionsPage);
wizardProgress()->item(optionsPagePageId)->setTitle(tr("Application options"));
}
class MobileAppWizardPrivate
{
class MobileApp *mobileApp;
......@@ -87,7 +72,7 @@ class MobileAppWizardPrivate
};
MobileAppWizard::MobileAppWizard()
: Core::BaseFileWizard(parameters())
: AbstractMobileAppWizard(parameters())
, m_d(new MobileAppWizardPrivate)
{
m_d->mobileApp = new MobileApp;
......@@ -113,39 +98,17 @@ Core::BaseFileWizardParameters MobileAppWizard::parameters()
return parameters;
}
QWizard *MobileAppWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath, const WizardPageList &extensionPages) const
AbstractMobileAppWizardDialog *MobileAppWizard::createWizardDialogInternal(QWidget *parent) const
{
m_d->wizardDialog = new MobileAppWizardDialog(parent);
m_d->wizardDialog->setPath(defaultPath);
m_d->wizardDialog->setProjectName(MobileAppWizardDialog::uniqueProjectName(defaultPath));
m_d->wizardDialog->m_optionsPage->setSymbianSvgIcon(m_d->mobileApp->symbianSvgIcon());
m_d->wizardDialog->m_optionsPage->setMaemoPngIcon(m_d->mobileApp->maemoPngIcon());
m_d->wizardDialog->m_optionsPage->setOrientation(m_d->mobileApp->orientation());
m_d->wizardDialog->m_optionsPage->setNetworkEnabled(m_d->mobileApp->networkEnabled());
connect(m_d->wizardDialog, SIGNAL(introPageLeft(QString, QString)), SLOT(useProjectPath(QString, QString)));
foreach (QWizardPage *p, extensionPages)
BaseFileWizard::applyExtensionPageShortTitle(m_d->wizardDialog, m_d->wizardDialog->addPage(p));
return m_d->wizardDialog;
}
Core::GeneratedFiles MobileAppWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
void MobileAppWizard::prepareGenerateFiles(const QWizard *w,
QString *errorMessage) const
{
Q_UNUSED(w);
Q_UNUSED(errorMessage)
const MobileAppWizardDialog *wizard = qobject_cast<const MobileAppWizardDialog*>(w);
m_d->mobileApp->setProjectName(wizard->projectName());
m_d->mobileApp->setProjectPath(wizard->path());
m_d->mobileApp->setSymbianTargetUid(wizard->m_optionsPage->symbianUid());
m_d->mobileApp->setSymbianSvgIcon(wizard->m_optionsPage->symbianSvgIcon());
m_d->mobileApp->setOrientation(wizard->m_optionsPage->orientation());
m_d->mobileApp->setNetworkEnabled(wizard->m_optionsPage->networkEnabled());
return m_d->mobileApp->generateFiles(errorMessage);
}
bool MobileAppWizard::postGenerateFiles(const QWizard *wizard, const Core::GeneratedFiles &l, QString *errorMessage)
......@@ -154,9 +117,14 @@ bool MobileAppWizard::postGenerateFiles(const QWizard *wizard, const Core::Gener
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
}
void MobileAppWizard::useProjectPath(const QString &projectName, const QString &projectPath)
AbstractMobileApp *MobileAppWizard::app() const
{
m_d->wizardDialog->m_optionsPage->setSymbianUid(MobileApp::symbianUidForPath(projectPath + projectName));
return m_d->mobileApp;
}
AbstractMobileAppWizardDialog *MobileAppWizard::wizardDialog() const
{
return m_d->wizardDialog;
}
} // namespace Internal
......
......@@ -30,32 +30,31 @@
#ifndef MOBILEAPPWIZARD_H
#define MOBILEAPPWIZARD_H
#include <coreplugin/basefilewizard.h>
#include "abstractmobileappwizard.h"
namespace Qt4ProjectManager {
namespace Internal {
class MobileAppWizard : public Core::BaseFileWizard
class MobileAppWizard : public AbstractMobileAppWizard
{
Q_OBJECT
public:
MobileAppWizard();
virtual ~MobileAppWizard();
private:
static Core::BaseFileWizardParameters parameters();
protected:
QWizard *createWizardDialog(QWidget *parent, const QString &defaultPath,
const WizardPageList &extensionPages) const;
Core::GeneratedFiles generateFiles(const QWizard *wizard,
QString *errorMessage) const;
bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l,
QString *errorMessage);
private slots:
void useProjectPath(const QString &projectName, const QString &projectPath);
virtual AbstractMobileApp *app() const;
virtual AbstractMobileAppWizardDialog *wizardDialog() const;
virtual AbstractMobileAppWizardDialog *createWizardDialogInternal(QWidget *parent) const;
virtual void prepareGenerateFiles(const QWizard *wizard,
QString *errorMessage) const;
private:
class MobileAppWizardPrivate *m_d;
};
......
......@@ -60,11 +60,11 @@ MobileAppWizardOptionsPage::MobileAppWizardOptionsPage(QWidget *parent)
SLOT(openMaemoPngIcon()));
m_d->ui.orientationBehaviorComboBox->addItem(tr("Auto rotate orientation"),
MobileApp::Auto);
AbstractMobileApp::Auto);
m_d->ui.orientationBehaviorComboBox->addItem(tr("Lock to landscape orientation"),
MobileApp::LockLandscape);
AbstractMobileApp::LockLandscape);
m_d->ui.orientationBehaviorComboBox->addItem(tr("Lock to portrait orientation"),
MobileApp::LockPortrait);
AbstractMobileApp::LockPortrait);
}
MobileAppWizardOptionsPage::~MobileAppWizardOptionsPage()
......@@ -72,7 +72,7 @@ MobileAppWizardOptionsPage::~MobileAppWizardOptionsPage()
delete m_d;
}
void MobileAppWizardOptionsPage::setOrientation(MobileApp::Orientation orientation)
void MobileAppWizardOptionsPage::setOrientation(AbstractMobileApp::Orientation orientation)
{
QComboBox *const comboBox = m_d->ui.orientationBehaviorComboBox;
for (int i = 0; i < comboBox->count(); ++i)
......@@ -82,10 +82,10 @@ void MobileAppWizardOptionsPage::setOrientation(MobileApp::Orientation orientati
}
}
MobileApp::Orientation MobileAppWizardOptionsPage::orientation() const
AbstractMobileApp::Orientation MobileAppWizardOptionsPage::orientation() const
{
const int index = m_d->ui.orientationBehaviorComboBox->currentIndex();
return static_cast<MobileApp::Orientation>(m_d->ui.orientationBehaviorComboBox->itemData(index).toInt());
return static_cast<AbstractMobileApp::Orientation>(m_d->ui.orientationBehaviorComboBox->itemData(index).toInt());
}
QString MobileAppWizardOptionsPage::symbianSvgIcon() const
......
......@@ -30,7 +30,7 @@
#ifndef MOBILEAPPWIZARDPAGES_H
#define MOBILEAPPWIZARDPAGES_H
#include "mobileapp.h"
#include "abstractmobileapp.h"
#include <QtGui/QWizardPage>
......@@ -46,8 +46,8 @@ public:
explicit MobileAppWizardOptionsPage(QWidget *parent = 0);
virtual ~MobileAppWizardOptionsPage();
void setOrientation(MobileApp::Orientation orientation);
MobileApp::Orientation orientation() const;
void setOrientation(AbstractMobileApp::Orientation orientation);
AbstractMobileApp::Orientation orientation() const;
QString symbianSvgIcon() const;
void setSymbianSvgIcon(const QString &icon);
QString maemoPngIcon() const;
......
......@@ -28,9 +28,9 @@
**************************************************************************/
#include "mobileappwizardpages.h"
#include "qmlstandaloneapp.h"
#include "qmlstandaloneappwizard.h"
#include "qmlstandaloneappwizardpages.h"
#include "qmlstandaloneapp.h"
#include "qt4projectmanagerconstants.h"
......@@ -39,20 +39,13 @@
#include <projectexplorer/projectexplorer.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtGui/QIcon>
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#include <QtCore/QTextStream>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtGui/QIcon>
namespace Qt4ProjectManager {
namespace Internal {
class QmlStandaloneAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
class QmlStandaloneAppWizardDialog : public AbstractMobileAppWizardDialog
{
Q_OBJECT
......@@ -62,13 +55,12 @@ public:
private:
QmlStandaloneAppWizard::WizardType m_type;
class QmlStandaloneAppWizardSourcesPage *m_qmlSourcesPage;
class MobileAppWizardOptionsPage *m_qmlOptionsPage;
friend class QmlStandaloneAppWizard;
};
QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QmlStandaloneAppWizard::WizardType type,
QWidget *parent)
: ProjectExplorer::BaseProjectWizardDialog(parent)
: AbstractMobileAppWizardDialog(parent)
, m_type(type)
{
setWindowTitle(m_type == QmlStandaloneAppWizard::NewQmlFile
......@@ -80,20 +72,8 @@ QmlStandaloneAppWizardDialog::QmlStandaloneAppWizardDialog(QmlStandaloneAppWizar
m_qmlSourcesPage = new QmlStandaloneAppWizardSourcesPage;
m_qmlSourcesPage->setMainQmlFileChooserVisible(m_type == QmlStandaloneAppWizard::ImportQmlFile);
const QString qmlSourcesTitle = tr("QML Sources");
if (m_type == QmlStandaloneAppWizard::ImportQmlFile) {
const int qmlSourcesPagePageId = addPage(m_qmlSourcesPage);
wizardProgress()->item(qmlSourcesPagePageId)->setTitle(qmlSourcesTitle);
}
m_qmlOptionsPage = new MobileAppWizardOptionsPage;
const int qmlOptionsPagePageId = addPage(m_qmlOptionsPage);
wizardProgress()->item(qmlOptionsPagePageId)->setTitle(tr("QML Application options"));
if (m_type == QmlStandaloneAppWizard::NewQmlFile) {
// In case of NewQmlFile, we show that page at the end. Is that useful? Or irritating?
const int qmlSourcesPagePageId = addPage(m_qmlSourcesPage);
wizardProgress()->item(qmlSourcesPagePageId)->setTitle(qmlSourcesTitle);
}
const int qmlSourcesPagePageId = addPage(m_qmlSourcesPage);
wizardProgress()->item(qmlSourcesPagePageId)->setTitle(tr("QML Sources"));
}
class QmlStandaloneAppWizardPrivate
......@@ -105,7 +85,7 @@ class QmlStandaloneAppWizardPrivate
};
QmlStandaloneAppWizard::QmlStandaloneAppWizard(WizardType type)
: Core::BaseFileWizard(parameters(type))
: AbstractMobileAppWizard(parameters(type))
, m_d(new QmlStandaloneAppWizardPrivate)
{
m_d->type = type;
......@@ -116,6 +96,7 @@ QmlStandaloneAppWizard::QmlStandaloneAppWizard(WizardType type)
QmlStandaloneAppWizard::~QmlStandaloneAppWizard()
{
delete m_d->standaloneApp;
delete m_d;
}
Core::BaseFileWizardParameters QmlStandaloneAppWizard::parameters(WizardType type)
......@@ -141,47 +122,23 @@ Core::BaseFileWizardParameters QmlStandaloneAppWizard::parameters(WizardType typ
return parameters;
}
QWizard *QmlStandaloneAppWizard::createWizardDialog(QWidget *parent,
const QString &defaultPath,
const WizardPageList &extensionPages) const
AbstractMobileAppWizardDialog *QmlStandaloneAppWizard::createWizardDialogInternal(QWidget *parent) const
{
m_d->wizardDialog = new QmlStandaloneAppWizardDialog(m_d->type, parent);
m_d->wizardDialog->setPath(defaultPath);
m_d->wizardDialog->setProjectName(QmlStandaloneAppWizardDialog::uniqueProjectName(defaultPath));
m_d->wizardDialog->m_qmlOptionsPage->setSymbianSvgIcon(m_d->standaloneApp->symbianSvgIcon());
m_d->wizardDialog->m_qmlOptionsPage->setMaemoPngIcon(m_d->standaloneApp->maemoPngIcon());
m_d->wizardDialog->m_qmlOptionsPage->setOrientation(m_d->standaloneApp->orientation());
m_d->wizardDialog->m_qmlOptionsPage->setNetworkEnabled(m_d->standaloneApp->networkEnabled());
connect(m_d->wizardDialog, SIGNAL(introPageLeft(QString, QString)), SLOT(useProjectPath(QString, QString)));
connect(m_d->wizardDialog->m_qmlSourcesPage,
SIGNAL(externalModulesChanged(QStringList, QStringList)), SLOT(handleModulesChange(QStringList, QStringList)));
foreach (QWizardPage *p, extensionPages)
BaseFileWizard::applyExtensionPageShortTitle(m_d->wizardDialog, m_d->wizardDialog->addPage(p));
return m_d->wizardDialog;
}
Core::GeneratedFiles QmlStandaloneAppWizard::generateFiles(const QWizard *w,
QString *errorMessage) const
void QmlStandaloneAppWizard::prepareGenerateFiles(const QWizard *w,
QString *errorMessage) const
{
Q_UNUSED(errorMessage)
const QmlStandaloneAppWizardDialog *wizard = qobject_cast<const QmlStandaloneAppWizardDialog*>(w);
m_d->standaloneApp->setProjectName(wizard->projectName());
m_d->standaloneApp->setProjectPath(wizard->path());
m_d->standaloneApp->setSymbianTargetUid(wizard->m_qmlOptionsPage->symbianUid());
m_d->standaloneApp->setSymbianSvgIcon(wizard->m_qmlOptionsPage->symbianSvgIcon());