mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 09:55:55 +00:00
Use less operations when building strings
This commit is contained in:
parent
0fe9cd05c4
commit
49df1cd3c7
@ -402,11 +402,9 @@ void AddNewTorrentDialog::updateDiskSpaceLabel()
|
||||
}
|
||||
}
|
||||
|
||||
QString sizeString = torrentSize ? Utils::Misc::friendlyUnit(torrentSize) : QString(tr("Not Available", "This size is unavailable."));
|
||||
sizeString += " (";
|
||||
sizeString += tr("Free space on disk: %1").arg(Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(
|
||||
m_ui->savePath->selectedPath())));
|
||||
sizeString += ')';
|
||||
const QString sizeString = tr("%1 (Free space on disk: %2)").arg(
|
||||
((torrentSize > 0) ? Utils::Misc::friendlyUnit(torrentSize) : tr("Not available", "This size is unavailable."))
|
||||
, Utils::Misc::friendlyUnit(Utils::Fs::freeDiskSpaceOnPath(m_ui->savePath->selectedPath())));
|
||||
m_ui->labelSizeData->setText(sizeString);
|
||||
}
|
||||
|
||||
|
@ -1529,20 +1529,23 @@ void MainWindow::updateGUI()
|
||||
#ifndef Q_OS_MAC
|
||||
if (m_systrayIcon) {
|
||||
#ifdef Q_OS_UNIX
|
||||
QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
|
||||
html += "qBittorrent";
|
||||
html += "</div>";
|
||||
html += "<div style='vertical-align: baseline; height: 18px;'>";
|
||||
html += "<img src=':/icons/skin/download.svg' height='14'/> " + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
|
||||
html += "</div>";
|
||||
html += "<div style='vertical-align: baseline; height: 18px;'>";
|
||||
html += "<img src=':/icons/skin/seeding.svg' height='14'/> " + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
|
||||
html += "</div>";
|
||||
const QString html = QString(QLatin1String(
|
||||
"<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>"
|
||||
"qBittorrent"
|
||||
"</div>"
|
||||
"<div style='vertical-align: baseline; height: 18px;'>"
|
||||
"<img src=':/icons/skin/download.svg' height='14'/> %1"
|
||||
"</div>"
|
||||
"<div style='vertical-align: baseline; height: 18px;'>"
|
||||
"<img src=':/icons/skin/seeding.svg' height='14'/> %2"
|
||||
"</div>"))
|
||||
.arg(tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true))
|
||||
, tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)));
|
||||
#else
|
||||
// OSes such as Windows do not support html here
|
||||
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
|
||||
html += '\n';
|
||||
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
|
||||
const QString html = QString("%1\n%2").arg(
|
||||
tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true))
|
||||
, tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)));
|
||||
#endif // Q_OS_UNIX
|
||||
m_systrayIcon->setToolTip(html); // tray icon
|
||||
}
|
||||
|
@ -448,15 +448,15 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL
|
||||
auto article = m_articleListWidget->getRSSArticle(currentItem);
|
||||
Q_ASSERT(article);
|
||||
|
||||
QString html;
|
||||
html += "<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>";
|
||||
html += "<div style='background-color: #678db2; font-weight: bold; color: #fff;'>" + article->title() + "</div>";
|
||||
QString html =
|
||||
"<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>"
|
||||
"<div style='background-color: #678db2; font-weight: bold; color: #fff;'>" + article->title() + "</div>";
|
||||
if (article->date().isValid())
|
||||
html += "<div style='background-color: #efefef;'><b>" + tr("Date: ") + "</b>" + article->date().toLocalTime().toString(Qt::SystemLocaleLongDate) + "</div>";
|
||||
if (!article->author().isEmpty())
|
||||
html += "<div style='background-color: #efefef;'><b>" + tr("Author: ") + "</b>" + article->author() + "</div>";
|
||||
html += "</div>";
|
||||
html += "<div style='margin-left: 5px; margin-right: 5px;'>";
|
||||
html += "</div>"
|
||||
"<div style='margin-left: 5px; margin-right: 5px;'>";
|
||||
if (Qt::mightBeRichText(article->description())) {
|
||||
html += article->description();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user