aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
diff options
context:
space:
mode:
authordt <[email protected]>2009-01-21 16:25:21 +0100
committerdt <[email protected]>2009-01-21 16:25:21 +0100
commitdb20c44d4099ebafb053455634befec7df083099 (patch)
treeb62ebb49dd713c2f43f9eabe618a376acf120c73 /src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
parentf73861d458f62d9b1d69d934b2f451c5755b0e55 (diff)
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.
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp')
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp105
1 files changed, 104 insertions, 1 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
index 966c0144355..fb19dbdbf9b 100644
--- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp
@@ -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
+}