Commit 261796c3 authored by dt's avatar dt

If no cmake executable is specified or a invalid path, ask the user.

Directly in the wizard and save that to the settings. Also give feedback
if a wrong path was entered.
parent d25066f8
......@@ -261,11 +261,35 @@ void CMakeRunPage::initWidgets()
{
QFormLayout *fl = new QFormLayout;
setLayout(fl);
// Description Label
m_descriptionLabel = new QLabel(this);
m_descriptionLabel->setWordWrap(true);
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);
}
fl->addRow(new QLabel(text, this));
// Show a field for the user to enter
m_cmakeExecutable = new Core::Utils::PathChooser(this);
m_cmakeExecutable->setExpectedKind(Core::Utils::PathChooser::Command);
fl->addRow("CMake Executable", m_cmakeExecutable);
}
// Run CMake Line (with arguments)
m_argumentsLineEdit = new QLineEdit(this);
connect(m_argumentsLineEdit,SIGNAL(returnPressed()), this, SLOT(runCMake()));
......@@ -282,7 +306,7 @@ void CMakeRunPage::initWidgets()
fl->addRow(tr("Arguments"), hbox);
// Bottom output window
m_output = new QPlainTextEdit(this);
m_output->setReadOnly(true);
QSizePolicy pl = m_output->sizePolicy();
......@@ -347,9 +371,8 @@ void CMakeRunPage::initializePage()
}
}
m_generatorComboBox->clear();
// Find out whether we have multiple mvc versions
// Find out whether we have multiple msvc versions
QStringList msvcVersions = ProjectExplorer::ToolChain::availableMSVCVersions();
qDebug()<<"msvcVersions:"<<msvcVersions;
if (msvcVersions.isEmpty()) {
} else if (msvcVersions.count() == 1) {
......@@ -403,9 +426,22 @@ void CMakeRunPage::runCMake()
delete tc;
}
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator);
connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
if (m_cmakeExecutable) {
// We asked the user for the cmake executable
m_cmakeWizard->cmakeManager()->setCMakeExecutable(m_cmakeExecutable->path());
}
m_output->clear();
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator);
connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
} else {
m_runCMake->setEnabled(true);
m_argumentsLineEdit->setEnabled(true);
m_output->appendPlainText(tr("No valid cmake executable specified."));
}
}
void CMakeRunPage::cmakeReadyRead()
......
......@@ -139,6 +139,7 @@ private:
QPushButton *m_runCMake;
QProcess *m_cmakeProcess;
QLineEdit *m_argumentsLineEdit;
Core::Utils::PathChooser *m_cmakeExecutable;
QComboBox *m_generatorComboBox;
QLabel *m_descriptionLabel;
bool m_complete;
......
......@@ -39,12 +39,12 @@
#include <QtCore/QDir>
QT_FORWARD_DECLARE_CLASS(QProcess)
QT_FORWARD_DECLARE_CLASS(QLabel)
namespace CMakeProjectManager {
namespace Internal {
class CMakeSettingsPage;
class CMakeRunner;
class CMakeManager : public ProjectExplorer::IProjectManager
{
......@@ -57,7 +57,11 @@ public:
virtual ProjectExplorer::Project *openProject(const QString &fileName);
virtual QString mimeType() const;
QString cmakeExecutable() const;
bool isCMakeExecutableValid() const;
void setCMakeExecutable(const QString &executable);
QProcess* createXmlFile(const QStringList &arguments,
const QString &sourceDirectory,
......@@ -76,28 +80,6 @@ private:
CMakeSettingsPage *m_settingsPage;
};
class CMakeRunner
{
public:
CMakeRunner();
void setExecutable(const QString &executable);
QString executable() const;
QString version() const;
bool supportsQtCreator() const;
bool hasCodeBlocksMsvcGenerator() const;
private:
void run(QFutureInterface<void> &fi);
void waitForUpToDate() const;
QString m_executable;
QString m_version;
bool m_supportsQtCreator;
bool m_hasCodeBlocksMsvcGenerator;
bool m_cacheUpToDate;
mutable QFuture<void> m_future;
mutable QMutex m_mutex;
};
class CMakeSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
......@@ -114,15 +96,23 @@ public:
virtual void finish();
QString cmakeExecutable() const;
void askUserForCMakeExecutable();
void setCMakeExecutable(const QString &executable);
bool isCMakeExecutableValid();
bool hasCodeBlocksMsvcGenerator() const;
private slots:
void cmakeFinished();
private:
void updateCachedInformation() const;
void saveSettings() const;
void startProcess();
QString findCmakeExecutable() const;
void updateInfo();
mutable CMakeRunner m_cmakeRunner;
Core::Utils::PathChooser *m_pathchooser;
QString m_cmakeExecutable;
enum STATE { VALID, INVALID, RUNNING } m_state;
QProcess *m_process;
QString m_version;
bool m_hasCodeBlocksMsvcGenerator;
};
} // namespace Internal
......
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