Commit abedeeb9 authored by dt's avatar dt

CMakeProjec: Add "Run cmake" to Build menu and context menus

parent b2610f87
...@@ -42,6 +42,8 @@ const char * const CMAKEMIMETYPE = "text/x-cmake"; // TOOD check that this is c ...@@ -42,6 +42,8 @@ const char * const CMAKEMIMETYPE = "text/x-cmake"; // TOOD check that this is c
const char * const CMAKE_EDITOR_ID = "CMakeProject.CMakeEditor"; const char * const CMAKE_EDITOR_ID = "CMakeProject.CMakeEditor";
const char * const CMAKE_EDITOR_DISPLAY_NAME = "CMake Editor"; const char * const CMAKE_EDITOR_DISPLAY_NAME = "CMake Editor";
const char * const C_CMAKEEDITOR = "CMakeProject.Context.CMakeEditor"; const char * const C_CMAKEEDITOR = "CMakeProject.Context.CMakeEditor";
const char * const RUNCMAKE = "CMakeProject.RunCMake";
const char * const RUNCMAKECONTEXTMENU = "CMakeProject.RunCMakeContextMenu";
// Project // Project
const char * const CMAKEPROJECT_ID = "CMakeProjectManager.CMakeProject"; const char * const CMAKEPROJECT_ID = "CMakeProjectManager.CMakeProject";
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
** **
**************************************************************************/ **************************************************************************/
#include "cmakeopenprojectwizard.h"
#include "cmakeprojectmanager.h" #include "cmakeprojectmanager.h"
#include "cmakeprojectconstants.h" #include "cmakeprojectconstants.h"
#include "cmakeproject.h" #include "cmakeproject.h"
...@@ -40,7 +41,11 @@ ...@@ -40,7 +41,11 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h> #include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <qtconcurrent/QtConcurrentTools> #include <qtconcurrent/QtConcurrentTools>
#include <QtCore/QtConcurrentRun> #include <QtCore/QtConcurrentRun>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
...@@ -60,6 +65,72 @@ CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) ...@@ -60,6 +65,72 @@ CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
{ {
m_projectContext = Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT); m_projectContext = Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT);
m_projectLanguage = Core::Context(ProjectExplorer::Constants::LANG_CXX); m_projectLanguage = Core::Context(ProjectExplorer::Constants::LANG_CXX);
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)),
this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)));
Core::ActionManager *am = Core::ICore::instance()->actionManager();
Core::ActionContainer *mbuild =
am->actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
Core::ActionContainer *mproject =
am->actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
Core::ActionContainer *msubproject =
am->actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT);
m_runCMakeAction = new QAction(QIcon(), tr("Run cmake"), this);
Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, m_projectContext);
command->setAttribute(Core::Command::CA_Hide);
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_PROJECT);
connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake()));
m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run cmake"), this);
command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, m_projectContext);
command->setAttribute(Core::Command::CA_Hide);
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
connect(m_runCMakeActionContextMenu, SIGNAL(triggered()), this, SLOT(runCMakeContextMenu()));
}
void CMakeManager::updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node)
{
Q_UNUSED(node);
m_contextProject = project;
}
void CMakeManager::runCMake()
{
runCMake(ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject());
}
void CMakeManager::runCMakeContextMenu()
{
runCMake(m_contextProject);
}
void CMakeManager::runCMake(ProjectExplorer::Project *project)
{
if (!project)
return;
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(project);
if (!cmakeProject)
return;
if (!cmakeProject->activeTarget())
return;
if (!cmakeProject->activeTarget()->activeBuildConfiguration())
return;
CMakeBuildConfiguration *bc = cmakeProject->activeTarget()->activeBuildConfiguration();
CMakeOpenProjectWizard copw(this,
cmakeProject->projectDirectory(),
bc->buildDirectory(),
CMakeOpenProjectWizard::WantToUpdate,
bc->environment());
if (copw.exec() == QDialog::Accepted) {
cmakeProject->parseCMakeLists();
}
} }
Core::Context CMakeManager::projectContext() const Core::Context CMakeManager::projectContext() const
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <projectexplorer/iprojectmanager.h> #include <projectexplorer/iprojectmanager.h>
#include <coreplugin/dialogs/ioptionspage.h> #include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <coreplugin/icontext.h> #include <coreplugin/icontext.h>
#include <utils/environment.h> #include <utils/environment.h>
...@@ -44,6 +46,7 @@ ...@@ -44,6 +46,7 @@
#include <QtCore/QFuture> #include <QtCore/QFuture>
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtGui/QAction>
QT_FORWARD_DECLARE_CLASS(QProcess) QT_FORWARD_DECLARE_CLASS(QProcess)
QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QLabel)
...@@ -84,12 +87,20 @@ public: ...@@ -84,12 +87,20 @@ public:
static QString findCbpFile(const QDir &); static QString findCbpFile(const QDir &);
static QString findDumperLibrary(const Utils::Environment &env); static QString findDumperLibrary(const Utils::Environment &env);
private slots:
void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
void runCMake();
void runCMakeContextMenu();
private: private:
void runCMake(ProjectExplorer::Project *project);
static QString qtVersionForQMake(const QString &qmakePath); static QString qtVersionForQMake(const QString &qmakePath);
static QPair<QString, QString> findQtDir(const Utils::Environment &env); static QPair<QString, QString> findQtDir(const Utils::Environment &env);
Core::Context m_projectContext; Core::Context m_projectContext;
Core::Context m_projectLanguage; Core::Context m_projectLanguage;
CMakeSettingsPage *m_settingsPage; CMakeSettingsPage *m_settingsPage;
QAction *m_runCMakeAction;
QAction *m_runCMakeActionContextMenu;
ProjectExplorer::Project *m_contextProject;
}; };
struct CMakeValidator struct CMakeValidator
......
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