CMakeProjectManager: Use ActionBuilder for build file action

Previously, ActionBuilder could not handle ParameterActions.
Now it can.

Change-Id: Icfe203c63d5f84198ff88864699acba55516cb25
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2023-12-13 17:17:42 +01:00
parent aff66f9060
commit 9f342fb396

View File

@@ -39,8 +39,6 @@
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
#include <utils/parameteraction.h> #include <utils/parameteraction.h>
#include <QAction>
#include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
using namespace Core; using namespace Core;
@@ -109,18 +107,16 @@ CMakeManager::CMakeManager()
reloadCMakePresetsAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD); reloadCMakePresetsAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
reloadCMakePresetsAction.addOnTriggered(this, [this] { reloadCMakePresets(); }); reloadCMakePresetsAction.addOnTriggered(this, [this] { reloadCMakePresets(); });
m_buildFileAction = new Utils::ParameterAction(Tr::tr("Build File"), ActionBuilder buildFileAction(this, Constants::BUILD_FILE);
Tr::tr("Build File \"%1\""), buildFileAction.setParameterText(Tr::tr("Build File \"%1\""), Tr::tr("Build File"),
Utils::ParameterAction::AlwaysEnabled, ActionBuilder::AlwaysEnabled);
this); buildFileAction.bindContextAction(&m_buildFileAction);
Command *command = ActionManager::registerAction(m_buildFileAction, Constants::BUILD_FILE); buildFileAction.setCommandAttribute(Command::CA_Hide);
command->setAttribute(Command::CA_Hide); buildFileAction.setCommandAttribute(Command::CA_UpdateText);
command->setAttribute(Command::CA_UpdateText); buildFileAction.setCommandDescription(m_buildFileAction->text());
command->setDescription(m_buildFileAction->text()); buildFileAction.setDefaultKeySequence(Tr::tr("Ctrl+Alt+B"));
command->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+B"))); buildFileAction.addToContainer(PEC::M_BUILDPROJECT, PEC::G_BUILD_BUILD);
ActionContainer *mbuild = ActionManager::actionContainer(PEC::M_BUILDPROJECT); buildFileAction.addOnTriggered(this, [this] { buildFile(); });
mbuild->addAction(command, PEC::G_BUILD_BUILD);
connect(m_buildFileAction, &QAction::triggered, this, [this] { buildFile(); });
// CMake Profiler // CMake Profiler
ActionBuilder cmakeProfilerAction(this, Constants::RUN_CMAKE_PROFILER); ActionBuilder cmakeProfilerAction(this, Constants::RUN_CMAKE_PROFILER);