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