Android: Simplify parsing argument details

No need to call split() for the output - instead,
just look for the index of "Common Arguments:" and the
following newline.

Change-Id: I008adeb1a8c39b0e3c0dd2364566396bf0235511
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jarek Kobus
2024-05-03 10:40:43 +02:00
parent edde770676
commit f62dea66f6

View File

@@ -275,14 +275,13 @@ OptionsDialog::OptionsDialog(AndroidSdkManager *sdkManager, const QStringList &a
m_process.setCommand({androidConfig().sdkManagerToolPath(),
{"--help", "--sdk_root=" + androidConfig().sdkLocation().toString()}});
connect(&m_process, &Process::done, this, [this] {
const QString output = m_process.allOutput();
QString argumentDetails;
bool foundTag = false;
const QStringList lines = m_process.allOutput().split('\n');
for (const QString &line : lines) {
if (foundTag)
argumentDetails.append(line + "\n");
else if (line.startsWith("Common Arguments:"))
foundTag = true;
const int tagIndex = output.indexOf("Common Arguments:");
if (tagIndex >= 0) {
const int detailsIndex = output.indexOf('\n', tagIndex);
if (detailsIndex >= 0)
argumentDetails = output.mid(detailsIndex + 1);
}
if (argumentDetails.isEmpty())
argumentDetails = Tr::tr("Cannot load available arguments for \"sdkmanager\" command.");