forked from qt-creator/qt-creator
Show TargetSelectionPage when opening .pro files
Do this as part of the ProjectLoadWizard
This commit is contained in:
@@ -30,13 +30,12 @@
|
|||||||
#include "projectloadwizard.h"
|
#include "projectloadwizard.h"
|
||||||
|
|
||||||
#include "qt4project.h"
|
#include "qt4project.h"
|
||||||
#include "qt4projectmanager.h"
|
|
||||||
#include "qmakestep.h"
|
#include "qmakestep.h"
|
||||||
#include "qt4target.h"
|
#include "qt4target.h"
|
||||||
#include "makestep.h"
|
#include "makestep.h"
|
||||||
#include "qt4buildconfiguration.h"
|
#include "qt4buildconfiguration.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include "wizards/targetspage.h"
|
||||||
|
|
||||||
#include <QtGui/QCheckBox>
|
#include <QtGui/QCheckBox>
|
||||||
#include <QtGui/QHeaderView>
|
#include <QtGui/QHeaderView>
|
||||||
@@ -48,7 +47,8 @@ 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_importVersion(0), m_temporaryVersion(false),
|
||||||
|
m_targetsPage(0)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Import existing build settings"));
|
setWindowTitle(tr("Import existing build settings"));
|
||||||
QtVersionManager * vm = QtVersionManager::instance();
|
QtVersionManager * vm = QtVersionManager::instance();
|
||||||
@@ -88,8 +88,16 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
|
|||||||
// The default buildConfiguration depends on QmakeBuildConfig::DebugBuild
|
// 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
|
// Also if the qt version is not yet in the Tools Options dialog we offer to add it there
|
||||||
|
|
||||||
|
QList<QtVersion *> validVersions;
|
||||||
|
foreach (QtVersion * v, vm->versions()) {
|
||||||
|
if (v->isValid())
|
||||||
|
validVersions.append(v);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_importVersion)
|
if (m_importVersion)
|
||||||
setupImportPage(m_importVersion, m_importBuildConfig, m_additionalArguments);
|
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);
|
||||||
}
|
}
|
||||||
@@ -98,7 +106,7 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
|
|||||||
// We used to simply call ::exec() on the dialog
|
// We used to simply call ::exec() on the dialog
|
||||||
void ProjectLoadWizard::execDialog()
|
void ProjectLoadWizard::execDialog()
|
||||||
{
|
{
|
||||||
if (m_importVersion)
|
if (!pageIds().isEmpty())
|
||||||
exec();
|
exec();
|
||||||
else
|
else
|
||||||
done(QDialog::Accepted);
|
done(QDialog::Accepted);
|
||||||
@@ -106,7 +114,6 @@ void ProjectLoadWizard::execDialog()
|
|||||||
|
|
||||||
ProjectLoadWizard::~ProjectLoadWizard()
|
ProjectLoadWizard::~ProjectLoadWizard()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectLoadWizard::done(int result)
|
void ProjectLoadWizard::done(int result)
|
||||||
@@ -132,8 +139,16 @@ void ProjectLoadWizard::done(int result)
|
|||||||
}
|
}
|
||||||
if (m_project->targets().isEmpty())
|
if (m_project->targets().isEmpty())
|
||||||
qWarning() << "Failed to populate project with default targets for imported Qt" << m_importVersion->displayName();
|
qWarning() << "Failed to populate project with default targets for imported Qt" << m_importVersion->displayName();
|
||||||
} else {
|
|
||||||
// Not importing
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_targetsPage) {
|
||||||
|
m_targetsPage->setupProject(m_project);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not importing anything
|
||||||
if (m_temporaryVersion)
|
if (m_temporaryVersion)
|
||||||
delete m_importVersion;
|
delete m_importVersion;
|
||||||
|
|
||||||
@@ -157,7 +172,6 @@ void ProjectLoadWizard::done(int result)
|
|||||||
}
|
}
|
||||||
if (m_project->targets().isEmpty())
|
if (m_project->targets().isEmpty())
|
||||||
qWarning() << "Failed to populate project with default targets for default Qt" << defaultVersion->displayName();
|
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
|
||||||
@@ -205,3 +219,12 @@ void ProjectLoadWizard::setupImportPage(QtVersion *version, QtVersion::QmakeBuil
|
|||||||
addPage(importPage);
|
addPage(importPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectLoadWizard::setupTargetsPage()
|
||||||
|
{
|
||||||
|
if (m_targetsPage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_targetsPage = new TargetsPage(this);
|
||||||
|
addPage(m_targetsPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class Qt4Project;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class TargetsPage;
|
||||||
|
|
||||||
class ProjectLoadWizard : public QWizard
|
class ProjectLoadWizard : public QWizard
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -58,6 +60,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfigs buildConfig, QStringList addtionalArguments);
|
void setupImportPage(QtVersion *version, QtVersion::QmakeBuildConfigs buildConfig, QStringList addtionalArguments);
|
||||||
|
void setupTargetsPage();
|
||||||
|
|
||||||
Qt4Project *m_project;
|
Qt4Project *m_project;
|
||||||
|
|
||||||
@@ -75,6 +78,7 @@ private:
|
|||||||
QLabel *importLabel;
|
QLabel *importLabel;
|
||||||
QLabel *import2Label;
|
QLabel *import2Label;
|
||||||
QCheckBox *importCheckbox;
|
QCheckBox *importCheckbox;
|
||||||
|
TargetsPage *m_targetsPage;
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
#include "qtwizard.h"
|
#include "qtwizard.h"
|
||||||
|
|
||||||
#include "qt4project.h"
|
#include "qt4project.h"
|
||||||
#include "qt4projectmanager.h"
|
|
||||||
#include "qt4projectmanagerconstants.h"
|
#include "qt4projectmanagerconstants.h"
|
||||||
#include "qt4target.h"
|
#include "qt4target.h"
|
||||||
#include "modulespage.h"
|
#include "modulespage.h"
|
||||||
@@ -109,26 +108,7 @@ bool QtWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l
|
|||||||
const BaseQt4ProjectWizardDialog *dialog = qobject_cast<const BaseQt4ProjectWizardDialog *>(w);
|
const BaseQt4ProjectWizardDialog *dialog = qobject_cast<const BaseQt4ProjectWizardDialog *>(w);
|
||||||
|
|
||||||
// Generate user settings:
|
// Generate user settings:
|
||||||
QSet<QString> targets;
|
dialog->writeUserFile(proFileName);
|
||||||
if (dialog)
|
|
||||||
targets = dialog->selectedTargets();
|
|
||||||
if (!targets.isEmpty()) {
|
|
||||||
Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
|
|
||||||
Q_ASSERT(manager);
|
|
||||||
QtVersionManager *vm = QtVersionManager::instance();
|
|
||||||
|
|
||||||
Qt4Project *pro = new Qt4Project(manager, proFileName);
|
|
||||||
foreach (const QString &targetId, targets) {
|
|
||||||
QList<int> versionIds = dialog->selectedQtVersionIdsForTarget(targetId);
|
|
||||||
QList<QtVersion *> versions;
|
|
||||||
foreach (int id, versionIds)
|
|
||||||
versions.append(vm->version(id));
|
|
||||||
Qt4Target * target = pro->targetFactory()->create(pro, targetId, versions);
|
|
||||||
pro->addTarget(target);
|
|
||||||
}
|
|
||||||
pro->saveSettings();
|
|
||||||
delete pro;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Post-Generate: Open the project
|
// Post-Generate: Open the project
|
||||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFileName)) {
|
||||||
@@ -256,18 +236,18 @@ void BaseQt4ProjectWizardDialog::setDeselectedModules(const QString &modules)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> BaseQt4ProjectWizardDialog::selectedTargets() const
|
void BaseQt4ProjectWizardDialog::writeUserFile(const QString &proFileName) const
|
||||||
{
|
{
|
||||||
if (!m_targetsPage)
|
if (m_targetsPage)
|
||||||
return QSet<QString>();
|
m_targetsPage->writeUserFile(proFileName);
|
||||||
return m_targetsPage->selectedTargets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> BaseQt4ProjectWizardDialog::selectedQtVersionIdsForTarget(const QString &target) const
|
QSet<QString> BaseQt4ProjectWizardDialog::selectedTargets() const
|
||||||
{
|
{
|
||||||
if (!m_targetsPage)
|
QSet<QString> targets;
|
||||||
return QList<int>();
|
if (m_targetsPage)
|
||||||
return m_targetsPage->selectedVersionIdsForTarget(target);
|
targets = m_targetsPage->selectedTargets();
|
||||||
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> BaseQt4ProjectWizardDialog::desktopTarget()
|
QSet<QString> BaseQt4ProjectWizardDialog::desktopTarget()
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ public:
|
|||||||
QString deselectedModules() const;
|
QString deselectedModules() const;
|
||||||
void setDeselectedModules(const QString &);
|
void setDeselectedModules(const QString &);
|
||||||
|
|
||||||
|
void writeUserFile(const QString &proFileName) const;
|
||||||
QSet<QString> selectedTargets() const;
|
QSet<QString> selectedTargets() const;
|
||||||
QList<int> selectedQtVersionIdsForTarget(const QString &target) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void init(bool showModulesPage);
|
inline void init(bool showModulesPage);
|
||||||
|
|||||||
@@ -29,9 +29,13 @@
|
|||||||
|
|
||||||
#include "targetspage.h"
|
#include "targetspage.h"
|
||||||
|
|
||||||
|
#include "qt4projectmanager/qt4project.h"
|
||||||
|
#include "qt4projectmanager/qt4projectmanager.h"
|
||||||
#include "qt4projectmanager/qt4target.h"
|
#include "qt4projectmanager/qt4target.h"
|
||||||
#include "qt4projectmanager/qtversionmanager.h"
|
#include "qt4projectmanager/qtversionmanager.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
@@ -134,14 +138,14 @@ QSet<QString> TargetsPage::selectedTargets() const
|
|||||||
QTreeWidgetItem * targetItem = m_treeWidget->topLevelItem(i);
|
QTreeWidgetItem * targetItem = m_treeWidget->topLevelItem(i);
|
||||||
QString target = targetItem->data(0, Qt::UserRole).toString();
|
QString target = targetItem->data(0, Qt::UserRole).toString();
|
||||||
|
|
||||||
QList<int> versions = selectedVersionIdsForTarget(target);
|
QList<int> versions = selectedQtVersionIdsForTarget(target);
|
||||||
if (!versions.isEmpty())
|
if (!versions.isEmpty())
|
||||||
result.insert(target);
|
result.insert(target);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> TargetsPage::selectedVersionIdsForTarget(const QString &t) const
|
QList<int> TargetsPage::selectedQtVersionIdsForTarget(const QString &t) const
|
||||||
{
|
{
|
||||||
QList<int> result;
|
QList<int> result;
|
||||||
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
|
for (int i = 0; i < m_treeWidget->topLevelItemCount(); ++i) {
|
||||||
@@ -186,3 +190,37 @@ bool TargetsPage::needToDisplayPage() const
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TargetsPage::writeUserFile(const QString &proFileName) const
|
||||||
|
{
|
||||||
|
Qt4Manager *manager = ExtensionSystem::PluginManager::instance()->getObject<Qt4Manager>();
|
||||||
|
Q_ASSERT(manager);
|
||||||
|
|
||||||
|
Qt4Project *pro = new Qt4Project(manager, proFileName);
|
||||||
|
if (setupProject(pro))
|
||||||
|
pro->saveSettings();
|
||||||
|
delete pro;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TargetsPage::setupProject(Qt4ProjectManager::Qt4Project *project) const
|
||||||
|
{
|
||||||
|
if (!project)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Generate user settings:
|
||||||
|
QSet<QString> targets = selectedTargets();
|
||||||
|
if (targets.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QtVersionManager *vm = QtVersionManager::instance();
|
||||||
|
|
||||||
|
foreach (const QString &targetId, targets) {
|
||||||
|
QList<int> versionIds = selectedQtVersionIdsForTarget(targetId);
|
||||||
|
QList<QtVersion *> versions;
|
||||||
|
foreach (int id, versionIds)
|
||||||
|
versions.append(vm->version(id));
|
||||||
|
Qt4Target * target = project->targetFactory()->create(project, targetId, versions);
|
||||||
|
project->addTarget(target);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ class QTreeWidget;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
|
class Qt4Project;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class TargetsPage : public QWizardPage
|
class TargetsPage : public QWizardPage
|
||||||
@@ -53,12 +55,15 @@ public:
|
|||||||
void setValidTargets(const QSet<QString> &targets);
|
void setValidTargets(const QSet<QString> &targets);
|
||||||
|
|
||||||
QSet<QString> selectedTargets() const;
|
QSet<QString> selectedTargets() const;
|
||||||
QList<int> selectedVersionIdsForTarget(const QString &) const;
|
QList<int> selectedQtVersionIdsForTarget(const QString &) const;
|
||||||
|
|
||||||
bool isComplete() const;
|
bool isComplete() const;
|
||||||
|
|
||||||
bool needToDisplayPage() const;
|
bool needToDisplayPage() const;
|
||||||
|
|
||||||
|
void writeUserFile(const QString &proFileName) const;
|
||||||
|
bool setupProject(Qt4Project *project) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void itemWasClicked();
|
void itemWasClicked();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user