2009-05-11 10:58:04 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-05-11 10:58:04 +02:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-05-11 10:58:04 +02:00
|
|
|
**
|
|
|
|
|
** 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
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
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-04-16 15:55:32 +02:00
|
|
|
#include <projectexplorer/customwizard/customwizard.h>
|
2009-05-11 10:58:04 +02:00
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <QtGui/QIcon>
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("New QML Project"));
|
2009-11-26 18:03:16 +01:00
|
|
|
setIntroDescription(tr("This wizard generates a QML application 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);
|
2009-11-27 10:33:24 +01:00
|
|
|
parameters.setIcon(QIcon(QLatin1String(":/wizards/images/console.png")));
|
2010-03-18 10:50:20 +01:00
|
|
|
parameters.setDisplayName(tr("Qt QML Application"));
|
2009-11-27 10:33:24 +01:00
|
|
|
parameters.setId(QLatin1String("QA.QML Application"));
|
2010-05-12 10:39:49 +02:00
|
|
|
parameters.setDescription(tr("Creates a Qt QML application project with a single QML file containing the main view.\n\n"
|
|
|
|
|
"QML application projects are executed through the QML runtime and do not need to be built."));
|
2010-01-13 18:44:15 +01:00
|
|
|
parameters.setCategory(QLatin1String(Constants::QML_WIZARD_CATEGORY));
|
|
|
|
|
parameters.setDisplayCategory(QCoreApplication::translate(Constants::QML_WIZARD_TR_SCOPE,
|
|
|
|
|
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-04-13 12:23:12 +02:00
|
|
|
<< "import Qt 4.7" << endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< endl
|
|
|
|
|
<< "Rectangle {" << endl
|
|
|
|
|
<< " width: 200" << endl
|
|
|
|
|
<< " height: 200" << endl
|
|
|
|
|
<< " Text {" << endl
|
|
|
|
|
<< " x: 66" << endl
|
|
|
|
|
<< " y: 93" << endl
|
|
|
|
|
<< " text: \"Hello World\"" << endl
|
|
|
|
|
<< " }" << endl
|
|
|
|
|
<< "}" << 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);
|
|
|
|
|
|
|
|
|
|
out
|
2010-01-29 10:36:00 +01:00
|
|
|
//: Comment added to generated .qmlproject file
|
2010-03-22 10:19:39 +01:00
|
|
|
<< "/* " << tr("File generated by QtCreator", "qmlproject Template") << " */" << endl
|
2010-01-29 10:36:00 +01:00
|
|
|
<< endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< "import QmlProject 1.0" << endl
|
2010-01-29 10:36:00 +01:00
|
|
|
<< endl
|
2010-01-26 22:03:17 +01:00
|
|
|
<< "Project {" << endl
|
2010-01-29 10:36:00 +01:00
|
|
|
//: Comment added to generated .qmlproject file
|
2010-03-22 10:19:39 +01:00
|
|
|
<< " /* " << tr("Include .qml, .js, and image files from current directory and subdirectories", "qmlproject Template") << " */" << 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
|
2010-03-19 15:14:46 +01:00
|
|
|
//: Comment added to generated .qmlproject file
|
2010-03-22 10:19:39 +01:00
|
|
|
<< " /* " << tr("List of plugin directories passed to QML runtime", "qmlproject Template") << " */" << endl
|
2010-03-19 15:14:46 +01: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
|
|
|
|
|
|