diff options
author | hjk <hjk@qt.io> | 2024-01-30 18:16:10 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2024-02-01 06:57:41 +0000 |
commit | 6e7b83bb4acb461508d9a71ffad3c5a6e418b92b (patch) | |
tree | c464667511543f1accdc2331539a3c1bd6bcbbd6 | |
parent | aefd80094a67f032d0e7b8f2185baf74af42d390 (diff) |
CppCheck: Use ActionBuilder
Change-Id: I385427232891826641760f463da26de3777387b6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/cppcheck/cppcheckplugin.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/plugins/cppcheck/cppcheckplugin.cpp b/src/plugins/cppcheck/cppcheckplugin.cpp index 496d9af6cd..30ee2c2d67 100644 --- a/src/plugins/cppcheck/cppcheckplugin.cpp +++ b/src/plugins/cppcheck/cppcheckplugin.cpp @@ -30,6 +30,8 @@ #include <utils/qtcassert.h> #include <utils/utilsicons.h> +using namespace Core; +using namespace ProjectExplorer; using namespace Utils; namespace Cppcheck::Internal { @@ -46,7 +48,7 @@ public: CppcheckTool manualRunTool{manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID}; Utils::Perspective perspective{Constants::PERSPECTIVE_ID, ::Cppcheck::Tr::tr("Cppcheck")}; - QAction *manualRunAction; + Action *manualRunAction = nullptr; void startManualRun(); void updateManualRunAction(); @@ -130,7 +132,6 @@ void CppcheckPluginPrivate::startManualRun() void CppcheckPluginPrivate::updateManualRunAction() { - using namespace ProjectExplorer; const Project *project = ProjectManager::startupProject(); const Target *target = ProjectManager::startupTarget(); const Utils::Id cxx = ProjectExplorer::Constants::CXX_LANGUAGE_ID; @@ -148,19 +149,13 @@ class CppcheckPlugin final : public ExtensionSystem::IPlugin { d.reset(new CppcheckPluginPrivate); - using namespace Core; - ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER); + ActionBuilder(this, Constants::MANUAL_RUN_ACTION) + .setText(Tr::tr("Cppcheck...")) + .bindContextAction(&d->manualRunAction) + .addToContainer(Debugger::Constants::M_DEBUG_ANALYZER, + Debugger::Constants::G_ANALYZER_TOOLS) + .addOnTriggered(d.get(), &CppcheckPluginPrivate::startManualRun); - { - auto action = new QAction(Tr::tr("Cppcheck..."), this); - menu->addAction(ActionManager::registerAction(action, Constants::MANUAL_RUN_ACTION), - Debugger::Constants::G_ANALYZER_TOOLS); - connect(action, &QAction::triggered, - d.get(), &CppcheckPluginPrivate::startManualRun); - d->manualRunAction = action; - } - - using ProjectExplorer::ProjectExplorerPlugin; connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::runActionsUpdated, d.get(), &CppcheckPluginPrivate::updateManualRunAction); d->updateManualRunAction(); |