DAP: Fix dap engine selection with the translated strings

Change-Id: I051c1f7e9776922a98f7c54676c237c63984050d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Artem Sokolovskii
2023-09-29 14:50:58 +02:00
parent 6cd2e6de0c
commit 9af8ecd935
2 changed files with 24 additions and 30 deletions

View File

@@ -1239,17 +1239,29 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
void DebuggerPluginPrivate::createDapDebuggerPerspective(QWidget *globalLogWindow) void DebuggerPluginPrivate::createDapDebuggerPerspective(QWidget *globalLogWindow)
{ {
EngineManager::registerDefaultPerspective(Tr::tr("CMake Preset"), struct DapPerspective
"DAP", {
Constants::DAP_PERSPECTIVE_ID); QString name;
char const *runMode;
};
EngineManager::registerDefaultPerspective(Tr::tr("GDB Preset"), const QList<DapPerspective> perspectiveList = {
"DAP", DapPerspective{Tr::tr("CMake Preset"), ProjectExplorer::Constants::DAP_CMAKE_DEBUG_RUN_MODE},
Constants::DAP_PERSPECTIVE_ID); DapPerspective{Tr::tr("GDB Preset"), ProjectExplorer::Constants::DAP_GDB_DEBUG_RUN_MODE},
DapPerspective{Tr::tr("Python Preset"),
ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE},
};
EngineManager::registerDefaultPerspective(Tr::tr("Python Preset"), for (const DapPerspective &dp : perspectiveList)
"DAP", EngineManager::registerDefaultPerspective(dp.name, "DAP", Constants::DAP_PERSPECTIVE_ID);
Constants::DAP_PERSPECTIVE_ID);
connect(&m_startDapAction, &QAction::triggered, this, [perspectiveList] {
QComboBox *combo = qobject_cast<QComboBox *>(EngineManager::dapEngineChooser());
if (perspectiveList.size() > combo->currentIndex())
ProjectExplorerPlugin::runStartupProject(perspectiveList.at(combo->currentIndex())
.runMode,
false);
});
auto breakpointManagerView = createBreakpointManagerView("DAPDebugger.BreakWindow"); auto breakpointManagerView = createBreakpointManagerView("DAPDebugger.BreakWindow");
auto breakpointManagerWindow auto breakpointManagerWindow
@@ -1265,20 +1277,6 @@ void DebuggerPluginPrivate::createDapDebuggerPerspective(QWidget *globalLogWindo
Tr::tr("DAP Debugger Perspectives"), Tr::tr("DAP Debugger Perspectives"),
"DAPDebugger.Docks.Snapshots"); "DAPDebugger.Docks.Snapshots");
connect(&m_startDapAction, &QAction::triggered, this, [] {
QComboBox *combo = qobject_cast<QComboBox *>(EngineManager::dapEngineChooser());
if (combo->currentText() == "CMake Preset") {
ProjectExplorerPlugin::runStartupProject(
ProjectExplorer::Constants::DAP_CMAKE_DEBUG_RUN_MODE, false);
} else if (combo->currentText() == "GDB Preset") {
ProjectExplorerPlugin::runStartupProject(
ProjectExplorer::Constants::DAP_GDB_DEBUG_RUN_MODE, false);
} else {
ProjectExplorerPlugin::runStartupProject(
ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE, false);
}
});
m_perspectiveDap.addToolBarAction(&m_startDapAction); m_perspectiveDap.addToolBarAction(&m_startDapAction);
m_startDapAction.setToolTip(Tr::tr("Start DAP Debugging")); m_startDapAction.setToolTip(Tr::tr("Start DAP Debugging"));
m_startDapAction.setText(Tr::tr("Start DAP Debugging")); m_startDapAction.setText(Tr::tr("Start DAP Debugging"));

View File

@@ -481,14 +481,10 @@ void DebuggerRunTool::start()
runControl()->setDisplayName(m_runParameters.displayName); runControl()->setDisplayName(m_runParameters.displayName);
m_engine = createDapEngine(runControl()->runMode());
if (!m_engine) { if (!m_engine) {
if (runControl()->runMode() == ProjectExplorer::Constants::DAP_CMAKE_DEBUG_RUN_MODE) if (m_runParameters.isCppDebugging()) {
m_engine = createDapEngine(runControl()->runMode());
else if (runControl()->runMode() == ProjectExplorer::Constants::DAP_GDB_DEBUG_RUN_MODE)
m_engine = createDapEngine(runControl()->runMode());
else if (runControl()->runMode() == ProjectExplorer::Constants::DAP_PY_DEBUG_RUN_MODE)
m_engine = createDapEngine(runControl()->runMode());
else if (m_runParameters.isCppDebugging()) {
switch (m_runParameters.cppEngineType) { switch (m_runParameters.cppEngineType) {
case GdbEngineType: case GdbEngineType:
m_engine = createGdbEngine(); m_engine = createGdbEngine();