Commit fc867d5d authored by Daniel Teske's avatar Daniel Teske

CMakeOpenProjectWizard: Warn the user if no kit is available

And allow the user to configure kits before proceding.

Change-Id: I6acf2bcc05d53b0ac9d448599d29d2fe02ae1349
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@digia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 82f8ba65
......@@ -39,6 +39,7 @@
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <texteditor/fontsettings.h>
#include <QVBoxLayout>
......@@ -89,7 +90,6 @@ namespace Internal {
ProjectExplorer::Kit *m_kit;
bool m_isNinja;
};
}
}
......@@ -210,6 +210,9 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
m_useNinja(false),
m_kit(0)
{
if (!compatibleKitExist())
addPage(new NoKitPage(this));
if (hasInSourceBuild()) {
m_buildDirectory = m_sourceDirectory;
addPage(new InSourceBuildPage(this));
......@@ -274,6 +277,27 @@ bool CMakeOpenProjectWizard::hasInSourceBuild() const
return false;
}
bool CMakeOpenProjectWizard::compatibleKitExist() const
{
bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator();
bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator();
QList<ProjectExplorer::Kit *> kitList =
ProjectExplorer::KitManager::instance()->kits();
foreach (ProjectExplorer::Kit *k, kitList) {
// OfferNinja and ForceNinja differ in what they return
// but not whether the list is empty or not, which is what we
// are interested in here
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
hasCodeBlocksGenerator);
if (!infos.isEmpty())
return true;
}
return false;
}
bool CMakeOpenProjectWizard::existsUpToDateXmlFile() const
{
QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory()));
......@@ -338,6 +362,63 @@ void CMakeOpenProjectWizard::setKit(ProjectExplorer::Kit *kit)
m_kit = kit;
}
//////
// NoKitPage
/////
NoKitPage::NoKitPage(CMakeOpenProjectWizard *cmakeWizard)
: QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard)
{
QVBoxLayout *layout = new QVBoxLayout;
setLayout(layout);
m_descriptionLabel = new QLabel(this);
m_descriptionLabel->setWordWrap(true);
layout->addWidget(m_descriptionLabel);
m_optionsButton = new QPushButton;
m_optionsButton->setText(tr("Show Options"));
connect(m_optionsButton, SIGNAL(clicked()),
this, SLOT(showOptions()));
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(m_optionsButton);
hbox->addStretch();
layout->addLayout(hbox);
setTitle(tr("Check Kits"));
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()),
this, SLOT(kitsChanged()));
kitsChanged();
}
void NoKitPage::kitsChanged()
{
if (isComplete()) {
m_descriptionLabel->setText(tr("There are compatible kits."));
m_optionsButton->setVisible(false);
} else {
m_descriptionLabel->setText(tr("Qt Creator has no kits that are suitable for CMake projects. Please configure a kit."));
m_optionsButton->setVisible(true);
}
emit completeChanged();
}
bool NoKitPage::isComplete() const
{
return m_cmakeWizard->compatibleKitExist();
}
void NoKitPage::showOptions()
{
Core::ICore::showOptionsDialog(Core::Id(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY),
Core::Id(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID), this);
}
InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard)
: QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard)
{
......
......@@ -111,6 +111,7 @@ public:
ProjectExplorer::Kit *kit() const;
void setKit(ProjectExplorer::Kit *kit);
bool existsUpToDateXmlFile() const;
bool compatibleKitExist() const;
private:
void init();
......@@ -124,6 +125,21 @@ private:
ProjectExplorer::Kit *m_kit;
};
class NoKitPage : public QWizardPage
{
Q_OBJECT
public:
NoKitPage(CMakeOpenProjectWizard *cmakeWizard);
bool isComplete() const;
private slots:
void kitsChanged();
void showOptions();
private:
QLabel *m_descriptionLabel;
QPushButton *m_optionsButton;
CMakeOpenProjectWizard *m_cmakeWizard;
};
class InSourceBuildPage : public QWizardPage
{
Q_OBJECT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment