Utils: Use multi-arg for strings

Change-Id: I57d87b8f0435c7b304c484ad4d728b59780f212d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-01-10 23:54:26 +01:00
parent ed3d75b044
commit 398b5656b4
5 changed files with 14 additions and 21 deletions

View File

@@ -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)

View File

@@ -478,8 +478,7 @@ expected_str<void> 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<void> 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<QByteArray> 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<qint64> 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();
}

View File

@@ -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());
});

View File

@@ -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.</p>")
.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 <b>not</b> be propagated to "
"the newer version.</p>")
.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
"<p>Did you work with this project on another machine or "
"using a different settings path before?</p>"
"<p>Do you still want to load the settings file \"%2\"?</p>")
.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);

View File

@@ -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;
}