From 3861608c63e848c6d8fe9977fc491c8ca9ddaa58 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 21 Sep 2023 17:26:35 +0200 Subject: [PATCH] AutoTest: Create sub-menu for "run test under cursor" actions No need to add all four variants to the top level of the context menu. Change-Id: Iffed7abdf06be5d6811b4dde83f27aa865627134 Reviewed-by: Christian Stenger Reviewed-by: Qt CI Bot Reviewed-by: --- src/plugins/autotest/autotestplugin.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index edfac7559a4..0f93fb7dc75 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -307,43 +307,47 @@ void AutotestPlugin::extensionsInitialized() if (!contextMenu) // if QC is started without CppEditor plugin return; - QAction *action = new QAction(Tr::tr("&Run Test Under Cursor"), this); + ActionContainer * const runTestMenu = ActionManager::createMenu("Autotest.TestUnderCursor"); + runTestMenu->menu()->setTitle(Tr::tr("Run Test Under Cursor")); + contextMenu->addSeparator(); + contextMenu->addMenu(runTestMenu); + contextMenu->addSeparator(); + + QAction *action = new QAction(Tr::tr("&Run Test"), this); action->setEnabled(false); action->setIcon(Utils::Icons::RUN_SMALL.icon()); Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_UCURSOR); connect(action, &QAction::triggered, std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Run)); - contextMenu->addSeparator(); - contextMenu->addAction(command); + runTestMenu->addAction(command); - action = new QAction(Tr::tr("Run Test Under Cursor Without Deployment"), this); + action = new QAction(Tr::tr("Run Test Without Deployment"), this); action->setEnabled(false); action->setIcon(Utils::Icons::RUN_SMALL.icon()); command = ActionManager::registerAction(action, Constants::ACTION_RUN_UCURSOR_NODEPLOY); connect(action, &QAction::triggered, std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::RunWithoutDeploy)); - contextMenu->addAction(command); + runTestMenu->addAction(command); - action = new QAction(Tr::tr("&Debug Test Under Cursor"), this); + action = new QAction(Tr::tr("&Debug Test"), this); action->setEnabled(false); action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon()); command = ActionManager::registerAction(action, Constants::ACTION_RUN_DBG_UCURSOR); connect(action, &QAction::triggered, std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Debug)); - contextMenu->addAction(command); + runTestMenu->addAction(command); - action = new QAction(Tr::tr("Debug Test Under Cursor Without Deployment"), this); + action = new QAction(Tr::tr("Debug Test Without Deployment"), this); action->setEnabled(false); action->setIcon(ProjectExplorer::Icons::DEBUG_START_SMALL.icon()); command = ActionManager::registerAction(action, Constants::ACTION_RUN_DBG_UCURSOR_NODEPLOY); connect(action, &QAction::triggered, std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::DebugWithoutDeploy)); - contextMenu->addAction(command); - contextMenu->addSeparator(); + runTestMenu->addAction(command); } ExtensionSystem::IPlugin::ShutdownFlag AutotestPlugin::aboutToShutdown()