2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 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
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
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
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
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 "qtwizard.h"
|
2010-02-17 14:26:42 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4project.h"
|
2010-02-17 14:26:42 +01:00
|
|
|
#include "qt4projectmanager.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "qt4projectmanagerconstants.h"
|
2009-11-26 18:03:16 +01:00
|
|
|
#include "modulespage.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2009-06-17 12:40:54 +02:00
|
|
|
#include <cpptools/cpptoolsconstants.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QCoreApplication>
|
2009-06-17 12:40:54 +02:00
|
|
|
#include <QtCore/QVariant>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace Qt4ProjectManager;
|
|
|
|
|
using namespace Qt4ProjectManager::Internal;
|
|
|
|
|
|
|
|
|
|
static inline Core::BaseFileWizardParameters
|
2009-11-27 10:33:24 +01:00
|
|
|
wizardParameters(const QString &id,
|
2010-01-13 18:44:15 +01:00
|
|
|
const QString &category,
|
|
|
|
|
const QString &categoryTranslationScope,
|
|
|
|
|
const QString &displayCategory,
|
2009-11-27 10:33:24 +01:00
|
|
|
const QString &name,
|
2008-12-02 12:01:29 +01:00
|
|
|
const QString &description,
|
|
|
|
|
const QIcon &icon)
|
|
|
|
|
{
|
|
|
|
|
Core::BaseFileWizardParameters rc(Core::IWizard::ProjectWizard);
|
2010-01-13 18:44:15 +01:00
|
|
|
rc.setCategory(category);
|
|
|
|
|
rc.setDisplayCategory(QCoreApplication::translate(categoryTranslationScope.toLatin1(),
|
|
|
|
|
displayCategory.toLatin1()));
|
2008-12-02 12:01:29 +01:00
|
|
|
rc.setIcon(icon);
|
2010-01-07 18:17:24 +01:00
|
|
|
rc.setDisplayName(name);
|
2009-11-27 10:33:24 +01:00
|
|
|
rc.setId(id);
|
2008-12-02 12:01:29 +01:00
|
|
|
rc.setDescription(description);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -------------------- QtWizard
|
2010-01-13 18:44:15 +01:00
|
|
|
QtWizard::QtWizard(const QString &id,
|
|
|
|
|
const QString &category,
|
|
|
|
|
const QString &categoryTranslationScope,
|
|
|
|
|
const QString &displayCategory,
|
|
|
|
|
const QString &name,
|
2009-11-27 10:33:24 +01:00
|
|
|
const QString &description, const QIcon &icon) :
|
2010-01-13 18:44:15 +01:00
|
|
|
Core::BaseFileWizard(wizardParameters(id,
|
|
|
|
|
category,
|
|
|
|
|
categoryTranslationScope,
|
|
|
|
|
displayCategory,
|
|
|
|
|
name,
|
|
|
|
|
description,
|
|
|
|
|
icon))
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 14:19:34 +01:00
|
|
|
QString QtWizard::sourceSuffix()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return preferredSuffix(QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 14:19:34 +01:00
|
|
|
QString QtWizard::headerSuffix()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return preferredSuffix(QLatin1String(Constants::CPP_HEADER_MIMETYPE));
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 14:19:34 +01:00
|
|
|
QString QtWizard::formSuffix()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return preferredSuffix(QLatin1String(Constants::FORM_MIMETYPE));
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 14:19:34 +01:00
|
|
|
QString QtWizard::profileSuffix()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return preferredSuffix(QLatin1String(Constants::PROFILE_MIMETYPE));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QtWizard::postGenerateFiles(const Core::GeneratedFiles &l, QString *errorMessage)
|
|
|
|
|
{
|
|
|
|
|
// Post-Generate: Open the project
|
|
|
|
|
const QString proFileName = l.back().path();
|
2009-03-04 09:38:01 +01:00
|
|
|
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
2008-12-02 12:01:29 +01:00
|
|
|
*errorMessage = tr("The project %1 could not be opened.").arg(proFileName);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-16 14:19:34 +01:00
|
|
|
QString QtWizard::templateDir()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-01-20 15:31:33 +01:00
|
|
|
QString rc = Core::ICore::instance()->resourcePath();
|
2008-12-02 12:01:29 +01:00
|
|
|
rc += QLatin1String("/templates/qt4project");
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
2009-06-17 12:40:54 +02:00
|
|
|
|
|
|
|
|
bool QtWizard::lowerCaseFiles()
|
|
|
|
|
{
|
|
|
|
|
QString lowerCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP);
|
|
|
|
|
lowerCaseSettingsKey += QLatin1Char('/');
|
|
|
|
|
lowerCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY);
|
|
|
|
|
const bool lowerCaseDefault = CppTools::Constants::lowerCaseFilesDefault;
|
|
|
|
|
return Core::ICore::instance()->settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool();
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
bool QtWizard::showModulesPageForApplications()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QtWizard::showModulesPageForLibraries()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ----------------- BaseQt4ProjectWizardDialog
|
|
|
|
|
BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage, QWidget *parent) :
|
|
|
|
|
ProjectExplorer::BaseProjectWizardDialog(parent),
|
|
|
|
|
m_modulesPage(0)
|
|
|
|
|
{
|
|
|
|
|
init(showModulesPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseQt4ProjectWizardDialog::BaseQt4ProjectWizardDialog(bool showModulesPage,
|
|
|
|
|
Utils::ProjectIntroPage *introPage,
|
|
|
|
|
int introId, QWidget *parent) :
|
|
|
|
|
ProjectExplorer::BaseProjectWizardDialog(introPage, introId, parent),
|
|
|
|
|
m_modulesPage(0)
|
|
|
|
|
{
|
|
|
|
|
init(showModulesPage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseQt4ProjectWizardDialog::init(bool showModulesPage)
|
|
|
|
|
{
|
|
|
|
|
if (showModulesPage)
|
|
|
|
|
m_modulesPage = new ModulesPage;
|
|
|
|
|
}
|
2009-06-17 12:40:54 +02:00
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
void BaseQt4ProjectWizardDialog::addModulesPage(int id)
|
|
|
|
|
{
|
|
|
|
|
if (m_modulesPage) {
|
|
|
|
|
if (id >= 0) {
|
|
|
|
|
setPage(id, m_modulesPage);
|
|
|
|
|
} else {
|
|
|
|
|
addPage(m_modulesPage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BaseQt4ProjectWizardDialog::selectedModules() const
|
|
|
|
|
{
|
|
|
|
|
return m_modulesPage ? m_modulesPage->selectedModules() : m_selectedModules;
|
|
|
|
|
}
|
2009-06-17 12:40:54 +02:00
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
void BaseQt4ProjectWizardDialog::setSelectedModules(const QString &modules, bool lock)
|
2010-01-29 22:49:55 +01:00
|
|
|
{
|
2009-11-26 18:03:16 +01:00
|
|
|
if (m_modulesPage) {
|
|
|
|
|
foreach(const QString &module, modules.split(QLatin1Char(' '))) {
|
|
|
|
|
m_modulesPage->setModuleSelected(module, true);
|
|
|
|
|
m_modulesPage->setModuleEnabled(module, !lock);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
m_selectedModules = modules;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-17 12:40:54 +02:00
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
QString BaseQt4ProjectWizardDialog::deselectedModules() const
|
|
|
|
|
{
|
|
|
|
|
return m_modulesPage ? m_modulesPage->deselectedModules() : m_deselectedModules;
|
|
|
|
|
}
|
2009-06-17 12:40:54 +02:00
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
void BaseQt4ProjectWizardDialog::setDeselectedModules(const QString &modules)
|
|
|
|
|
{
|
|
|
|
|
if (m_modulesPage) {
|
|
|
|
|
foreach(const QString &module, modules.split(QLatin1Char(' ')))
|
|
|
|
|
m_modulesPage->setModuleSelected(module, false);
|
|
|
|
|
} else {
|
|
|
|
|
m_deselectedModules = modules;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-17 12:40:54 +02:00
|
|
|
|