From 398b5656b4c17f15e107373fa8282efeaa5c6572 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 10 Jan 2023 23:54:26 +0100 Subject: [PATCH] Utils: Use multi-arg for strings Change-Id: I57d87b8f0435c7b304c484ad4d728b59780f212d Reviewed-by: hjk Reviewed-by: --- src/libs/utils/classnamevalidatinglineedit.cpp | 4 ++-- src/libs/utils/devicefileaccess.cpp | 13 ++++--------- src/libs/utils/deviceshell.cpp | 6 ++---- src/libs/utils/settingsaccessor.cpp | 10 +++++----- src/libs/utils/terminalprocess.cpp | 2 +- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/libs/utils/classnamevalidatinglineedit.cpp b/src/libs/utils/classnamevalidatinglineedit.cpp index 0fb08c277cc..f3d53259339 100644 --- a/src/libs/utils/classnamevalidatinglineedit.cpp +++ b/src/libs/utils/classnamevalidatinglineedit.cpp @@ -121,8 +121,8 @@ QString ClassNameValidatingLineEdit::fixInputString(const QString &string) void ClassNameValidatingLineEdit::updateRegExp() const { const QString pattern = "^%1(%2%1)*$"; - d->m_nameRegexp.setPattern(pattern.arg("[a-zA-Z_][a-zA-Z0-9_]*") - .arg(QRegularExpression::escape(d->m_namespaceDelimiter))); + d->m_nameRegexp.setPattern(pattern.arg(QString("[a-zA-Z_][a-zA-Z0-9_]*"), + QRegularExpression::escape(d->m_namespaceDelimiter))); } QString ClassNameValidatingLineEdit::createClassName(const QString &name) diff --git a/src/libs/utils/devicefileaccess.cpp b/src/libs/utils/devicefileaccess.cpp index ed02b444ae9..7709e6fa23e 100644 --- a/src/libs/utils/devicefileaccess.cpp +++ b/src/libs/utils/devicefileaccess.cpp @@ -478,8 +478,7 @@ expected_str DesktopDeviceFileAccess::copyFile(const FilePath &filePath, if (QFile::copy(filePath.path(), target.path())) return {}; return make_unexpected(Tr::tr("Failed to copy file \"%1\" to \"%2\".") - .arg(filePath.toUserOutput()) - .arg(target.toUserOutput())); + .arg(filePath.toUserOutput(), target.toUserOutput())); } bool DesktopDeviceFileAccess::renameFile(const FilePath &filePath, const FilePath &target) const @@ -811,9 +810,7 @@ expected_str UnixDeviceFileAccess::copyFile(const FilePath &filePath, if (result.exitCode != 0) { return make_unexpected(Tr::tr("Failed to copy file \"%1\" to \"%2\": %3") - .arg(filePath.toUserOutput()) - .arg(target.toUserOutput()) - .arg(QString::fromUtf8(result.stdErr))); + .arg(filePath.toUserOutput(), target.toUserOutput(), QString::fromUtf8(result.stdErr))); } return {}; } @@ -847,8 +844,7 @@ expected_str UnixDeviceFileAccess::fileContents(const FilePath &file if (r.exitCode != 0) return make_unexpected(Tr::tr("Failed reading file \"%1\": %2") - .arg(filePath.toUserOutput()) - .arg(QString::fromUtf8(r.stdErr))); + .arg(filePath.toUserOutput(), QString::fromUtf8(r.stdErr))); return r.stdOut; } @@ -866,8 +862,7 @@ expected_str UnixDeviceFileAccess::writeFileContents(const FilePath &fil if (result.exitCode != 0) { return make_unexpected(Tr::tr("Failed writing file \"%1\": %2") - .arg(filePath.toUserOutput()) - .arg(QString::fromUtf8(result.stdErr))); + .arg(filePath.toUserOutput(), QString::fromUtf8(result.stdErr))); } return data.size(); } diff --git a/src/libs/utils/deviceshell.cpp b/src/libs/utils/deviceshell.cpp index 221c8c22991..f349e6db568 100644 --- a/src/libs/utils/deviceshell.cpp +++ b/src/libs/utils/deviceshell.cpp @@ -109,10 +109,8 @@ RunResult DeviceShell::run(const CommandLine &cmd, const QByteArray &stdInData) const auto it = m_commandOutput.insert(id, CommandRun{{-1, {}, {}}, &waiter}); QMetaObject::invokeMethod(m_shellProcess.get(), [this, id, cmd, stdInData] { - const QString command = QString("%1 \"%2\" %3\n") - .arg(id) - .arg(QString::fromLatin1(stdInData.toBase64())) - .arg(cmd.toUserOutput()); + const QString command = QString("%1 \"%2\" %3\n").arg(id) + .arg(QString::fromLatin1(stdInData.toBase64()), cmd.toUserOutput()); qCDebug(deviceShellLog) << "Running via shell:" << command; m_shellProcess->writeRaw(command.toUtf8()); }); diff --git a/src/libs/utils/settingsaccessor.cpp b/src/libs/utils/settingsaccessor.cpp index 35a5dc5415a..3eb440eb00d 100644 --- a/src/libs/utils/settingsaccessor.cpp +++ b/src/libs/utils/settingsaccessor.cpp @@ -260,7 +260,7 @@ BackingUpSettingsAccessor::readData(const FilePath &path, QWidget *parent) const "for instance because they were written by an incompatible " "version of %2, or because a different settings path " "was used.

") - .arg(path.toUserOutput()).arg(applicationDisplayName), Issue::Type::ERROR); + .arg(path.toUserOutput(), applicationDisplayName), Issue::Type::ERROR); i.buttons.insert(QMessageBox::Ok, DiscardAndContinue); result.issue = i; } @@ -544,7 +544,7 @@ UpgradingSettingsAccessor::validateVersionRange(const RestoreData &data) const "version of %2 was used are ignored, and " "changes made now will not be propagated to " "the newer version.

") - .arg(result.path.toUserOutput()).arg(applicationDisplayName), Issue::Type::WARNING); + .arg(result.path.toUserOutput(), applicationDisplayName), Issue::Type::WARNING); i.buttons.insert(QMessageBox::Ok, Continue); result.issue = i; return result; @@ -561,7 +561,7 @@ UpgradingSettingsAccessor::validateVersionRange(const RestoreData &data) const "

Did you work with this project on another machine or " "using a different settings path before?

" "

Do you still want to load the settings file \"%2\"?

") - .arg(applicationDisplayName).arg(result.path.toUserOutput()), Issue::Type::WARNING); + .arg(applicationDisplayName, result.path.toUserOutput()), Issue::Type::WARNING); i.defaultButton = QMessageBox::No; i.escapeButton = QMessageBox::No; i.buttons.clear(); @@ -621,8 +621,8 @@ SettingsAccessor::RestoreData MergingSettingsAccessor::readData(const FilePath & QApplication::translate("Utils::SettingsAccessor", "\"%1\" is not supported by %2. " "Do you want to try loading it anyway?") - .arg(secondaryData.path.toUserOutput()) - .arg(applicationDisplayName), Issue::Type::WARNING); + .arg(secondaryData.path.toUserOutput(), applicationDisplayName), + Issue::Type::WARNING); secondaryData.issue->buttons.clear(); secondaryData.issue->buttons.insert(QMessageBox::Yes, Continue); secondaryData.issue->buttons.insert(QMessageBox::No, DiscardAndContinue); diff --git a/src/libs/utils/terminalprocess.cpp b/src/libs/utils/terminalprocess.cpp index aeda71fca95..be2cb63ed1a 100644 --- a/src/libs/utils/terminalprocess.cpp +++ b/src/libs/utils/terminalprocess.cpp @@ -399,7 +399,7 @@ void TerminalImpl::start() if (!d->m_process.waitForStarted()) { const QString msg = QtcProcess::tr("Cannot start the terminal emulator \"%1\", change the " "setting in the Environment preferences. (%2)") - .arg(terminal.command).arg(d->m_process.errorString()); + .arg(terminal.command, d->m_process.errorString()); cleanupAfterStartFailure(msg); return; }