forked from qt-creator/qt-creator
Update projectloadwizard
* Handle shadowbuild directories * Refactor the code Reviewed-by: dt
This commit is contained in:
@@ -36,7 +36,7 @@
|
|||||||
#include "qt4buildconfiguration.h"
|
#include "qt4buildconfiguration.h"
|
||||||
#include "qt4projectmanagerconstants.h"
|
#include "qt4projectmanagerconstants.h"
|
||||||
|
|
||||||
#include "wizards/targetspage.h"
|
#include "wizards/targetsetuppage.h"
|
||||||
|
|
||||||
#include <QtGui/QCheckBox>
|
#include <QtGui/QCheckBox>
|
||||||
#include <QtGui/QHeaderView>
|
#include <QtGui/QHeaderView>
|
||||||
@@ -48,52 +48,19 @@ using namespace Qt4ProjectManager;
|
|||||||
using namespace Qt4ProjectManager::Internal;
|
using namespace Qt4ProjectManager::Internal;
|
||||||
|
|
||||||
ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags)
|
ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::WindowFlags flags)
|
||||||
: QWizard(parent, flags), m_project(project), m_importVersion(0), m_temporaryVersion(false),
|
: QWizard(parent, flags), m_project(project), m_targetSetupPage(0)
|
||||||
m_targetsPage(0)
|
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Import existing build settings"));
|
Q_ASSERT(project);
|
||||||
QtVersionManager * vm = QtVersionManager::instance();
|
|
||||||
QString directory = project->projectDirectory();
|
|
||||||
QString importVersion = QtVersionManager::findQMakeBinaryFromMakefile(directory);
|
|
||||||
|
|
||||||
if (!importVersion.isNull()) {
|
setWindowTitle(tr("Project setup"));
|
||||||
// This also means we have a build in there
|
|
||||||
// First get the qt version
|
|
||||||
m_importVersion = vm->qtVersionForQMakeBinary(importVersion);
|
|
||||||
// Okay does not yet exist, create
|
|
||||||
if (!m_importVersion) {
|
|
||||||
m_importVersion = new QtVersion(importVersion);
|
|
||||||
m_temporaryVersion = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
m_importVersions = TargetSetupPage::recursivelyCheckDirectoryForBuild(project->projectDirectory());
|
||||||
QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig());
|
m_importVersions.append(TargetSetupPage::recursivelyCheckDirectoryForBuild(project->defaultTopLevelBuildDirectory()));
|
||||||
m_importBuildConfig = result.first;
|
|
||||||
m_additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second);
|
|
||||||
|
|
||||||
QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArgumentList(result.second, directory, m_importVersion);
|
m_importVersions.append(TargetSetupPage::importInfosForKnownQtVersions(project));
|
||||||
QString versionSpec = m_importVersion->mkspec();
|
|
||||||
|
|
||||||
// Compare mkspecs and add to additional arguments
|
if (m_importVersions.count() > 1)
|
||||||
if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") {
|
setupTargetPage();
|
||||||
// using the default spec, don't modify additional arguments
|
|
||||||
} else {
|
|
||||||
m_additionalArguments.prepend(parsedSpec);
|
|
||||||
m_additionalArguments.prepend("-spec");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// So now we have the version and the configuration for that version
|
|
||||||
// If buildAll we create debug and release configurations,
|
|
||||||
// if not then just either debug or release
|
|
||||||
// The default buildConfiguration depends on QmakeBuildConfig::DebugBuild
|
|
||||||
// Also if the qt version is not yet in the Tools Options dialog we offer to add it there
|
|
||||||
|
|
||||||
QList<QtVersion *> validVersions = vm->validVersions();
|
|
||||||
if (m_importVersion)
|
|
||||||
setupImportPage(m_importVersion, m_importBuildConfig, m_additionalArguments);
|
|
||||||
else if (validVersions.count() > 1)
|
|
||||||
setupTargetsPage();
|
|
||||||
|
|
||||||
setOptions(options() | QWizard::NoCancelButton | QWizard::NoBackButtonOnLastPage);
|
setOptions(options() | QWizard::NoCancelButton | QWizard::NoBackButtonOnLastPage);
|
||||||
}
|
}
|
||||||
@@ -114,59 +81,12 @@ ProjectLoadWizard::~ProjectLoadWizard()
|
|||||||
|
|
||||||
void ProjectLoadWizard::done(int result)
|
void ProjectLoadWizard::done(int result)
|
||||||
{
|
{
|
||||||
QtVersionManager *vm = QtVersionManager::instance();
|
|
||||||
QWizard::done(result);
|
QWizard::done(result);
|
||||||
// This normally happens on showing the final page, but since we
|
// This normally happens on showing the final page, but since we
|
||||||
// don't show it anymore, do it here
|
// don't show it anymore, do it here
|
||||||
|
|
||||||
if (m_importVersion && importCheckbox->isChecked()) {
|
if (result == Accepted)
|
||||||
// Importing
|
applySettings();
|
||||||
if (m_temporaryVersion)
|
|
||||||
vm->addVersion(m_importVersion);
|
|
||||||
|
|
||||||
// Import the existing stuff
|
|
||||||
// qDebug()<<"Creating m_buildconfiguration entry from imported stuff";
|
|
||||||
// qDebug()<<((m_importBuildConfig& QtVersion::BuildAll)? "debug_and_release" : "")<<((m_importBuildConfig & QtVersion::DebugBuild)? "debug" : "release");
|
|
||||||
foreach (const QString &id, m_importVersion->supportedTargetIds()) {
|
|
||||||
Qt4Target *t(m_project->targetFactory()->create(m_project, id, QList<QtVersion*>() << m_importVersion));
|
|
||||||
if (!t)
|
|
||||||
continue;
|
|
||||||
m_project->addTarget(t);
|
|
||||||
}
|
|
||||||
if (m_project->targets().isEmpty())
|
|
||||||
qWarning() << "Failed to populate project with default targets for imported Qt" << m_importVersion->displayName();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_targetsPage) {
|
|
||||||
m_targetsPage->setupProject(m_project);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not importing anything
|
|
||||||
if (m_temporaryVersion)
|
|
||||||
delete m_importVersion;
|
|
||||||
|
|
||||||
// Find a Qt version:
|
|
||||||
QList<QtVersion *> candidates = vm->versions();
|
|
||||||
QtVersion *defaultVersion = candidates.at(0); // always there and always valid!
|
|
||||||
// Check for the first valid desktop-Qt, fall back to any valid Qt if no desktop
|
|
||||||
// flavour is available.
|
|
||||||
foreach (QtVersion *v, candidates) {
|
|
||||||
if (v->isValid())
|
|
||||||
defaultVersion = v;
|
|
||||||
if (v->supportsTargetId(Constants::DESKTOP_TARGET_ID) && v->isValid())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (const QString &id, defaultVersion->supportedTargetIds()) {
|
|
||||||
Qt4Target *t(m_project->targetFactory()->create(m_project, id, QList<QtVersion *>() << defaultVersion));
|
|
||||||
if (!t)
|
|
||||||
continue;
|
|
||||||
m_project->addTarget(t);
|
|
||||||
}
|
|
||||||
if (m_project->targets().isEmpty())
|
|
||||||
qWarning() << "Failed to populate project with default targets for default Qt" << defaultVersion->displayName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function used to do the commented stuff instead of having only one page
|
// This function used to do the commented stuff instead of having only one page
|
||||||
@@ -175,51 +95,22 @@ int ProjectLoadWizard::nextId() const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfigs buildConfig, QStringList addtionalArguments)
|
void ProjectLoadWizard::setupTargetPage()
|
||||||
{
|
{
|
||||||
resize(605, 490);
|
if (m_targetSetupPage)
|
||||||
// Import Page
|
|
||||||
importPage = new QWizardPage(this);
|
|
||||||
importPage->setTitle(tr("Import existing build settings"));
|
|
||||||
QVBoxLayout *importLayout = new QVBoxLayout(importPage);
|
|
||||||
importLabel = new QLabel(importPage);
|
|
||||||
|
|
||||||
QString versionString = version->displayName() + QLatin1String(" (") +
|
|
||||||
QDir::toNativeSeparators(version->qmakeCommand()) +
|
|
||||||
QLatin1Char(')');
|
|
||||||
QString buildConfigString = (buildConfig & QtVersion::BuildAll) ? QLatin1String("debug_and_release ") : QString();
|
|
||||||
buildConfigString.append((buildConfig & QtVersion::DebugBuild) ? QLatin1String("debug") : QLatin1String("release"));
|
|
||||||
importLabel->setTextFormat(Qt::RichText);
|
|
||||||
importLabel->setText(tr("Qt Creator has found an already existing build in the source directory.<br><br>"
|
|
||||||
"<b>Qt Version:</b> %1<br>"
|
|
||||||
"<b>Build configuration:</b> %2<br>"
|
|
||||||
"<b>Additional qmake Arguments:</b>%3")
|
|
||||||
.arg(versionString)
|
|
||||||
.arg(buildConfigString)
|
|
||||||
.arg(ProjectExplorer::Environment::joinArgumentList(addtionalArguments)));
|
|
||||||
|
|
||||||
importLayout->addWidget(importLabel);
|
|
||||||
|
|
||||||
|
|
||||||
importCheckbox = new QCheckBox(importPage);
|
|
||||||
importCheckbox->setText(tr("Import existing build settings."));
|
|
||||||
importCheckbox->setChecked(true);
|
|
||||||
importLayout->addWidget(importCheckbox);
|
|
||||||
import2Label = new QLabel(importPage);
|
|
||||||
import2Label->setTextFormat(Qt::RichText);
|
|
||||||
if (m_temporaryVersion)
|
|
||||||
import2Label->setText(tr("<b>Note:</b> Importing the settings will automatically add the Qt Version identified by <br><b>%1</b> to the list of Qt versions.")
|
|
||||||
.arg(QDir::toNativeSeparators(m_importVersion->qmakeCommand())));
|
|
||||||
importLayout->addWidget(import2Label);
|
|
||||||
addPage(importPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectLoadWizard::setupTargetsPage()
|
|
||||||
{
|
|
||||||
if (m_targetsPage)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_targetsPage = new TargetsPage(this);
|
m_targetSetupPage = new TargetSetupPage(this);
|
||||||
addPage(m_targetsPage);
|
m_targetSetupPage->setImportInfos(m_importVersions);
|
||||||
|
m_targetSetupPage->setImportDirectoryBrowsingEnabled(true);
|
||||||
|
m_targetSetupPage->setImportDirectoryBrowsingLocation(m_project->projectDirectory());
|
||||||
|
|
||||||
|
addPage(m_targetSetupPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectLoadWizard::applySettings()
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_targetSetupPage);
|
||||||
|
m_targetSetupPage->setupProject(m_project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,9 @@
|
|||||||
#define PROJECTLOADWIZARD_H
|
#define PROJECTLOADWIZARD_H
|
||||||
|
|
||||||
#include "qtversionmanager.h"
|
#include "qtversionmanager.h"
|
||||||
|
#include "wizards/targetsetuppage.h"
|
||||||
#include <QtGui/QWizard>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QWizardPage;
|
|
||||||
class QLabel;
|
|
||||||
class QCheckBox;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
|
|
||||||
class Qt4Project;
|
class Qt4Project;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -59,28 +51,14 @@ public:
|
|||||||
void execDialog();
|
void execDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfigs buildConfig, QStringList addtionalArguments);
|
void setupTargetPage();
|
||||||
void setupTargetsPage();
|
|
||||||
|
void applySettings();
|
||||||
|
|
||||||
Qt4Project *m_project;
|
Qt4Project *m_project;
|
||||||
|
QList<TargetSetupPage::ImportInfo> m_importVersions;
|
||||||
|
|
||||||
// Only used for imported stuff
|
TargetSetupPage *m_targetSetupPage;
|
||||||
QtVersion *m_importVersion;
|
|
||||||
QtVersion::QmakeBuildConfigs m_importBuildConfig;
|
|
||||||
QStringList m_additionalArguments;
|
|
||||||
// Those that we might add
|
|
||||||
bool m_temporaryVersion;
|
|
||||||
|
|
||||||
// This was a file autogenarated by Designer, before I found out you can't actually
|
|
||||||
// create non linear wizards in it
|
|
||||||
// So those variables should all be m_*, but that one has to wait for refactoring support :)
|
|
||||||
QWizardPage *importPage;
|
|
||||||
QLabel *importLabel;
|
|
||||||
QLabel *import2Label;
|
|
||||||
QCheckBox *importCheckbox;
|
|
||||||
TargetsPage *m_targetsPage;
|
|
||||||
|
|
||||||
void setupUi();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user