2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01: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).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "consoleappwizard.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "consoleappwizarddialog.h"
|
|
|
|
|
#include "qt4projectmanagerconstants.h"
|
|
|
|
|
|
2010-12-03 13:49:35 +01:00
|
|
|
#include <cpptools/abstracteditorsupport.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <QtGui/QIcon>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QTextStream>
|
|
|
|
|
|
|
|
|
|
static const char *mainCppC =
|
|
|
|
|
"#include <QtCore/QCoreApplication>\n\n"
|
|
|
|
|
"int main(int argc, char *argv[])\n"
|
|
|
|
|
"{\n"
|
|
|
|
|
" QCoreApplication a(argc, argv);\n\n"
|
|
|
|
|
" return a.exec();\n"
|
|
|
|
|
"}\n";
|
|
|
|
|
|
|
|
|
|
static const char *mainSourceFileC = "main";
|
|
|
|
|
|
|
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-01-20 15:31:33 +01:00
|
|
|
ConsoleAppWizard::ConsoleAppWizard()
|
2010-01-13 18:44:15 +01:00
|
|
|
: QtWizard(QLatin1String("E.Qt4Core"),
|
|
|
|
|
QLatin1String(Constants::QT_APP_WIZARD_CATEGORY),
|
|
|
|
|
QLatin1String(Constants::QT_APP_WIZARD_TR_SCOPE),
|
|
|
|
|
QLatin1String(Constants::QT_APP_WIZARD_TR_CATEGORY),
|
|
|
|
|
tr("Qt Console Application"),
|
2010-05-12 10:39:49 +02:00
|
|
|
tr("Creates a project containing a single main.cpp file with a stub implementation.\n\n"
|
|
|
|
|
"Preselects a desktop Qt for building the application if available."),
|
2009-11-27 10:33:24 +01:00
|
|
|
QIcon(QLatin1String(":/wizards/images/console.png")))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWizard *ConsoleAppWizard::createWizardDialog(QWidget *parent,
|
|
|
|
|
const QString &defaultPath,
|
|
|
|
|
const WizardPageList &extensionPages) const
|
|
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
ConsoleAppWizardDialog *dialog = new ConsoleAppWizardDialog(displayName(), icon(), extensionPages,
|
2009-11-26 18:03:16 +01:00
|
|
|
showModulesPageForApplications(), parent);
|
|
|
|
|
dialog->setPath(defaultPath);
|
2010-01-07 18:17:24 +01:00
|
|
|
dialog->setProjectName(ConsoleAppWizardDialog::uniqueProjectName(defaultPath));
|
2008-12-02 12:01:29 +01:00
|
|
|
return dialog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Core::GeneratedFiles
|
|
|
|
|
ConsoleAppWizard::generateFiles(const QWizard *w,
|
|
|
|
|
QString * /*errorMessage*/) const
|
|
|
|
|
{
|
|
|
|
|
const ConsoleAppWizardDialog *wizard = qobject_cast< const ConsoleAppWizardDialog *>(w);
|
|
|
|
|
const QtProjectParameters params = wizard->parameters();
|
|
|
|
|
const QString projectPath = params.projectPath();
|
|
|
|
|
|
|
|
|
|
// Create files: Source
|
|
|
|
|
|
|
|
|
|
const QString sourceFileName = Core::BaseFileWizard::buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix());
|
|
|
|
|
Core::GeneratedFile source(sourceFileName);
|
2010-08-09 12:23:21 +02:00
|
|
|
source.setContents(CppTools::AbstractEditorSupport::licenseTemplate(sourceFileName) + QLatin1String(mainCppC));
|
2010-04-16 15:55:32 +02:00
|
|
|
source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);
|
2008-12-02 12:01:29 +01:00
|
|
|
// Create files: Profile
|
2010-01-07 18:17:24 +01:00
|
|
|
const QString profileName = Core::BaseFileWizard::buildFileName(projectPath, params.fileName, profileSuffix());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
Core::GeneratedFile profile(profileName);
|
2010-04-16 15:55:32 +02:00
|
|
|
profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
|
2008-12-02 12:01:29 +01:00
|
|
|
QString contents;
|
|
|
|
|
{
|
|
|
|
|
QTextStream proStr(&contents);
|
|
|
|
|
QtProjectParameters::writeProFileHeader(proStr);
|
|
|
|
|
params.writeProFile(proStr);
|
|
|
|
|
proStr << "\n\nSOURCES += " << QFileInfo(sourceFileName).fileName() << '\n';
|
|
|
|
|
}
|
|
|
|
|
profile.setContents(contents);
|
|
|
|
|
return Core::GeneratedFiles() << source << profile;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 16:19:05 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qt4ProjectManager
|