Commit c0d4de5a authored by jkobus's avatar jkobus Committed by hjk

Combine multi qt quick app wizards into just one

Cleanup some stuff (mobile orientation page),
drop import of qml from existing file

Change-Id: I261f03b6f249129dfe732719fb683978cc90fb9e
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 16f5dc82
......@@ -22,7 +22,6 @@ HEADERS += \
wizards/qtprojectparameters.h \
wizards/guiappwizard.h \
wizards/mobileapp.h \
wizards/mobileappwizardpages.h \
wizards/mobilelibrarywizardoptionpage.h \
wizards/mobilelibraryparameters.h \
wizards/consoleappwizard.h \
......@@ -81,7 +80,6 @@ SOURCES += \
wizards/qtprojectparameters.cpp \
wizards/guiappwizard.cpp \
wizards/mobileapp.cpp \
wizards/mobileappwizardpages.cpp \
wizards/mobilelibrarywizardoptionpage.cpp \
wizards/mobilelibraryparameters.cpp \
wizards/consoleappwizard.cpp \
......@@ -128,7 +126,6 @@ FORMS += makestep.ui \
wizards/testwizardpage.ui \
wizards/html5appwizardsourcespage.ui \
wizards/mobilelibrarywizardoptionpage.ui \
wizards/mobileappwizardgenericoptionspage.ui \
wizards/qtquickcomponentsetoptionspage.ui
RESOURCES += qmakeprojectmanager.qrc \
......
......@@ -104,8 +104,6 @@ QtcPlugin {
"librarywizard.cpp", "librarywizard.h",
"librarywizarddialog.cpp", "librarywizarddialog.h",
"mobileapp.cpp", "mobileapp.h",
"mobileappwizardgenericoptionspage.ui",
"mobileappwizardpages.cpp", "mobileappwizardpages.h",
"mobilelibraryparameters.cpp", "mobilelibraryparameters.h",
"mobilelibrarywizardoptionpage.cpp", "mobilelibrarywizardoptionpage.h", "mobilelibrarywizardoptionpage.ui",
"modulespage.cpp", "modulespage.h",
......
......@@ -126,7 +126,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
addAutoReleasedObject(new SubdirsProjectWizard);
addAutoReleasedObject(new GuiAppWizard);
addAutoReleasedObject(new ConsoleAppWizard);
QtQuickAppWizard::createInstances(this); //creates several instances with different options
addAutoReleasedObject(new QtQuickAppWizard);
addAutoReleasedObject(new Html5AppWizard);
addAutoReleasedObject(new LibraryWizard);
addAutoReleasedObject(new TestWizard);
......
......@@ -60,22 +60,11 @@ const int AbstractMobileApp::StubVersion = 9;
AbstractMobileApp::AbstractMobileApp()
: QObject()
, m_orientation(ScreenOrientationAuto)
{
}
AbstractMobileApp::~AbstractMobileApp() { }
void AbstractMobileApp::setOrientation(ScreenOrientation orientation)
{
m_orientation = orientation;
}
AbstractMobileApp::ScreenOrientation AbstractMobileApp::orientation() const
{
return m_orientation;
}
void AbstractMobileApp::setProjectName(const QString &name)
{
m_projectName = name;
......@@ -167,25 +156,7 @@ QByteArray AbstractMobileApp::generateMainCpp(QString *errorMessage) const
QString line;
while (!(line = in.readLine()).isNull()) {
bool adaptLine = true;
if (line.contains(QLatin1String("// ORIENTATION"))) {
const char *orientationString;
switch (orientation()) {
case ScreenOrientationLockLandscape:
orientationString = "ScreenOrientationLockLandscape";
break;
case ScreenOrientationLockPortrait:
orientationString = "ScreenOrientationLockPortrait";
break;
case ScreenOrientationAuto:
orientationString = "ScreenOrientationAuto";
break;
case ScreenOrientationImplicit:
default:
continue; // omit line
}
insertParameter(line, mainWindowClassName() + QLatin1String("::")
+ QLatin1String(orientationString));
} else if (line.contains(QLatin1String("// DELETE_LINE"))) {
if (line.contains(QLatin1String("// DELETE_LINE"))) {
continue; // omit this line in the output
} else {
adaptLine = adaptCurrentMainCppTemplateLine(line);
......
......@@ -80,13 +80,6 @@ class
Q_OBJECT
public:
enum ScreenOrientation {
ScreenOrientationLockLandscape,
ScreenOrientationLockPortrait,
ScreenOrientationAuto,
ScreenOrientationImplicit // Don't set in application at all
};
enum FileType {
MainCpp,
MainCppOrigin,
......@@ -105,8 +98,6 @@ public:
virtual ~AbstractMobileApp();
void setOrientation(ScreenOrientation orientation);
ScreenOrientation orientation() const;
void setProjectName(const QString &name);
QString projectName() const;
void setProjectPath(const QString &path);
......@@ -174,7 +165,6 @@ private:
QFileInfo m_projectPath;
QString m_pngIcon64;
QString m_pngIcon80;
ScreenOrientation m_orientation;
};
} // namespace QmakeProjectManager
......
......@@ -28,8 +28,8 @@
****************************************************************************/
#include "abstractmobileappwizard.h"
#include "abstractmobileapp.h"
#include "mobileappwizardpages.h"
#include "../qmakeprojectimporter.h"
#include <extensionsystem/pluginmanager.h>
......@@ -51,57 +51,35 @@ AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent,
const QtSupport::QtVersionNumber &maximumQtVersionNumber,
const Core::WizardDialogParameters &parameters)
: ProjectExplorer::BaseProjectWizardDialog(parent, parameters)
, m_targetsPage(0)
, m_genericOptionsPageId(-1)
, m_targetsPageId(-1)
, m_ignoreGeneralOptions(false)
, m_targetItem(0)
, m_genericItem(0)
, m_kitIds(parameters.extraValues().value(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))
.value<QList<Core::Id> >())
, m_kitsPage(0)
{
if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) {
m_targetsPage = new ProjectExplorer::TargetSetupPage;
m_targetsPage->setProjectImporter(new Internal::QmakeProjectImporter(path()));
m_kitsPage = new ProjectExplorer::TargetSetupPage;
m_kitsPage->setProjectImporter(new Internal::QmakeProjectImporter(path()));
QString platform = selectedPlatform();
if (platform.isEmpty()) {
m_targetsPage->setPreferredKitMatcher(
m_kitsPage->setPreferredKitMatcher(
new QtSupport::QtVersionKitMatcher(
Core::FeatureSet( QtSupport::Constants::FEATURE_MOBILE)));
} else {
m_targetsPage->setPreferredKitMatcher(new QtSupport::QtPlatformKitMatcher(platform));
m_kitsPage->setPreferredKitMatcher(new QtSupport::QtPlatformKitMatcher(platform));
}
m_targetsPage->setRequiredKitMatcher(new QtSupport::QtVersionKitMatcher(requiredFeatures(),
m_kitsPage->setRequiredKitMatcher(new QtSupport::QtVersionKitMatcher(requiredFeatures(),
minimumQtVersionNumber,
maximumQtVersionNumber));
resize(900, 450);
}
m_genericOptionsPage = new Internal::MobileAppWizardGenericOptionsPage;
}
void AbstractMobileAppWizardDialog::addMobilePages()
void AbstractMobileAppWizardDialog::addKitsPage()
{
if (m_targetsPage) {
m_targetsPageId = addPageWithTitle(m_targetsPage, tr("Targets"));
m_targetItem = wizardProgress()->item(m_targetsPageId);
}
const bool shouldAddGenericPage = m_targetsPage;
if (shouldAddGenericPage) {
m_genericOptionsPageId = addPageWithTitle(m_genericOptionsPage,
tr("Mobile Options"));
m_genericItem = wizardProgress()->item(m_genericOptionsPageId);
}
if (m_targetItem)
m_targetItem->setNextShownItem(0);
if (m_kitsPage)
addPageWithTitle(m_kitsPage, tr("Kits"));
}
ProjectExplorer::TargetSetupPage *AbstractMobileAppWizardDialog::targetsPage() const
ProjectExplorer::TargetSetupPage *AbstractMobileAppWizardDialog::kitsPage() const
{
return m_targetsPage;
return m_kitsPage;
}
int AbstractMobileAppWizardDialog::addPageWithTitle(QWizardPage *page, const QString &title)
......@@ -111,72 +89,6 @@ int AbstractMobileAppWizardDialog::addPageWithTitle(QWizardPage *page, const QSt
return pageId;
}
int AbstractMobileAppWizardDialog::nextId() const
{
if (m_targetsPage) {
if (currentPage() == m_targetsPage)
return idOfNextGenericPage();
if (currentPage() == m_genericOptionsPage)
return idOfNextGenericPage();
}
return BaseProjectWizardDialog::nextId();
}
void AbstractMobileAppWizardDialog::initializePage(int id)
{
if (m_targetItem) {
if (id == startId()) {
m_targetItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< m_genericItem << itemOfNextGenericPage());
} else if (id == m_genericOptionsPageId) {
QList<Utils::WizardProgressItem *> order;
order << m_genericItem << itemOfNextGenericPage();
for (int i = 0; i < order.count() - 1; i++)
order.at(i)->setNextShownItem(order.at(i + 1));
}
}
BaseProjectWizardDialog::initializePage(id);
}
void AbstractMobileAppWizardDialog::setIgnoreGenericOptionsPage(bool ignore)
{
m_ignoreGeneralOptions = ignore;
}
Utils::WizardProgressItem *AbstractMobileAppWizardDialog::targetsPageItem() const
{
return m_targetItem;
}
int AbstractMobileAppWizardDialog::idOfNextGenericPage() const
{
return pageIds().at(pageIds().indexOf(m_genericOptionsPageId) + 1);
}
Utils::WizardProgressItem *AbstractMobileAppWizardDialog::itemOfNextGenericPage() const
{
return wizardProgress()->item(idOfNextGenericPage());
}
bool AbstractMobileAppWizardDialog::isQtPlatformSelected(const QString &platform) const
{
QList<Core::Id> selectedKitsList = selectedKits();
foreach (Kit *k, KitManager::matchingKits(QtSupport::QtPlatformKitMatcher(platform)))
if (selectedKitsList.contains(k->id()))
return true;
return false;
}
QList<Core::Id> AbstractMobileAppWizardDialog::selectedKits() const
{
if (m_targetsPage)
return m_targetsPage->selectedKits();
return m_kitIds;
}
AbstractMobileAppWizard::AbstractMobileAppWizard(QObject *parent)
: Core::BaseFileWizard(parent)
......@@ -188,7 +100,6 @@ QWizard *AbstractMobileAppWizard::createWizardDialog(QWidget *parent,
AbstractMobileAppWizardDialog * const wdlg
= createWizardDialogInternal(parent, wizardDialogParameters);
wdlg->setProjectName(ProjectExplorer::BaseProjectWizardDialog::uniqueProjectName(wizardDialogParameters.defaultPath()));
wdlg->m_genericOptionsPage->setOrientation(app()->orientation());
connect(wdlg, SIGNAL(projectParametersChanged(QString,QString)),
SLOT(useProjectPath(QString,QString)));
wdlg->addExtensionPages(wizardDialogParameters.extensionPages());
......@@ -199,9 +110,6 @@ QWizard *AbstractMobileAppWizard::createWizardDialog(QWidget *parent,
Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizard,
QString *errorMessage) const
{
const AbstractMobileAppWizardDialog *wdlg
= qobject_cast<const AbstractMobileAppWizardDialog*>(wizard);
app()->setOrientation(wdlg->m_genericOptionsPage->orientation());
prepareGenerateFiles(wizard, errorMessage);
return app()->generateFiles(errorMessage);
}
......@@ -217,8 +125,8 @@ bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w,
Q_ASSERT(manager);
QmakeProject project(manager, app()->path(AbstractMobileApp::AppPro));
bool success = true;
if (wizardDialog()->m_targetsPage) {
success = wizardDialog()->m_targetsPage->setupProject(&project);
if (wizardDialog()->kitsPage()) {
success = wizardDialog()->kitsPage()->setupProject(&project);
if (success) {
project.saveSettings();
success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
......@@ -239,8 +147,8 @@ void AbstractMobileAppWizard::useProjectPath(const QString &projectName,
{
app()->setProjectName(projectName);
app()->setProjectPath(projectPath);
if (wizardDialog()->m_targetsPage)
wizardDialog()->m_targetsPage->setProjectPath(app()->path(AbstractMobileApp::AppPro));
if (wizardDialog()->kitsPage())
wizardDialog()->kitsPage()->setProjectPath(app()->path(AbstractMobileApp::AppPro));
projectPathChanged(app()->path(AbstractMobileApp::AppPro));
}
......
......@@ -44,8 +44,6 @@ namespace QmakeProjectManager {
class AbstractMobileApp;
namespace Internal { class MobileAppWizardGenericOptionsPage; }
/// \internal
class QMAKEPROJECTMANAGER_EXPORT AbstractMobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog
{
......@@ -55,36 +53,16 @@ protected:
explicit AbstractMobileAppWizardDialog(QWidget *parent, const QtSupport::QtVersionNumber &minimumQtVersionNumber,
const QtSupport::QtVersionNumber &maximumQtVersionNumber,
const Core::WizardDialogParameters &parameters);
void addMobilePages();
void addKitsPage();
public:
ProjectExplorer::TargetSetupPage *targetsPage() const;
ProjectExplorer::TargetSetupPage *kitsPage() const;
protected:
int addPageWithTitle(QWizardPage *page, const QString &title);
virtual void initializePage(int id);
virtual void setIgnoreGenericOptionsPage(bool);
virtual int nextId() const;
Utils::WizardProgressItem *targetsPageItem() const;
private:
int idOfNextGenericPage() const;
Utils::WizardProgressItem *itemOfNextGenericPage() const;
bool isQtPlatformSelected(const QString &platform) const;
QList<Core::Id> selectedKits() const;
Internal::MobileAppWizardGenericOptionsPage *m_genericOptionsPage;
ProjectExplorer::TargetSetupPage *m_targetsPage;
int m_genericOptionsPageId;
int m_targetsPageId;
bool m_ignoreGeneralOptions; // If true, do not show generic mobile options page.
Utils::WizardProgressItem *m_targetItem;
Utils::WizardProgressItem *m_genericItem;
QList<Core::Id> m_kitIds;
friend class AbstractMobileAppWizard;
ProjectExplorer::TargetSetupPage *m_kitsPage;
};
/// \internal
......
......@@ -67,7 +67,7 @@ Html5AppWizardDialog::Html5AppWizardDialog(QWidget *parent,
m_htmlOptionsPage = new Html5AppWizardOptionsPage;
addPageWithTitle(m_htmlOptionsPage, tr("HTML Options"));
addMobilePages();
addKitsPage();
}
......@@ -114,8 +114,8 @@ AbstractMobileAppWizardDialog *Html5AppWizard::createWizardDialogInternal(QWidge
void Html5AppWizard::projectPathChanged(const QString &path) const
{
if (d->wizardDialog->targetsPage())
d->wizardDialog->targetsPage()->setProjectPath(path);
if (d->wizardDialog->kitsPage())
d->wizardDialog->kitsPage()->setProjectPath(path);
}
void Html5AppWizard::prepareGenerateFiles(const QWizard *w,
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QmakeProjectManager::Internal::MobileAppWizardGenericOptionsPage</class>
<widget class="QWizardPage" name="QmakeProjectManager::Internal::MobileAppWizardGenericOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="orientationBehaviorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Orientation behavior:</string>
</property>
<property name="buddy">
<cstring>orientationBehaviorComboBox</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="orientationBehaviorComboBox"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>66</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "mobileappwizardpages.h"
#include "ui_mobileappwizardgenericoptionspage.h"
#include <utils/fileutils.h>
#include <QTemporaryFile>
#include <QFileDialog>
#include <QMessageBox>
namespace QmakeProjectManager {
namespace Internal {
class MobileAppWizardGenericOptionsPagePrivate
{
Ui::MobileAppWizardGenericOptionsPage ui;
friend class MobileAppWizardGenericOptionsPage;
};
MobileAppWizardGenericOptionsPage::MobileAppWizardGenericOptionsPage(QWidget *parent)
: QWizardPage(parent)
, d(new MobileAppWizardGenericOptionsPagePrivate)
{
d->ui.setupUi(this);
d->ui.orientationBehaviorComboBox->addItem(tr("Automatically Rotate Orientation"),
AbstractMobileApp::ScreenOrientationAuto);
d->ui.orientationBehaviorComboBox->addItem(tr("Lock to Landscape Orientation"),
AbstractMobileApp::ScreenOrientationLockLandscape);
d->ui.orientationBehaviorComboBox->addItem(tr("Lock to Portrait Orientation"),
AbstractMobileApp::ScreenOrientationLockPortrait);
}
MobileAppWizardGenericOptionsPage::~MobileAppWizardGenericOptionsPage()
{
delete d;
}
void MobileAppWizardGenericOptionsPage::setOrientation(AbstractMobileApp::ScreenOrientation orientation)
{
QComboBox *const comboBox = d->ui.orientationBehaviorComboBox;
for (int i = 0; i < comboBox->count(); ++i) {
if (comboBox->itemData(i).toInt() == static_cast<int>(orientation)) {
comboBox->setCurrentIndex(i);
break;
}
}
}
AbstractMobileApp::ScreenOrientation MobileAppWizardGenericOptionsPage::orientation() const
{
QComboBox *const comboBox = d->ui.orientationBehaviorComboBox;
const int index = comboBox->currentIndex();
return static_cast<AbstractMobileApp::ScreenOrientation>(comboBox->itemData(index).toInt());
}
class PngIconScaler : public QObject
{
Q_OBJECT
public:
PngIconScaler(const QSize &expectedSize, const QString &iconPath)
: m_expectedSize(expectedSize)
, m_iconPath(iconPath)
, m_pixmap(iconPath)
{
}
bool hasRightSize() const { return m_expectedSize == m_pixmap.size(); }
QPixmap pixmap() const { return m_pixmap; }
bool scale(QString *newPath) {
const QMessageBox::StandardButton button
= QMessageBox::warning(QApplication::activeWindow(),
tr("Wrong Icon Size"),
tr("The icon needs to be %1x%2 pixels big, "
"but is not. Do you want Qt Creator to scale it?")
.arg(m_expectedSize.width()).arg(m_expectedSize.height()),
QMessageBox::Ok | QMessageBox::Cancel);
if (button != QMessageBox::Ok)
return false;
m_pixmap = m_pixmap.scaled(m_expectedSize);
Utils::TempFileSaver saver;
saver.setAutoRemove(false);
if (!saver.hasError())
saver.setResult(m_pixmap.save(
saver.file(), QFileInfo(m_iconPath).suffix().toLatin1().constData()));
if (!saver.finalize()) {
QMessageBox::critical(QApplication::activeWindow(),
tr("File Error"),
tr("Could not copy icon file: %1").arg(saver.errorString()));
return false;
}
*newPath = saver.fileName();
return true;
}
private:
QSize m_expectedSize;
QString m_iconPath;
QPixmap m_pixmap;
};
} // namespace Internal
} // namespace QmakeProjectManager
#include "mobileappwizardpages.moc"
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef MOBILEAPPWIZARDPAGES_H
#define MOBILEAPPWIZARDPAGES_H
#include "abstractmobileapp.h"