forked from qt-creator/qt-creator
CMakeOpenProjectWizard: Add page asking for cmake executable
We used to do that on the cmake run page, but given it's own page is certainly better. Task-number: QTCREATORBUG-7971 Change-Id: Id38690a750e99dbccfd9f17f64423033891b0d78 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -216,6 +216,9 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const
|
|||||||
addPage(new ShadowBuildPage(this));
|
addPage(new ShadowBuildPage(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_cmakeManager->isCMakeExecutableValid())
|
||||||
|
addPage(new ChooseCMakePage(this));
|
||||||
|
|
||||||
addPage(new CMakeRunPage(this));
|
addPage(new CMakeRunPage(this));
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -243,6 +246,8 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMake
|
|||||||
m_buildDirectory = info.buildDirectory;
|
m_buildDirectory = info.buildDirectory;
|
||||||
addPage(new ShadowBuildPage(this, true));
|
addPage(new ShadowBuildPage(this, true));
|
||||||
}
|
}
|
||||||
|
if (!m_cmakeManager->isCMakeExecutableValid())
|
||||||
|
addPage(new ChooseCMakePage(this));
|
||||||
|
|
||||||
addPage(new CMakeRunPage(this, rmode, info.buildDirectory));
|
addPage(new CMakeRunPage(this, rmode, info.buildDirectory));
|
||||||
init();
|
init();
|
||||||
@@ -375,6 +380,61 @@ void ShadowBuildPage::buildDirectoryChanged()
|
|||||||
m_cmakeWizard->setBuildDirectory(m_pc->path());
|
m_cmakeWizard->setBuildDirectory(m_pc->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChooseCMakePage::ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard)
|
||||||
|
: QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard)
|
||||||
|
{
|
||||||
|
QFormLayout *fl = new QFormLayout;
|
||||||
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
|
setLayout(fl);
|
||||||
|
|
||||||
|
m_cmakeLabel = new QLabel;
|
||||||
|
m_cmakeLabel->setWordWrap(true);
|
||||||
|
fl->addRow(m_cmakeLabel);
|
||||||
|
// Show a field for the user to enter
|
||||||
|
m_cmakeExecutable = new Utils::PathChooser(this);
|
||||||
|
m_cmakeExecutable->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||||
|
fl->addRow("cmake Executable:", m_cmakeExecutable);
|
||||||
|
|
||||||
|
connect(m_cmakeExecutable, SIGNAL(editingFinished()),
|
||||||
|
this, SLOT(cmakeExecutableChanged()));
|
||||||
|
connect(m_cmakeExecutable, SIGNAL(browsingFinished()),
|
||||||
|
this, SLOT(cmakeExecutableChanged()));
|
||||||
|
|
||||||
|
setTitle(tr("Choose Cmake Executable"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChooseCMakePage::updateErrorText()
|
||||||
|
{
|
||||||
|
QString cmakeExecutable = m_cmakeWizard->cmakeManager()->cmakeExecutable();
|
||||||
|
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
|
||||||
|
m_cmakeLabel->setText(tr("The cmake executable is valid."));
|
||||||
|
} else {
|
||||||
|
QString text = tr("Please specify the path to the cmake executable. No cmake executable was found in the path.");
|
||||||
|
if (!cmakeExecutable.isEmpty()) {
|
||||||
|
QFileInfo fi(cmakeExecutable);
|
||||||
|
if (!fi.exists())
|
||||||
|
text += tr(" The cmake executable (%1) does not exist.").arg(cmakeExecutable);
|
||||||
|
else if (!fi.isExecutable())
|
||||||
|
text += tr(" The path %1 is not a executable.").arg(cmakeExecutable);
|
||||||
|
else
|
||||||
|
text += tr(" The path %1 is not a valid cmake.").arg(cmakeExecutable);
|
||||||
|
}
|
||||||
|
m_cmakeLabel->setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChooseCMakePage::cmakeExecutableChanged()
|
||||||
|
{
|
||||||
|
m_cmakeWizard->cmakeManager()->setCMakeExecutable(m_cmakeExecutable->path());
|
||||||
|
updateErrorText();
|
||||||
|
emit completeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChooseCMakePage::isComplete() const
|
||||||
|
{
|
||||||
|
return m_cmakeWizard->cmakeManager()->isCMakeExecutableValid();
|
||||||
|
}
|
||||||
|
|
||||||
CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory)
|
CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory)
|
||||||
: QWizardPage(cmakeWizard),
|
: QWizardPage(cmakeWizard),
|
||||||
m_cmakeWizard(cmakeWizard),
|
m_cmakeWizard(cmakeWizard),
|
||||||
@@ -397,30 +457,6 @@ void CMakeRunPage::initWidgets()
|
|||||||
|
|
||||||
fl->addRow(m_descriptionLabel);
|
fl->addRow(m_descriptionLabel);
|
||||||
|
|
||||||
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
|
|
||||||
m_cmakeExecutable = 0;
|
|
||||||
} else {
|
|
||||||
QString text = tr("Please specify the path to the cmake executable. No cmake executable was found in the path.");
|
|
||||||
QString cmakeExecutable = m_cmakeWizard->cmakeManager()->cmakeExecutable();
|
|
||||||
if (!cmakeExecutable.isEmpty()) {
|
|
||||||
QFileInfo fi(cmakeExecutable);
|
|
||||||
if (!fi.exists())
|
|
||||||
text += tr(" The cmake executable (%1) does not exist.").arg(cmakeExecutable);
|
|
||||||
else if (!fi.isExecutable())
|
|
||||||
text += tr(" The path %1 is not a executable.").arg(cmakeExecutable);
|
|
||||||
else
|
|
||||||
text += tr(" The path %1 is not a valid cmake.").arg(cmakeExecutable);
|
|
||||||
}
|
|
||||||
|
|
||||||
QLabel *cmakeLabel = new QLabel(text);
|
|
||||||
cmakeLabel->setWordWrap(true);
|
|
||||||
fl->addRow(cmakeLabel);
|
|
||||||
// Show a field for the user to enter
|
|
||||||
m_cmakeExecutable = new Utils::PathChooser(this);
|
|
||||||
m_cmakeExecutable->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
||||||
fl->addRow("cmake Executable:", m_cmakeExecutable);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run CMake Line (with arguments)
|
// Run CMake Line (with arguments)
|
||||||
m_argumentsLineEdit = new Utils::FancyLineEdit(this);
|
m_argumentsLineEdit = new Utils::FancyLineEdit(this);
|
||||||
m_argumentsLineEdit->setHistoryCompleter(QLatin1String("CMakeArgumentsLineEdit"));
|
m_argumentsLineEdit->setHistoryCompleter(QLatin1String("CMakeArgumentsLineEdit"));
|
||||||
@@ -586,10 +622,6 @@ bool CMakeRunPage::validatePage()
|
|||||||
|
|
||||||
void CMakeRunPage::runCMake()
|
void CMakeRunPage::runCMake()
|
||||||
{
|
{
|
||||||
if (m_cmakeExecutable)
|
|
||||||
// We asked the user for the cmake executable
|
|
||||||
m_cmakeWizard->cmakeManager()->setCMakeExecutable(m_cmakeExecutable->path());
|
|
||||||
|
|
||||||
m_optionalCMake = false;
|
m_optionalCMake = false;
|
||||||
m_complete = false;
|
m_complete = false;
|
||||||
|
|
||||||
|
@@ -145,6 +145,22 @@ private:
|
|||||||
Utils::PathChooser *m_pc;
|
Utils::PathChooser *m_pc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ChooseCMakePage : public QWizardPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard);
|
||||||
|
|
||||||
|
virtual bool isComplete() const;
|
||||||
|
public slots:
|
||||||
|
void cmakeExecutableChanged();
|
||||||
|
private:
|
||||||
|
void updateErrorText();
|
||||||
|
QLabel *m_cmakeLabel;
|
||||||
|
CMakeOpenProjectWizard *m_cmakeWizard;
|
||||||
|
Utils::PathChooser *m_cmakeExecutable;
|
||||||
|
};
|
||||||
|
|
||||||
class CMakeRunPage : public QWizardPage
|
class CMakeRunPage : public QWizardPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -169,7 +185,6 @@ private:
|
|||||||
QPushButton *m_runCMake;
|
QPushButton *m_runCMake;
|
||||||
Utils::QtcProcess *m_cmakeProcess;
|
Utils::QtcProcess *m_cmakeProcess;
|
||||||
Utils::FancyLineEdit *m_argumentsLineEdit;
|
Utils::FancyLineEdit *m_argumentsLineEdit;
|
||||||
Utils::PathChooser *m_cmakeExecutable;
|
|
||||||
QComboBox *m_generatorComboBox;
|
QComboBox *m_generatorComboBox;
|
||||||
QLabel *m_descriptionLabel;
|
QLabel *m_descriptionLabel;
|
||||||
QLabel *m_exitCodeLabel;
|
QLabel *m_exitCodeLabel;
|
||||||
|
Reference in New Issue
Block a user