forked from qt-creator/qt-creator
Fixes: Add a settings page to the cmake plugin.
Details: There's a linedit on there, we restore and save the settings, only thing missing is actually using it.
This commit is contained in:
@@ -105,6 +105,7 @@ public:
|
||||
CMakeStep *cmakeStep() const;
|
||||
QStringList targets() const;
|
||||
|
||||
|
||||
private:
|
||||
void parseCMakeLists(const QDir &directory);
|
||||
QString findCbpFile(const QDir &);
|
||||
|
@@ -39,16 +39,25 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/environment.h>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QFormLayout>
|
||||
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
|
||||
CMakeManager::CMakeManager()
|
||||
CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
|
||||
: m_settingsPage(cmakeSettingsPage)
|
||||
{
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
m_projectContext = core->uniqueIDManager()->uniqueIdentifier(CMakeProjectManager::Constants::PROJECTCONTEXT);
|
||||
m_projectLanguage = core->uniqueIDManager()->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX);
|
||||
}
|
||||
|
||||
CMakeSettingsPage::~CMakeSettingsPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CMakeManager::projectContext() const
|
||||
{
|
||||
return m_projectContext;
|
||||
@@ -62,6 +71,14 @@ int CMakeManager::projectLanguage() const
|
||||
ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName)
|
||||
{
|
||||
// TODO check wheter this project is already opened
|
||||
// Check that we have a cmake executable first
|
||||
// Look at the settings first
|
||||
QString cmakeExecutable = m_settingsPage->cmakeExecutable();
|
||||
if (cmakeExecutable.isNull())
|
||||
m_settingsPage->askUserForCMakeExecutable();
|
||||
cmakeExecutable = m_settingsPage->cmakeExecutable();
|
||||
if (cmakeExecutable.isNull())
|
||||
return 0;
|
||||
return new CMakeProject(this, fileName);
|
||||
}
|
||||
|
||||
@@ -69,3 +86,89 @@ QString CMakeManager::mimeType() const
|
||||
{
|
||||
return Constants::CMAKEMIMETYPE;
|
||||
}
|
||||
|
||||
/////
|
||||
// CMakeSettingsPage
|
||||
////
|
||||
|
||||
CMakeSettingsPage::CMakeSettingsPage()
|
||||
{
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
QSettings * settings = core->settings();
|
||||
settings->beginGroup("CMakeSettings");
|
||||
m_cmakeExecutable = settings->value("cmakeExecutable").toString();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::findCmakeExecutable() const
|
||||
{
|
||||
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
||||
return env.searchInPath("cmake");
|
||||
}
|
||||
|
||||
|
||||
QString CMakeSettingsPage::name() const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::category() const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::trCategory() const
|
||||
{
|
||||
return tr("CMake");
|
||||
}
|
||||
|
||||
QWidget *CMakeSettingsPage::createPage(QWidget *parent)
|
||||
{
|
||||
QWidget *w = new QWidget(parent);
|
||||
QFormLayout *fl = new QFormLayout(w);
|
||||
m_pathchooser = new Core::Utils::PathChooser(w);
|
||||
m_pathchooser->setExpectedKind(Core::Utils::PathChooser::Command);
|
||||
fl->addRow("CMake executable", m_pathchooser);
|
||||
m_pathchooser->setPath(cmakeExecutable());
|
||||
return w;
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::saveSettings() const
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("CMakeSettings");
|
||||
settings->setValue("cmakeExecutable", m_cmakeExecutable);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::apply()
|
||||
{
|
||||
m_cmakeExecutable = m_pathchooser->path();
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::finish()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::cmakeExecutable() const
|
||||
{
|
||||
if (m_cmakeExecutable.isEmpty()) {
|
||||
m_cmakeExecutable = findCmakeExecutable();
|
||||
if (!m_cmakeExecutable.isEmpty()) {
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
return m_cmakeExecutable;
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::askUserForCMakeExecutable()
|
||||
{
|
||||
// TODO implement
|
||||
// That is ideally add a label to the settings page, which says something
|
||||
// to the effect: please configure the cmake executable
|
||||
// and show the settings page
|
||||
// ensure that we rehide the label in the finish() function
|
||||
// But to test that i need an environment without cmake, e.g. windows
|
||||
}
|
||||
|
@@ -34,16 +34,20 @@
|
||||
#ifndef CMAKEPROJECTMANAGER_H
|
||||
#define CMAKEPROJECTMANAGER_H
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <projectexplorer/iprojectmanager.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeSettingsPage;
|
||||
|
||||
class CMakeManager : public ProjectExplorer::IProjectManager
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeManager();
|
||||
CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
|
||||
|
||||
virtual int projectContext() const;
|
||||
virtual int projectLanguage() const;
|
||||
@@ -55,6 +59,30 @@ public:
|
||||
private:
|
||||
int m_projectContext;
|
||||
int m_projectLanguage;
|
||||
CMakeSettingsPage *m_settingsPage;
|
||||
};
|
||||
|
||||
class CMakeSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeSettingsPage();
|
||||
virtual ~CMakeSettingsPage();
|
||||
virtual QString name() const;
|
||||
virtual QString category() const;
|
||||
virtual QString trCategory() const;
|
||||
|
||||
virtual QWidget *createPage(QWidget *parent);
|
||||
virtual void apply();
|
||||
virtual void finish();
|
||||
|
||||
QString cmakeExecutable() const;
|
||||
void askUserForCMakeExecutable();
|
||||
private:
|
||||
void saveSettings() const;
|
||||
QString findCmakeExecutable() const;
|
||||
mutable QString m_cmakeExecutable;
|
||||
Core::Utils::PathChooser *m_pathchooser;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -18,3 +18,4 @@ SOURCES = cmakeproject.cpp \
|
||||
makestep.cpp \
|
||||
cmakerunconfiguration.cpp
|
||||
RESOURCES += cmakeproject.qrc
|
||||
FORMS += cmakesettingspage.ui
|
||||
|
@@ -59,7 +59,9 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
addAutoReleasedObject(new CMakeManager());
|
||||
CMakeSettingsPage *cmp = new CMakeSettingsPage();
|
||||
addAutoReleasedObject(cmp);
|
||||
addAutoReleasedObject(new CMakeManager(cmp));
|
||||
addAutoReleasedObject(new CMakeBuildStepFactory());
|
||||
addAutoReleasedObject(new MakeBuildStepFactory());
|
||||
addAutoReleasedObject(new CMakeRunConfigurationFactory());
|
||||
|
@@ -183,10 +183,6 @@ void Environment::clear()
|
||||
m_values.clear();
|
||||
}
|
||||
|
||||
// currently it returns the string that was passed in, except
|
||||
// under windows and if the executable does not end in .exe
|
||||
// then it returns executable appended with .exe
|
||||
// that is clearly wrong
|
||||
QString Environment::searchInPath(QString executable)
|
||||
{
|
||||
// qDebug()<<"looking for "<<executable<< "in PATH: "<<m_values.value("PATH");
|
||||
|
Reference in New Issue
Block a user