2009-11-26 18:03:16 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2009-11-26 18:03:16 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-11-26 18:03:16 +01: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-11-26 18:03:16 +01: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-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-11-26 18:03:16 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "baseprojectwizarddialog.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/basefilewizard.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/filemanager.h>
|
|
|
|
|
#include <utils/projectintropage.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
|
2011-04-14 12:58:14 +02:00
|
|
|
/*!
|
|
|
|
|
\class ProjectExplorer::BaseProjectWizardDialog
|
|
|
|
|
|
|
|
|
|
\brief Base class for project wizards.
|
|
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
Presents the introductory page and takes care of setting the folder chosen
|
2011-04-14 12:58:14 +02:00
|
|
|
as default projects' folder should the user wish to do that.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2010-01-29 22:49:55 +01:00
|
|
|
struct BaseProjectWizardDialogPrivate {
|
2009-11-26 18:03:16 +01:00
|
|
|
explicit BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id = -1);
|
|
|
|
|
|
2010-03-22 15:33:33 +01:00
|
|
|
const int desiredIntroPageId;
|
2010-01-07 18:17:24 +01:00
|
|
|
Utils::ProjectIntroPage *introPage;
|
2010-03-22 15:33:33 +01:00
|
|
|
int introPageId;
|
2009-11-26 18:03:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BaseProjectWizardDialogPrivate::BaseProjectWizardDialogPrivate(Utils::ProjectIntroPage *page, int id) :
|
2010-03-22 15:33:33 +01:00
|
|
|
desiredIntroPageId(id),
|
|
|
|
|
introPage(page),
|
2010-10-27 12:51:33 +02:00
|
|
|
introPageId(-1)
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseProjectWizardDialog::BaseProjectWizardDialog(QWidget *parent) :
|
2010-03-31 14:48:08 +02:00
|
|
|
Utils::Wizard(parent),
|
2009-11-26 18:03:16 +01:00
|
|
|
d(new BaseProjectWizardDialogPrivate(new Utils::ProjectIntroPage))
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseProjectWizardDialog::BaseProjectWizardDialog(Utils::ProjectIntroPage *introPage,
|
|
|
|
|
int introId,
|
|
|
|
|
QWidget *parent) :
|
2010-03-31 14:48:08 +02:00
|
|
|
Utils::Wizard(parent),
|
2009-11-26 18:03:16 +01:00
|
|
|
d(new BaseProjectWizardDialogPrivate(introPage, introId))
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::init()
|
|
|
|
|
{
|
|
|
|
|
Core::BaseFileWizard::setupWizard(this);
|
2010-03-22 15:33:33 +01:00
|
|
|
if (d->introPageId == -1) {
|
|
|
|
|
d->introPageId = addPage(d->introPage);
|
|
|
|
|
} else {
|
|
|
|
|
d->introPageId = d->desiredIntroPageId;
|
|
|
|
|
setPage(d->desiredIntroPageId, d->introPage);
|
|
|
|
|
}
|
2010-03-31 14:48:08 +02:00
|
|
|
wizardProgress()->item(d->introPageId)->setTitle(tr("Location"));
|
2009-11-26 18:03:16 +01:00
|
|
|
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
|
2010-10-27 12:51:33 +02:00
|
|
|
connect(this, SIGNAL(nextClicked()), this, SLOT(nextClicked()));
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BaseProjectWizardDialog::~BaseProjectWizardDialog()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString BaseProjectWizardDialog::projectName() const
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
return d->introPage->projectName();
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString BaseProjectWizardDialog::path() const
|
|
|
|
|
{
|
|
|
|
|
return d->introPage->path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setIntroDescription(const QString &des)
|
|
|
|
|
{
|
|
|
|
|
d->introPage->setDescription(des);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::setPath(const QString &path)
|
|
|
|
|
{
|
|
|
|
|
d->introPage->setPath(path);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
void BaseProjectWizardDialog::setProjectName(const QString &name)
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
2010-01-07 18:17:24 +01:00
|
|
|
d->introPage->setProjectName(name);
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BaseProjectWizardDialog::slotAccepted()
|
|
|
|
|
{
|
|
|
|
|
if (d->introPage->useAsDefaultPath()) {
|
2010-03-22 15:33:33 +01:00
|
|
|
// Store the path as default path for new projects if desired.
|
2012-01-19 23:23:43 +01:00
|
|
|
Core::FileManager::setProjectsDirectory(path());
|
|
|
|
|
Core::FileManager::setUseProjectsDirectory(true);
|
2009-11-26 18:03:16 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-27 12:51:33 +02:00
|
|
|
void BaseProjectWizardDialog::nextClicked()
|
2010-03-22 15:33:33 +01:00
|
|
|
{
|
2010-10-27 12:51:33 +02:00
|
|
|
if (currentId() == d->introPageId) {
|
|
|
|
|
emit projectParametersChanged(d->introPage->projectName(), d->introPage->path());
|
2010-03-22 15:33:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-26 18:03:16 +01:00
|
|
|
Utils::ProjectIntroPage *BaseProjectWizardDialog::introPage() const
|
|
|
|
|
{
|
|
|
|
|
return d->introPage;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString BaseProjectWizardDialog::uniqueProjectName(const QString &path)
|
2009-11-26 18:03:16 +01:00
|
|
|
{
|
|
|
|
|
const QDir pathDir(path);
|
2010-02-15 11:08:23 +01:00
|
|
|
//: File path suggestion for a new project. If you choose
|
2012-01-16 13:50:48 +01:00
|
|
|
//: to translate it, make sure it is a valid path name without blanks
|
|
|
|
|
//: and using only ascii chars.
|
2009-11-26 18:03:16 +01:00
|
|
|
const QString prefix = tr("untitled");
|
2011-04-19 15:42:14 +02:00
|
|
|
for (unsigned i = 0; ; ++i) {
|
2009-11-26 18:03:16 +01:00
|
|
|
QString name = prefix;
|
|
|
|
|
if (i)
|
|
|
|
|
name += QString::number(i);
|
|
|
|
|
if (!pathDir.exists(name))
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
return prefix;
|
|
|
|
|
}
|
|
|
|
|
} // namespace ProjectExplorer
|