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 <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Christian Kandeler
2023-09-21 17:26:35 +02:00
parent bd38c30759
commit 3861608c63

View File

@@ -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()