forked from qt-creator/qt-creator
CMake: Pimpl CMakeProjectPlugin and avoid use of global object pool
Follows the recent pattern. Change-Id: Ib91fb8e6ab343b5e595b9ed470daa3e55999f37c Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -51,13 +51,38 @@
|
||||
|
||||
#include <utils/parameteraction.h>
|
||||
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
using namespace Core;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeProjectPluginPrivate
|
||||
{
|
||||
public:
|
||||
Utils::ParameterAction *m_buildTargetContextAction = nullptr;
|
||||
QMetaObject::Connection m_actionConnect;
|
||||
|
||||
CMakeSettingsPage settingsPage;
|
||||
CMakeManager manager;
|
||||
CMakeBuildStepFactory buildStepFactory;
|
||||
CMakeRunConfigurationFactory runConfigFactory;
|
||||
CMakeBuildConfigurationFactory buildConfigFactory;
|
||||
CMakeEditorFactory editorFactor;
|
||||
CMakeLocatorFilter locatorFiler;
|
||||
};
|
||||
|
||||
CMakeProjectPlugin::~CMakeProjectPlugin()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
d = new CMakeProjectPluginPrivate;
|
||||
|
||||
const Context projectContext(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
||||
|
||||
Core::FileIconProvider::registerIconOverlayForSuffix(Constants::FILEOVERLAY_CMAKE, "cmake");
|
||||
@@ -65,17 +90,8 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
|
||||
TextEditor::SnippetProvider::registerGroup(Constants::CMAKE_SNIPPETS_GROUP_ID,
|
||||
tr("CMake", "SnippetProvider"));
|
||||
addAutoReleasedObject(new CMakeSettingsPage);
|
||||
addAutoReleasedObject(new CMakeManager);
|
||||
|
||||
ProjectManager::registerProjectType<CMakeProject>(Constants::CMAKEPROJECTMIMETYPE);
|
||||
|
||||
addAutoReleasedObject(new CMakeBuildStepFactory);
|
||||
addAutoReleasedObject(new CMakeRunConfigurationFactory);
|
||||
addAutoReleasedObject(new CMakeBuildConfigurationFactory);
|
||||
addAutoReleasedObject(new CMakeEditorFactory);
|
||||
addAutoReleasedObject(new CMakeLocatorFilter);
|
||||
|
||||
new CMakeToolManager(this);
|
||||
|
||||
KitManager::registerKitInformation(new CMakeKitInformation);
|
||||
@@ -89,13 +105,13 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
//register actions
|
||||
Command *command = nullptr;
|
||||
|
||||
m_buildTargetContextAction = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
|
||||
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
|
||||
this);
|
||||
command = ActionManager::registerAction(m_buildTargetContextAction, Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
|
||||
d->m_buildTargetContextAction = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""),
|
||||
Utils::ParameterAction::AlwaysEnabled/*handled manually*/,
|
||||
this);
|
||||
command = ActionManager::registerAction(d->m_buildTargetContextAction, Constants::BUILD_TARGET_CONTEXTMENU, projectContext);
|
||||
command->setAttribute(Command::CA_Hide);
|
||||
command->setAttribute(Command::CA_UpdateText);
|
||||
command->setDescription(m_buildTargetContextAction->text());
|
||||
command->setDescription(d->m_buildTargetContextAction->text());
|
||||
msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD);
|
||||
|
||||
// Wire up context menu updates:
|
||||
@@ -121,12 +137,16 @@ void CMakeProjectPlugin::updateContextActions()
|
||||
CMakeProject *cmProject = dynamic_cast<CMakeProject *>(project);
|
||||
|
||||
// Build Target:
|
||||
disconnect(m_actionConnect);
|
||||
m_buildTargetContextAction->setParameter(targetDisplayName);
|
||||
m_buildTargetContextAction->setEnabled(targetNode);
|
||||
m_buildTargetContextAction->setVisible(targetNode);
|
||||
disconnect(d->m_actionConnect);
|
||||
d->m_buildTargetContextAction->setParameter(targetDisplayName);
|
||||
d->m_buildTargetContextAction->setEnabled(targetNode);
|
||||
d->m_buildTargetContextAction->setVisible(targetNode);
|
||||
if (cmProject && targetNode) {
|
||||
m_actionConnect = connect(m_buildTargetContextAction, &Utils::ParameterAction::triggered,
|
||||
d->m_actionConnect = connect(d->m_buildTargetContextAction, &Utils::ParameterAction::triggered,
|
||||
cmProject, [cmProject, targetDisplayName]() { cmProject->buildCMakeTarget(targetDisplayName); });
|
||||
}
|
||||
}
|
||||
|
||||
} // Internal
|
||||
} // CMakeProjectManager
|
||||
|
||||
|
||||
Reference in New Issue
Block a user