Revise string literal usage

This commit covers src/gui folder.
PR #16757.
This commit is contained in:
Chocobo1
2022-03-29 10:41:17 +08:00
committed by GitHub
parent 746fe7ba09
commit 75c93d72be
36 changed files with 275 additions and 280 deletions

View File

@@ -188,10 +188,11 @@ void DownloadedPiecesBar::clear()
QString DownloadedPiecesBar::simpleToolTipText() const
{
const QString borderColor = colorBoxBorderColor().name();
const QString rowHTML = QString::fromLatin1("<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>");
return QLatin1String("<table cellspacing=4>")
const QString rowHTML = u"<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>"_qs;
return u"<table cellspacing=4>"
+ rowHTML.arg(backgroundColor().name(), borderColor, tr("Missing pieces"))
+ rowHTML.arg(m_dlPieceColor.name(), borderColor, tr("Partial pieces"))
+ rowHTML.arg(pieceColor().name(), borderColor, tr("Completed pieces"))
+ QLatin1String("</table>");
+ u"</table>";
}

View File

@@ -477,7 +477,7 @@ void PeerListWidget::updatePeer(const BitTorrent::Torrent *torrent, const BitTor
for (const Path &filePath : filePaths)
downloadingFiles.append(filePath.toString());
const QString downloadingFilesDisplayValue = downloadingFiles.join(u';');
setModelData(row, PeerListColumns::DOWNLOADING_PIECE, downloadingFilesDisplayValue, downloadingFilesDisplayValue, {}, downloadingFiles.join(QLatin1Char('\n')));
setModelData(row, PeerListColumns::DOWNLOADING_PIECE, downloadingFilesDisplayValue, downloadingFilesDisplayValue, {}, downloadingFiles.join(u'\n'));
if (m_resolver)
m_resolver->resolve(peerEndpoint.address.ip);

View File

@@ -168,9 +168,10 @@ void PieceAvailabilityBar::clear()
QString PieceAvailabilityBar::simpleToolTipText() const
{
const QString borderColor = colorBoxBorderColor().name();
const QString rowHTML = QString::fromLatin1("<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>");
return QLatin1String("<table cellspacing=4>")
const QString rowHTML = u"<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>"_qs;
return u"<table cellspacing=4>"
+ rowHTML.arg(backgroundColor().name(), borderColor, tr("Unavailable pieces"))
+ rowHTML.arg(pieceColor().name(), borderColor, tr("Available pieces"))
+ QLatin1String("</table>");
+ u"</table>";
}

View File

@@ -796,7 +796,7 @@ void PropertiesWidget::configure()
delete m_speedWidget;
}
const auto displayText = QString::fromLatin1("<center><b>%1</b><p>%2</p></center>")
const auto displayText = u"<center><b>%1</b><p>%2</p></center>"_qs
.arg(tr("Speed graphs are disabled"), tr("You can enable it in Advanced Options"));
auto *label = new QLabel(displayText, this);
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
@@ -812,7 +812,7 @@ void PropertiesWidget::askWebSeed()
// Ask user for a new url seed
const QString urlSeed = AutoExpandableDialog::getText(this, tr("New URL seed", "New HTTP source"),
tr("New URL seed:"), QLineEdit::Normal,
QLatin1String("http://www."), &ok);
u"http://www."_qs, &ok);
if (!ok) return;
qDebug("Adding %s web seed", qUtf8Printable(urlSeed));
if (!m_ui->listWebSeeds->findItems(urlSeed, Qt::MatchFixedString).empty())
@@ -871,7 +871,7 @@ void PropertiesWidget::editWebSeed()
if (!m_ui->listWebSeeds->findItems(newSeed, Qt::MatchFixedString).empty())
{
QMessageBox::warning(this, QLatin1String("qBittorrent"),
QMessageBox::warning(this, u"qBittorrent"_qs,
tr("This URL seed is already in the list."),
QMessageBox::Ok);
return;