2009-05-11 10:58:04 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2009-05-11 10:58:04 +02:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2009-05-11 10:58:04 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2009-05-11 10:58:04 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2009-05-11 10:58:04 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
#include "qmlprojectapplicationwizard.h"
|
2009-05-11 10:58:04 +02:00
|
|
|
|
2010-01-13 18:44:15 +01:00
|
|
|
#include "qmlprojectconstants.h"
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2010-04-16 15:55:32 +02:00
|
|
|
#include <projectexplorer/customwizard/customwizard.h>
|
2010-10-04 14:50:58 +02:00
|
|
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
2009-05-11 10:58:04 +02:00
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <QtGui/QIcon>
|
|
|
|
|
|
2010-05-14 11:03:30 +02:00
|
|
|
#include <QtGui/QPainter>
|
|
|
|
|
#include <QtGui/QPixmap>
|
|
|
|
|
|
2010-12-03 17:04:29 +01:00
|
|
|
#include <QtCore/QDir>
|
2009-11-26 18:03:16 +01:00
|
|
|
#include <QtCore/QTextStream>
|
2009-11-27 10:33:24 +01:00
|
|
|
#include <QtCore/QCoreApplication>
|
2009-05-11 10:58:04 +02:00
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-05-11 10:58:04 +02:00
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
QmlProjectApplicationWizardDialog::QmlProjectApplicationWizardDialog(QWidget *parent) :
|
2009-11-26 18:03:16 +01:00
|
|
|
ProjectExplorer::BaseProjectWizardDialog(parent)
|
2009-05-11 10:58:04 +02:00
|
|
|
{
|
2010-09-28 13:55:38 +02:00
|
|
|
setWindowTitle(tr("New Qt Quick UI Project"));
|
|
|
|
|
setIntroDescription(tr("This wizard generates a Qt Quick UI project."));
|
2009-05-11 10:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
QmlProjectApplicationWizard::QmlProjectApplicationWizard()
|
2009-05-11 10:58:04 +02:00
|
|
|
: Core::BaseFileWizard(parameters())
|
|
|
|
|
{ }
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
QmlProjectApplicationWizard::~QmlProjectApplicationWizard()
|
2009-05-11 10:58:04 +02:00
|
|
|
{ }
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
Core::BaseFileWizardParameters QmlProjectApplicationWizard::parameters()
|
2009-05-11 10:58:04 +02:00
|
|
|
{
|
2010-02-16 09:18:24 +01:00
|
|
|
Core::BaseFileWizardParameters parameters(ProjectWizard);
|
2010-10-04 14:50:58 +02:00
|
|
|
parameters.setIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::QML_WIZARD_ICON)));
|
2010-09-28 13:55:38 +02:00
|
|
|
parameters.setDisplayName(tr("Qt Quick UI"));
|
2011-01-24 16:00:12 +01:00
|
|
|
parameters.setId(QLatin1String("QB.QML Application"));
|
2010-09-28 13:55:38 +02:00
|
|
|
|
|
|
|
|
parameters.setDescription(tr("Creates a Qt Quick UI project with a single "
|
|
|
|
|
"QML file that contains the main view.\n\n"
|
|
|
|
|
"You can review Qt Quick UI projects in the QML Viewer and you need not build them. "
|
|
|
|
|
"You do not need to have the development environment installed "
|
|
|
|
|
"on your computer to create and run this type of projects."));
|
2010-10-04 14:50:58 +02:00
|
|
|
parameters.setCategory(QLatin1String(Qt4ProjectManager::Constants::QML_WIZARD_CATEGORY));
|
|
|
|
|
parameters.setDisplayCategory(QCoreApplication::translate(Qt4ProjectManager::Constants::QML_WIZARD_TR_SCOPE,
|
|
|
|
|
Qt4ProjectManager::Constants::QML_WIZARD_TR_CATEGORY));
|
2009-05-11 10:58:04 +02:00
|
|
|
return parameters;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
QWizard *QmlProjectApplicationWizard::createWizardDialog(QWidget *parent,
|
2009-05-11 10:58:04 +02:00
|
|
|
const QString &defaultPath,
|
|
|
|
|
const WizardPageList &extensionPages) const
|
|
|
|
|
{
|
2010-02-18 15:33:35 +01:00
|
|
|
QmlProjectApplicationWizardDialog *wizard = new QmlProjectApplicationWizardDialog(parent);
|
2009-05-11 10:58:04 +02:00
|
|
|
|
|
|
|
|
wizard->setPath(defaultPath);
|
2010-02-18 15:33:35 +01:00
|
|
|
wizard->setProjectName(QmlProjectApplicationWizardDialog::uniqueProjectName(defaultPath));
|
2009-05-11 10:58:04 +02:00
|
|
|
|
|
|
|
|
foreach (QWizardPage *p, extensionPages)
|
2010-03-31 14:48:08 +02:00
|
|
|
BaseFileWizard::applyExtensionPageShortTitle(wizard, wizard->addPage(p));
|
2009-05-11 10:58:04 +02:00
|
|
|
|
|
|
|
|
return wizard;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
Core::GeneratedFiles QmlProjectApplicationWizard::generateFiles(const QWizard *w,
|
2009-05-11 10:58:04 +02:00
|
|
|
QString *errorMessage) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(errorMessage)
|
|
|
|
|
|
2010-02-18 15:33:35 +01:00
|
|
|
const QmlProjectApplicationWizardDialog *wizard = qobject_cast<const QmlProjectApplicationWizardDialog *>(w);
|
2010-01-07 18:17:24 +01:00
|
|
|
const QString projectName = wizard->projectName();
|
2009-05-11 10:58:04 +02:00
|
|
|
const QString projectPath = wizard->path() + QLatin1Char('/') + projectName;
|
|
|
|
|
|
|
|
|
|
const QString creatorFileName = Core::BaseFileWizard::buildFileName(projectPath,
|
|
|
|
|
projectName,
|
|
|
|
|
QLatin1String("qmlproject"));
|
|
|
|
|
|
|
|
|
|
const QString mainFileName = Core::BaseFileWizard::buildFileName(projectPath,
|
|
|
|
|
projectName,
|
|
|
|
|
QLatin1String("qml"));
|
|
|
|
|
|
|
|
|
|
QString contents;
|
2010-01-26 22:03:17 +01:00
|
|
|
{
|
|
|
|
|
QTextStream out(&contents);
|
|
|
|
|
|
|
|
|
|
out
|
2010-11-30 16:23:22 +01:00
|
|
|
<< "import QtQuick 1.0" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< endl
|
|
|
|
|
<< "Rectangle {" << endl
|
2010-11-11 11:39:57 +01:00
|
|
|
<< " width: 360" << endl
|
|
|
|
|
<< " height: 360" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< " Text {" << endl
|
2010-11-11 11:39:57 +01:00
|
|
|
<< " anchors.centerIn: parent" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< " text: \"Hello World\"" << endl
|
|
|
|
|
<< " }" << endl
|
2010-11-11 11:39:57 +01:00
|
|
|
<< " MouseArea {" << endl
|
|
|
|
|
<< " anchors.fill: parent" << endl
|
|
|
|
|
<< " onClicked: {" << endl
|
|
|
|
|
<< " Qt.quit();" << endl
|
|
|
|
|
<< " }" << endl
|
|
|
|
|
<< " }" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< "}" << endl;
|
|
|
|
|
}
|
2009-05-11 10:58:04 +02:00
|
|
|
Core::GeneratedFile generatedMainFile(mainFileName);
|
|
|
|
|
generatedMainFile.setContents(contents);
|
2010-04-16 15:55:32 +02:00
|
|
|
generatedMainFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
2009-05-11 10:58:04 +02:00
|
|
|
|
2010-01-26 22:03:17 +01:00
|
|
|
QString projectContents;
|
|
|
|
|
{
|
|
|
|
|
QTextStream out(&projectContents);
|
|
|
|
|
|
2011-02-14 16:36:05 +01:00
|
|
|
out << "/* File generated by Qt Creator, version " << Core::Constants::IDE_VERSION_LONG << " */" << endl
|
2010-01-29 10:36:00 +01:00
|
|
|
<< endl
|
2010-12-03 17:04:29 +01:00
|
|
|
<< "import QmlProject 1.1" << endl
|
2010-01-29 10:36:00 +01:00
|
|
|
<< endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< "Project {" << endl
|
2011-02-14 16:36:05 +01:00
|
|
|
<< " mainFile: \"" << QDir(projectPath).relativeFilePath(mainFileName) << '"' << endl
|
2010-12-03 17:04:29 +01:00
|
|
|
<< endl
|
2011-02-14 16:36:05 +01:00
|
|
|
<< " /* Include .qml, .js, and image files from current directory and subdirectories */" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< " QmlFiles {" << endl
|
|
|
|
|
<< " directory: \".\"" << endl
|
|
|
|
|
<< " }" << endl
|
2010-01-29 10:36:00 +01:00
|
|
|
<< " JavaScriptFiles {" << endl
|
|
|
|
|
<< " directory: \".\"" << endl
|
|
|
|
|
<< " }" << endl
|
|
|
|
|
<< " ImageFiles {" << endl
|
|
|
|
|
<< " directory: \".\"" << endl
|
|
|
|
|
<< " }" << endl
|
2011-02-14 16:36:05 +01:00
|
|
|
<< " /* List of plugin directories passed to QML runtime */" << endl
|
2010-06-24 13:45:54 +02:00
|
|
|
<< " // importPaths: [ \"../exampleplugin\" ]" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< "}" << endl;
|
|
|
|
|
}
|
2009-05-11 10:58:04 +02:00
|
|
|
Core::GeneratedFile generatedCreatorFile(creatorFileName);
|
2010-01-26 22:03:17 +01:00
|
|
|
generatedCreatorFile.setContents(projectContents);
|
2010-04-16 15:55:32 +02:00
|
|
|
generatedCreatorFile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
2009-05-11 10:58:04 +02:00
|
|
|
|
|
|
|
|
Core::GeneratedFiles files;
|
|
|
|
|
files.append(generatedMainFile);
|
|
|
|
|
files.append(generatedCreatorFile);
|
|
|
|
|
|
|
|
|
|
return files;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 15:55:32 +02:00
|
|
|
bool QmlProjectApplicationWizard::postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage)
|
2009-05-11 10:58:04 +02:00
|
|
|
{
|
2010-04-16 15:55:32 +02:00
|
|
|
return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage);
|
|
|
|
|
|
2009-05-11 10:58:04 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-16 13:39:13 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace QmlProjectManager
|
|
|
|
|
|