CMake: Use setup functions for a few more cmake related items

Change-Id: I7a1bbea9507d7d168584348a51d557f4a910de47
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
hjk
2024-01-29 14:27:33 +01:00
parent cc64c84b5f
commit 5646aae859
7 changed files with 69 additions and 61 deletions

View File

@@ -803,12 +803,21 @@ void CMakeBuildStep::updateDeploymentData()
// CMakeBuildStepFactory
CMakeBuildStepFactory::CMakeBuildStepFactory()
class CMakeBuildStepFactory final : public BuildStepFactory
{
public:
CMakeBuildStepFactory()
{
registerStep<CMakeBuildStep>(Constants::CMAKE_BUILD_STEP_ID);
setDisplayName(Tr::tr("CMake Build", "Display name for CMakeProjectManager::CMakeBuildStep id."));
setSupportedProjectType(Constants::CMAKE_PROJECT_ID);
}
};
void setupCMakeBuildStep()
{
static CMakeBuildStepFactory theCMakeBuildStepFactory;
}
} // CMakeProjectManager::Internal

View File

@@ -118,10 +118,6 @@ private:
std::optional<QString> m_configuration;
};
class CMakeBuildStepFactory : public ProjectExplorer::BuildStepFactory
{
public:
CMakeBuildStepFactory();
};
void setupCMakeBuildStep();
} // CMakeProjectManager::Internal

View File

@@ -25,14 +25,13 @@
#include <texteditor/basehoverhandler.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <texteditor/texteditoractionhandler.h>
#include <utils/mimeconstants.h>
#include <utils/textutils.h>
#include <utils/tooltip/tooltip.h>
#include <QTextDocument>
#include <functional>
using namespace Core;
@@ -501,11 +500,12 @@ void CMakeHoverHandler::operateTooltip(TextEditorWidget *editorWidget, const QPo
setToolTip(m_helpToolTip);
}
//
// CMakeEditorFactory
//
CMakeEditorFactory::CMakeEditorFactory()
class CMakeEditorFactory final : public TextEditorFactory
{
public:
CMakeEditorFactory()
{
setId(Constants::CMAKE_EDITOR_ID);
setDisplayName(::Core::Tr::tr("CMake Editor"));
@@ -534,5 +534,11 @@ CMakeEditorFactory::CMakeEditorFactory()
contextMenu->addSeparator(Context(Constants::CMAKE_EDITOR_ID));
contextMenu->addAction(ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION));
}
};
void setupCMakeEditor()
{
static CMakeEditorFactory theCMakeEditorFactory;
}
} // CMakeProjectManager::Internal

View File

@@ -3,14 +3,8 @@
#pragma once
#include <texteditor/texteditor.h>
namespace CMakeProjectManager::Internal {
class CMakeEditorFactory : public TextEditor::TextEditorFactory
{
public:
CMakeEditorFactory();
};
void setupCMakeEditor();
} // CMakeProjectManager::Internal

View File

@@ -52,11 +52,7 @@ public:
Action::AlwaysEnabled/*handled manually*/
};
CMakeSettingsPage settingsPage;
CMakeBuildStepFactory buildStepFactory;
CMakeBuildConfigurationFactory buildConfigFactory;
CMakeEditorFactory editorFactor;
CMakeInstallStepFactory installStepFactory;
CMakeBuildTargetFilter cMakeBuildTargetFilter;
CMakeOpenTargetFilter cMakeOpenTargetFilter;
@@ -78,6 +74,11 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
{
setupCMakeToolManager(this);
setupCMakeSettingsPage();
setupCMakeBuildStep();
setupCMakeEditor();
d = new CMakeProjectPluginPrivate;
setupCMakeManager();

View File

@@ -10,6 +10,7 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/icore.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/detailswidget.h>
@@ -652,11 +653,12 @@ void CMakeToolConfigWidget::currentCMakeToolChanged(const QModelIndex &newCurren
m_makeDefButton->setEnabled(m_currentItem && (!m_model.defaultItemId().isValid() || m_currentItem->m_id != m_model.defaultItemId()));
}
//
// CMakeSettingsPage
//
CMakeSettingsPage::CMakeSettingsPage()
class CMakeSettingsPage final : public Core::IOptionsPage
{
public:
CMakeSettingsPage()
{
setId(Constants::Settings::TOOLS_ID);
setDisplayName(Tr::tr("Tools"));
@@ -664,5 +666,11 @@ CMakeSettingsPage::CMakeSettingsPage()
setCategory(Constants::Settings::CATEGORY);
setWidgetCreator([] { return new CMakeToolConfigWidget; });
}
};
void setupCMakeSettingsPage()
{
static CMakeSettingsPage theCMakeSettingsPage;
}
} // CMakeProjectManager::Internal

View File

@@ -3,14 +3,8 @@
#pragma once
#include <coreplugin/dialogs/ioptionspage.h>
namespace CMakeProjectManager::Internal {
class CMakeSettingsPage final : public Core::IOptionsPage
{
public:
CMakeSettingsPage();
};
void setupCMakeSettingsPage();
} // CMakeProjectManager::Internal