forked from qt-creator/qt-creator
CppCheck: Use ActionBuilder
Change-Id: I385427232891826641760f463da26de3777387b6 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -30,6 +30,8 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Cppcheck::Internal {
|
namespace Cppcheck::Internal {
|
||||||
@@ -46,7 +48,7 @@ public:
|
|||||||
CppcheckTool manualRunTool{manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID};
|
CppcheckTool manualRunTool{manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID};
|
||||||
Utils::Perspective perspective{Constants::PERSPECTIVE_ID, ::Cppcheck::Tr::tr("Cppcheck")};
|
Utils::Perspective perspective{Constants::PERSPECTIVE_ID, ::Cppcheck::Tr::tr("Cppcheck")};
|
||||||
|
|
||||||
QAction *manualRunAction;
|
Action *manualRunAction = nullptr;
|
||||||
|
|
||||||
void startManualRun();
|
void startManualRun();
|
||||||
void updateManualRunAction();
|
void updateManualRunAction();
|
||||||
@@ -130,7 +132,6 @@ void CppcheckPluginPrivate::startManualRun()
|
|||||||
|
|
||||||
void CppcheckPluginPrivate::updateManualRunAction()
|
void CppcheckPluginPrivate::updateManualRunAction()
|
||||||
{
|
{
|
||||||
using namespace ProjectExplorer;
|
|
||||||
const Project *project = ProjectManager::startupProject();
|
const Project *project = ProjectManager::startupProject();
|
||||||
const Target *target = ProjectManager::startupTarget();
|
const Target *target = ProjectManager::startupTarget();
|
||||||
const Utils::Id cxx = ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
const Utils::Id cxx = ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
||||||
@@ -148,19 +149,13 @@ class CppcheckPlugin final : public ExtensionSystem::IPlugin
|
|||||||
{
|
{
|
||||||
d.reset(new CppcheckPluginPrivate);
|
d.reset(new CppcheckPluginPrivate);
|
||||||
|
|
||||||
using namespace Core;
|
ActionBuilder(this, Constants::MANUAL_RUN_ACTION)
|
||||||
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
|
.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,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::runActionsUpdated,
|
||||||
d.get(), &CppcheckPluginPrivate::updateManualRunAction);
|
d.get(), &CppcheckPluginPrivate::updateManualRunAction);
|
||||||
d->updateManualRunAction();
|
d->updateManualRunAction();
|
||||||
|
Reference in New Issue
Block a user