Lua: Add function to stop running configurations

Change-Id: I85cb9113efeb0c7b1bdd6e12eb7cabe369458dee
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Justyna Hudziak
2024-09-27 14:54:24 +02:00
parent c70e7d76f5
commit b788cf8ee5
2 changed files with 26 additions and 0 deletions

View File

@@ -113,6 +113,26 @@ void setupProjectModule()
}
};
result["stopRunConfigurationsByName"] =
[](const QString &displayName, const std::optional<bool> &force) -> int {
const auto runControls = ProjectExplorerPlugin::instance()->allRunControls();
int stoppedCount = 0;
for (const auto rc : runControls) {
if (rc && rc->displayName() == displayName) {
stoppedCount++;
if (force.has_value() && force.value()) {
rc->forceStop();
} else {
rc->initiateStop();
}
}
}
return stoppedCount;
};
result["RunMode"] = lua.create_table_with(
"Normal", Constants::NORMAL_RUN_MODE, "Debug", Constants::DEBUG_RUN_MODE);

View File

@@ -50,4 +50,10 @@ function project.canRunStartupProject(runMode) end
---@param displayName? string Override the run configuration display name with the provided name.
function project.runStartupProject(runnable, displayName) end
---Stops any configuration with display names equal to the provided name.
---@param displayName string The name for projects to stop.
---@param force? boolean Whether to close project forcefully (false assumeed if not provided).
---@return int Number of stopped configurations.
function project.stopRunConfigurationsByName(displayName, force) end
return project