1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Construct QString more efficiently

This commit is contained in:
Chocobo1 2020-03-22 18:35:16 +08:00
parent 2c23840947
commit 7de8a4d6e0
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
25 changed files with 60 additions and 61 deletions

View File

@ -587,7 +587,7 @@ int Application::exec(const QStringList &params)
#ifndef DISABLE_WEBUI #ifndef DISABLE_WEBUI
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();
// Display some information to the user // Display some information to the user
const QString mesg = QString("\n******** %1 ********\n").arg(tr("Information")) const QString mesg = QString::fromLatin1("\n******** %1 ********\n").arg(tr("Information"))
+ tr("To control qBittorrent, access the Web UI at %1") + tr("To control qBittorrent, access the Web UI at %1")
.arg(QString("http://localhost:") + QString::number(pref->getWebUiPort())) + '\n'; .arg(QString("http://localhost:") + QString::number(pref->getWebUiPort())) + '\n';
printf("%s", qUtf8Printable(mesg)); printf("%s", qUtf8Printable(mesg));

View File

@ -364,7 +364,7 @@ QStringList QBtCommandLineParameters::paramList() const
// torrent paths or URLs. // torrent paths or URLs.
if (!savePath.isEmpty()) if (!savePath.isEmpty())
result.append(QString("@savePath=%1").arg(savePath)); result.append(QLatin1String("@savePath=") + savePath);
if (addPaused == TriStateBool::True) { if (addPaused == TriStateBool::True) {
result.append(QLatin1String("@addPaused=1")); result.append(QLatin1String("@addPaused=1"));
@ -377,7 +377,7 @@ QStringList QBtCommandLineParameters::paramList() const
result.append(QLatin1String("@skipChecking")); result.append(QLatin1String("@skipChecking"));
if (!category.isEmpty()) if (!category.isEmpty())
result.append(QString("@category=%1").arg(category)); result.append(QLatin1String("@category=") + category);
if (sequential) if (sequential)
result.append(QLatin1String("@sequential")); result.append(QLatin1String("@sequential"));

View File

@ -395,7 +395,7 @@ bool userAgreesWithLegalNotice()
Q_ASSERT(!pref->getAcceptedLegal()); Q_ASSERT(!pref->getAcceptedLegal());
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
const QString eula = QString("\n*** %1 ***\n").arg(QObject::tr("Legal Notice")) const QString eula = QString::fromLatin1("\n*** %1 ***\n").arg(QObject::tr("Legal Notice"))
+ QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.") + "\n\n" + QObject::tr("qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.") + "\n\n"
+ QObject::tr("No further notices will be issued.") + "\n\n" + QObject::tr("No further notices will be issued.") + "\n\n"
+ QObject::tr("Press %1 key to accept and continue...").arg("'y'") + '\n'; + QObject::tr("Press %1 key to accept and continue...").arg("'y'") + '\n';

View File

@ -93,8 +93,8 @@ BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVO
EnumModulesContext* context = (EnumModulesContext*)UserContext; EnumModulesContext* context = (EnumModulesContext*)UserContext;
mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
if(SymGetModuleInfo64(context->hProcess, BaseOfDll, &mod)) { if(SymGetModuleInfo64(context->hProcess, BaseOfDll, &mod)) {
QString moduleBase = QString("0x%1").arg(BaseOfDll, 16, 16, QLatin1Char('0')); QString moduleBase = QString::fromLatin1("0x%1").arg(BaseOfDll, 16, 16, QLatin1Char('0'));
QString line = QString("%1 %2 Image: %3") QString line = QString::fromLatin1("%1 %2 Image: %3")
.arg(mod.ModuleName, -25) .arg(mod.ModuleName, -25)
.arg(moduleBase, -13) .arg(moduleBase, -13)
.arg(mod.LoadedImageName); .arg(mod.LoadedImageName);
@ -102,7 +102,7 @@ BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVO
QString pdbName(mod.LoadedPdbName); QString pdbName(mod.LoadedPdbName);
if(!pdbName.isEmpty()) { if(!pdbName.isEmpty()) {
QString line2 = QString("%1 %2") QString line2 = QString::fromLatin1("%1 %2")
.arg("", 35) .arg("", 35)
.arg(pdbName); .arg(pdbName);
context->stream << line2 << '\n'; context->stream << line2 << '\n';
@ -165,7 +165,7 @@ QString straceWin::getSourcePathAndLineNumber(HANDLE hProcess, DWORD64 addr)
} }
#endif #endif
#endif #endif
return QString("%1 : %2").arg(path).arg(line.LineNumber); return QString::fromLatin1("%1 : %2").arg(path).arg(line.LineNumber);
} }
return QString(); return QString();
@ -296,7 +296,7 @@ const QString straceWin::getBacktrace()
sourceFile = getSourcePathAndLineNumber(hProcess, ihsf.InstructionOffset - 1); sourceFile = getSourcePathAndLineNumber(hProcess, ihsf.InstructionOffset - 1);
} }
else { else {
funcName = QString("0x%1").arg(ihsf.InstructionOffset, 8, 16, QLatin1Char('0')); funcName = QString::fromLatin1("0x%1").arg(ihsf.InstructionOffset, 8, 16, QLatin1Char('0'));
} }
SymSetContext(hProcess, &ihsf, NULL); SymSetContext(hProcess, &ihsf, NULL);
#ifndef __MINGW32__ #ifndef __MINGW32__
@ -304,7 +304,7 @@ const QString straceWin::getBacktrace()
SymEnumSymbols(hProcess, 0, NULL, EnumSymbolsCB, (PVOID)&params); SymEnumSymbols(hProcess, 0, NULL, EnumSymbolsCB, (PVOID)&params);
#endif #endif
QString insOffset = QString("0x%1").arg(ihsf.InstructionOffset, 16, 16, QLatin1Char('0')); QString insOffset = QString::fromLatin1("0x%1").arg(ihsf.InstructionOffset, 16, 16, QLatin1Char('0'));
QString formatLine = "#%1 %2 %3 %4"; QString formatLine = "#%1 %2 %3 %4";
#ifndef __MINGW32__ #ifndef __MINGW32__
formatLine += "(%5)"; formatLine += "(%5)";
@ -318,7 +318,7 @@ const QString straceWin::getBacktrace()
.arg(params.join(", ")); .arg(params.join(", "));
if (!sourceFile.isEmpty()) if (!sourceFile.isEmpty())
debugLine += QString("[ %1 ]").arg(sourceFile); debugLine += QString::fromLatin1("[ %1 ]").arg(sourceFile);
#else #else
; ;
#endif #endif

View File

@ -1810,7 +1810,7 @@ bool Session::deleteTorrent(const InfoHash &hash, const DeleteOption deleteOptio
// Remove it from torrent resume directory // Remove it from torrent resume directory
const QDir resumeDataDir(m_resumeFolderPath); const QDir resumeDataDir(m_resumeFolderPath);
QStringList filters; QStringList filters;
filters << QString("%1.*").arg(torrent->hash()); filters << QString::fromLatin1("%1.*").arg(torrent->hash());
const QStringList files = resumeDataDir.entryList(filters, QDir::Files, QDir::Unsorted); const QStringList files = resumeDataDir.entryList(filters, QDir::Files, QDir::Unsorted);
for (const QString &file : files) for (const QString &file : files)
Utils::Fs::forceRemove(resumeDataDir.absoluteFilePath(file)); Utils::Fs::forceRemove(resumeDataDir.absoluteFilePath(file));
@ -2457,8 +2457,8 @@ void Session::exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolde
((folder == TorrentExportFolder::Finished) && !finishedTorrentExportDirectory().isEmpty())); ((folder == TorrentExportFolder::Finished) && !finishedTorrentExportDirectory().isEmpty()));
const QString validName = Utils::Fs::toValidFileSystemName(torrent->name()); const QString validName = Utils::Fs::toValidFileSystemName(torrent->name());
const QString torrentFilename = QString("%1.torrent").arg(torrent->hash()); const QString torrentFilename = QString::fromLatin1("%1.torrent").arg(torrent->hash());
QString torrentExportFilename = QString("%1.torrent").arg(validName); QString torrentExportFilename = QString::fromLatin1("%1.torrent").arg(validName);
const QString torrentPath = QDir(m_resumeFolderPath).absoluteFilePath(torrentFilename); const QString torrentPath = QDir(m_resumeFolderPath).absoluteFilePath(torrentFilename);
const QDir exportPath(folder == TorrentExportFolder::Regular ? torrentExportDirectory() : finishedTorrentExportDirectory()); const QDir exportPath(folder == TorrentExportFolder::Regular ? torrentExportDirectory() : finishedTorrentExportDirectory());
if (exportPath.exists() || exportPath.mkpath(exportPath.absolutePath())) { if (exportPath.exists() || exportPath.mkpath(exportPath.absolutePath())) {
@ -2466,7 +2466,7 @@ void Session::exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolde
int counter = 0; int counter = 0;
while (QFile::exists(newTorrentPath) && !Utils::Fs::sameFiles(torrentPath, newTorrentPath)) { while (QFile::exists(newTorrentPath) && !Utils::Fs::sameFiles(torrentPath, newTorrentPath)) {
// Append number to torrent name to make it unique // Append number to torrent name to make it unique
torrentExportFilename = QString("%1 %2.torrent").arg(validName).arg(++counter); torrentExportFilename = QString::fromLatin1("%1 %2.torrent").arg(validName).arg(++counter);
newTorrentPath = exportPath.absoluteFilePath(torrentExportFilename); newTorrentPath = exportPath.absoluteFilePath(torrentExportFilename);
} }
@ -3923,7 +3923,7 @@ void Session::handleTorrentResumeDataReady(TorrentHandle *const torrent, const l
out.reserve(1024 * 1024); // most fastresume file sizes are under 1 MB out.reserve(1024 * 1024); // most fastresume file sizes are under 1 MB
lt::bencode(std::back_inserter(out), data); lt::bencode(std::back_inserter(out), data);
const QString filename = QString("%1.fastresume").arg(torrent->hash()); const QString filename = QString::fromLatin1("%1.fastresume").arg(torrent->hash());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QMetaObject::invokeMethod(m_resumeDataSavingManager QMetaObject::invokeMethod(m_resumeDataSavingManager
, [this, filename, out]() { m_resumeDataSavingManager->save(filename, out); }); , [this, filename, out]() { m_resumeDataSavingManager->save(filename, out); });
@ -4160,7 +4160,7 @@ void Session::startUpTorrents()
int resumedTorrentsCount = 0; int resumedTorrentsCount = 0;
const auto startupTorrent = [this, &resumeDataDir, &resumedTorrentsCount](const TorrentResumeData &params) const auto startupTorrent = [this, &resumeDataDir, &resumedTorrentsCount](const TorrentResumeData &params)
{ {
const QString filePath = resumeDataDir.filePath(QString("%1.torrent").arg(params.hash)); const QString filePath = resumeDataDir.filePath(QString::fromLatin1("%1.torrent").arg(params.hash));
qDebug() << "Starting up torrent" << params.hash << "..."; qDebug() << "Starting up torrent" << params.hash << "...";
if (!addTorrent_impl(params.addTorrentData, params.magnetUri, TorrentInfo::loadFromFile(filePath), params.data)) if (!addTorrent_impl(params.addTorrentData, params.magnetUri, TorrentInfo::loadFromFile(filePath), params.data))
LogMsg(tr("Unable to resume torrent '%1'.", "e.g: Unable to resume torrent 'hash'.") LogMsg(tr("Unable to resume torrent '%1'.", "e.g: Unable to resume torrent 'hash'.")

View File

@ -54,7 +54,7 @@ QByteArray Http::toByteArray(Response response)
// Header Fields // Header Fields
for (auto i = response.headers.constBegin(); i != response.headers.constEnd(); ++i) for (auto i = response.headers.constBegin(); i != response.headers.constEnd(); ++i)
buf += QString("%1: %2").arg(i.key(), i.value()).toLatin1().append(CRLF); buf += QString::fromLatin1("%1: %2").arg(i.key(), i.value()).toLatin1().append(CRLF);
// the first empty line // the first empty line
buf += CRLF; buf += CRLF;

View File

@ -88,7 +88,7 @@ void GeoIPManager::loadDatabase()
m_geoIPDatabase = nullptr; m_geoIPDatabase = nullptr;
const QString filepath = Utils::Fs::expandPathAbs( const QString filepath = Utils::Fs::expandPathAbs(
QString("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME)); QString::fromLatin1("%1%2/%3").arg(specialFolderLocation(SpecialFolder::Data), GEODB_FOLDER, GEODB_FILENAME));
QString error; QString error;
m_geoIPDatabase = GeoIPDatabase::load(filepath, error); m_geoIPDatabase = GeoIPDatabase::load(filepath, error);
@ -442,7 +442,7 @@ void GeoIPManager::downloadFinished(const DownloadResult &result)
specialFolderLocation(SpecialFolder::Data) + GEODB_FOLDER); specialFolderLocation(SpecialFolder::Data) + GEODB_FOLDER);
if (!QDir(targetPath).exists()) if (!QDir(targetPath).exists())
QDir().mkpath(targetPath); QDir().mkpath(targetPath);
QFile targetFile(QString("%1/%2").arg(targetPath, GEODB_FILENAME)); QFile targetFile(QString::fromLatin1("%1/%2").arg(targetPath, GEODB_FILENAME));
if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) == -1)) if (!targetFile.open(QFile::WriteOnly) || (targetFile.write(data) == -1))
LogMsg(tr("Couldn't save downloaded IP geolocation database file."), Log::WARNING); LogMsg(tr("Couldn't save downloaded IP geolocation database file."), Log::WARNING);
else else

View File

@ -139,17 +139,17 @@ void ProxyConfigurationManager::configureProxy()
if (!m_isProxyOnlyForTorrents) { if (!m_isProxyOnlyForTorrents) {
switch (m_config.type) { switch (m_config.type) {
case ProxyType::HTTP_PW: case ProxyType::HTTP_PW:
proxyStrHTTP = QString("http://%1:%2@%3:%4").arg(m_config.username proxyStrHTTP = QString::fromLatin1("http://%1:%2@%3:%4").arg(m_config.username
, m_config.password, m_config.ip, QString::number(m_config.port)); , m_config.password, m_config.ip, QString::number(m_config.port));
break; break;
case ProxyType::HTTP: case ProxyType::HTTP:
proxyStrHTTP = QString("http://%1:%2").arg(m_config.ip, QString::number(m_config.port)); proxyStrHTTP = QString::fromLatin1("http://%1:%2").arg(m_config.ip, QString::number(m_config.port));
break; break;
case ProxyType::SOCKS5: case ProxyType::SOCKS5:
proxyStrSOCK = QString("%1:%2").arg(m_config.ip, QString::number(m_config.port)); proxyStrSOCK = QString::fromLatin1("%1:%2").arg(m_config.ip, QString::number(m_config.port));
break; break;
case ProxyType::SOCKS5_PW: case ProxyType::SOCKS5_PW:
proxyStrSOCK = QString("%1:%2@%3:%4").arg(m_config.username proxyStrSOCK = QString::fromLatin1("%1:%2@%3:%4").arg(m_config.username
, m_config.password, m_config.ip, QString::number(m_config.port)); , m_config.password, m_config.ip, QString::number(m_config.port));
break; break;
default: default:

View File

@ -100,7 +100,7 @@ QPointer<AutoDownloader> AutoDownloader::m_instance = nullptr;
QString computeSmartFilterRegex(const QStringList &filters) QString computeSmartFilterRegex(const QStringList &filters)
{ {
return QString("(?:_|\\b)(?:%1)(?:_|\\b)").arg(filters.join(QString(")|(?:"))); return QString::fromLatin1("(?:_|\\b)(?:%1)(?:_|\\b)").arg(filters.join(QString(")|(?:")));
} }
AutoDownloader::AutoDownloader() AutoDownloader::AutoDownloader()

View File

@ -323,7 +323,7 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitl
} }
} }
else { // Single number else { // Single number
const QString expStr {QString("\\b(?:s0?%1[ -_\\.]?e0?%2|%1x0?%2)(?:\\D|\\b)").arg(season, episode)}; const QString expStr {QString::fromLatin1("\\b(?:s0?%1[ -_\\.]?e0?%2|%1x0?%2)(?:\\D|\\b)").arg(season, episode)};
if (cachedRegex(expStr).match(articleTitle).hasMatch()) if (cachedRegex(expStr).match(articleTitle).hasMatch())
return true; return true;
} }
@ -354,7 +354,7 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) co
if (!isRepack && !isProper) if (!isRepack && !isProper)
return false; return false;
const QString fullEpisodeStr = QString("%1%2%3").arg(episodeStr, const QString fullEpisodeStr = QString::fromLatin1("%1%2%3").arg(episodeStr,
isRepack ? "-REPACK" : "", isRepack ? "-REPACK" : "",
isProper ? "-PROPER" : ""); isProper ? "-PROPER" : "");
const bool previouslyMatchedFull = m_dataPtr->previouslyMatchedEpisodes.contains(fullEpisodeStr); const bool previouslyMatchedFull = m_dataPtr->previouslyMatchedEpisodes.contains(fullEpisodeStr);
@ -366,8 +366,8 @@ bool AutoDownloadRule::matchesSmartEpisodeFilter(const QString &articleTitle) co
// If this is a REPACK and PROPER download, add the individual entries to the list // If this is a REPACK and PROPER download, add the individual entries to the list
// so we don't download those // so we don't download those
if (isRepack && isProper) { if (isRepack && isProper) {
m_dataPtr->lastComputedEpisodes.append(QString("%1-REPACK").arg(episodeStr)); m_dataPtr->lastComputedEpisodes.append(episodeStr + QLatin1String("-REPACK"));
m_dataPtr->lastComputedEpisodes.append(QString("%1-PROPER").arg(episodeStr)); m_dataPtr->lastComputedEpisodes.append(episodeStr + QLatin1String("-PROPER"));
} }
} }

View File

@ -400,7 +400,7 @@ void Feed::downloadIcon()
// Download the RSS Feed icon // Download the RSS Feed icon
// XXX: This works for most sites but it is not perfect // XXX: This works for most sites but it is not perfect
const QUrl url(m_url); const QUrl url(m_url);
const auto iconUrl = QString("%1://%2/favicon.ico").arg(url.scheme(), url.host()); const auto iconUrl = QString::fromLatin1("%1://%2/favicon.ico").arg(url.scheme(), url.host());
Net::DownloadManager::instance()->download( Net::DownloadManager::instance()->download(
Net::DownloadRequest(iconUrl).saveToFile(true) Net::DownloadRequest(iconUrl).saveToFile(true)
, this, &Feed::handleIconDownloadFinished); , this, &Feed::handleIconDownloadFinished);

View File

@ -330,7 +330,7 @@ void Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
} }
else { else {
LogMsg(tr("Couldn't load RSS Item '%1'. Invalid data format.") LogMsg(tr("Couldn't load RSS Item '%1'. Invalid data format.")
.arg(QString("%1\\%2").arg(folder->path(), key)), Log::WARNING); .arg(QString::fromLatin1("%1\\%2").arg(folder->path(), key)), Log::WARNING);
} }
} }

View File

@ -185,7 +185,7 @@ void SearchPluginManager::enablePlugin(const QString &name, const bool enabled)
// Updates shipped plugin // Updates shipped plugin
void SearchPluginManager::updatePlugin(const QString &name) void SearchPluginManager::updatePlugin(const QString &name)
{ {
installPlugin(QString("%1%2.py").arg(m_updateUrl, name)); installPlugin(QString::fromLatin1("%1%2.py").arg(m_updateUrl, name));
} }
// Install or update plugin from file or url // Install or update plugin from file or url
@ -283,12 +283,12 @@ bool SearchPluginManager::uninstallPlugin(const QString &name)
void SearchPluginManager::updateIconPath(PluginInfo *const plugin) void SearchPluginManager::updateIconPath(PluginInfo *const plugin)
{ {
if (!plugin) return; if (!plugin) return;
QString iconPath = QString("%1/%2.png").arg(pluginsLocation(), plugin->name); QString iconPath = QString::fromLatin1("%1/%2.png").arg(pluginsLocation(), plugin->name);
if (QFile::exists(iconPath)) { if (QFile::exists(iconPath)) {
plugin->iconPath = iconPath; plugin->iconPath = iconPath;
} }
else { else {
iconPath = QString("%1/%2.ico").arg(pluginsLocation(), plugin->name); iconPath = QString::fromLatin1("%1/%2.ico").arg(pluginsLocation(), plugin->name);
if (QFile::exists(iconPath)) if (QFile::exists(iconPath))
plugin->iconPath = iconPath; plugin->iconPath = iconPath;
} }
@ -338,7 +338,7 @@ QString SearchPluginManager::pluginFullName(const QString &pluginName)
QString SearchPluginManager::pluginsLocation() QString SearchPluginManager::pluginsLocation()
{ {
return QString("%1/engines").arg(engineLocation()); return QString::fromLatin1("%1/engines").arg(engineLocation());
} }
QString SearchPluginManager::engineLocation() QString SearchPluginManager::engineLocation()
@ -526,7 +526,7 @@ bool SearchPluginManager::isUpdateNeeded(const QString &pluginName, const Plugin
QString SearchPluginManager::pluginPath(const QString &name) QString SearchPluginManager::pluginPath(const QString &name)
{ {
return QString("%1/%2.py").arg(pluginsLocation(), name); return QString::fromLatin1("%1/%2.py").arg(pluginsLocation(), name);
} }
PluginVersion SearchPluginManager::getPluginVersion(const QString &filePath) PluginVersion SearchPluginManager::getPluginVersion(const QString &filePath)

View File

@ -43,7 +43,7 @@ AboutDialog::AboutDialog(QWidget *parent)
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
// Title // Title
m_ui->labelName->setText(QString("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8)); m_ui->labelName->setText(QString::fromLatin1("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8));
m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32)); m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32));

View File

@ -333,7 +333,7 @@ void AdvancedSettings::loadAdvancedSettings()
, tr("Open documentation")) , tr("Open documentation"))
, this); , this);
labelQbtLink->setOpenExternalLinks(true); labelQbtLink->setOpenExternalLinks(true);
addRow(QBITTORRENT_HEADER, QString("<b>%1</b>").arg(tr("qBittorrent Section")), labelQbtLink); addRow(QBITTORRENT_HEADER, QString::fromLatin1("<b>%1</b>").arg(tr("qBittorrent Section")), labelQbtLink);
static_cast<QLabel *>(cellWidget(QBITTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); static_cast<QLabel *>(cellWidget(QBITTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
auto *labelLibtorrentLink = new QLabel( auto *labelLibtorrentLink = new QLabel(
@ -341,7 +341,7 @@ void AdvancedSettings::loadAdvancedSettings()
, tr("Open documentation")) , tr("Open documentation"))
, this); , this);
labelLibtorrentLink->setOpenExternalLinks(true); labelLibtorrentLink->setOpenExternalLinks(true);
addRow(LIBTORRENT_HEADER, QString("<b>%1</b>").arg(tr("libtorrent Section")), labelLibtorrentLink); addRow(LIBTORRENT_HEADER, QString::fromLatin1("<b>%1</b>").arg(tr("libtorrent Section")), labelLibtorrentLink);
static_cast<QLabel *>(cellWidget(LIBTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); static_cast<QLabel *>(cellWidget(LIBTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)

View File

@ -75,7 +75,7 @@ public:
if (!m_parent || m_parent->name().isEmpty()) if (!m_parent || m_parent->name().isEmpty())
return m_name; return m_name;
return QString("%1/%2").arg(m_parent->fullName(), m_name); return QString::fromLatin1("%1/%2").arg(m_parent->fullName(), m_name);
} }
CategoryModelItem *parent() const CategoryModelItem *parent() const

View File

@ -27,7 +27,7 @@ LineEdit::LineEdit(QWidget *parent)
m_searchButton->setStyleSheet("QToolButton {border: none; padding: 2px;}"); m_searchButton->setStyleSheet("QToolButton {border: none; padding: 2px;}");
// padding between text and widget borders // padding between text and widget borders
setStyleSheet(QString("QLineEdit {padding-left: %1px;}").arg(m_searchButton->sizeHint().width())); setStyleSheet(QString::fromLatin1("QLineEdit {padding-left: %1px;}").arg(m_searchButton->sizeHint().width()));
setClearButtonEnabled(true); setClearButtonEnabled(true);

View File

@ -1539,7 +1539,7 @@ void MainWindow::reloadSessionStats()
, tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))); , tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)));
#else #else
// OSes such as Windows do not support html here // OSes such as Windows do not support html here
const QString toolTip = QString("%1\n%2").arg( const QString toolTip = QString::fromLatin1("%1\n%2").arg(
tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true)) 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))); , tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)));
#endif // Q_OS_UNIX #endif // Q_OS_UNIX
@ -1818,7 +1818,7 @@ void MainWindow::handleUpdateCheckFinished(bool updateAvailable, QString newVers
answer = QMessageBox::question(this, tr("qBittorrent Update Available") answer = QMessageBox::question(this, tr("qBittorrent Update Available")
, tr("A new version is available.") + "<br/>" , tr("A new version is available.") + "<br/>"
+ tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>" + tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>"
+ QString("<a href=\"https://www.qbittorrent.org/news.php\">%1</a>").arg(tr("Open changelog...")) + QString::fromLatin1("<a href=\"https://www.qbittorrent.org/news.php\">%1</a>").arg(tr("Open changelog..."))
, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); , QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::Yes) { if (answer == QMessageBox::Yes) {
// The user want to update, let's download the update // The user want to update, let's download the update

View File

@ -1559,7 +1559,7 @@ void OptionsDialog::on_addScanFolderButton_clicked()
} }
if (!error.isEmpty()) if (!error.isEmpty())
QMessageBox::critical(this, tr("Adding entry failed"), QString("%1\n%2").arg(error, dir)); QMessageBox::critical(this, tr("Adding entry failed"), QString::fromLatin1("%1\n%2").arg(error, dir));
} }
} }

View File

@ -59,8 +59,8 @@ const QString EXT_LEGACY {QStringLiteral(".rssrules")};
AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
: QDialog(parent) : QDialog(parent)
, m_formatFilterJSON(QString("%1 (*%2)").arg(tr("Rules"), EXT_JSON)) , m_formatFilterJSON(QString::fromLatin1("%1 (*%2)").arg(tr("Rules"), EXT_JSON))
, m_formatFilterLegacy(QString("%1 (*%2)").arg(tr("Rules (legacy)"), EXT_LEGACY)) , m_formatFilterLegacy(QString::fromLatin1("%1 (*%2)").arg(tr("Rules (legacy)"), EXT_LEGACY))
, m_ui(new Ui::AutomatedRssDownloader) , m_ui(new Ui::AutomatedRssDownloader)
, m_currentRuleItem(nullptr) , m_currentRuleItem(nullptr)
{ {
@ -413,7 +413,7 @@ void AutomatedRssDownloader::on_exportBtn_clicked()
QString selectedFilter {m_formatFilterJSON}; QString selectedFilter {m_formatFilterJSON};
QString path = QFileDialog::getSaveFileName( QString path = QFileDialog::getSaveFileName(
this, tr("Export RSS rules"), QDir::homePath() this, tr("Export RSS rules"), QDir::homePath()
, QString("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter); , QString::fromLatin1("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter);
if (path.isEmpty()) return; if (path.isEmpty()) return;
const RSS::AutoDownloader::RulesFileFormat format { const RSS::AutoDownloader::RulesFileFormat format {
@ -445,7 +445,7 @@ void AutomatedRssDownloader::on_importBtn_clicked()
QString selectedFilter {m_formatFilterJSON}; QString selectedFilter {m_formatFilterJSON};
QString path = QFileDialog::getOpenFileName( QString path = QFileDialog::getOpenFileName(
this, tr("Import RSS rules"), QDir::homePath() this, tr("Import RSS rules"), QDir::homePath()
, QString("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter); , QString::fromLatin1("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter);
if (path.isEmpty() || !QFile::exists(path)) if (path.isEmpty() || !QFile::exists(path))
return; return;

View File

@ -113,7 +113,7 @@ void FeedListWidget::handleItemUnreadCountChanged(RSS::Item *rssItem)
else { else {
QTreeWidgetItem *item = mapRSSItem(rssItem); QTreeWidgetItem *item = mapRSSItem(rssItem);
Q_ASSERT(item); Q_ASSERT(item);
item->setData(0, Qt::DisplayRole, QString("%1 (%2)").arg(rssItem->name()).arg(rssItem->unreadCount())); item->setData(0, Qt::DisplayRole, QString::fromLatin1("%1 (%2)").arg(rssItem->name(), QString::number(rssItem->unreadCount())));
} }
} }
@ -122,7 +122,7 @@ void FeedListWidget::handleItemPathChanged(RSS::Item *rssItem)
QTreeWidgetItem *item = mapRSSItem(rssItem); QTreeWidgetItem *item = mapRSSItem(rssItem);
Q_ASSERT(item); Q_ASSERT(item);
item->setData(0, Qt::DisplayRole, QString("%1 (%2)").arg(rssItem->name()).arg(rssItem->unreadCount())); item->setData(0, Qt::DisplayRole, QString::fromLatin1("%1 (%2)").arg(rssItem->name(), QString::number(rssItem->unreadCount())));
RSS::Item *parentRssItem = RSS::Session::instance()->itemByPath(RSS::Item::parentPath(rssItem->path())); RSS::Item *parentRssItem = RSS::Session::instance()->itemByPath(RSS::Item::parentPath(rssItem->path()));
QTreeWidgetItem *parentItem = mapRSSItem(parentRssItem); QTreeWidgetItem *parentItem = mapRSSItem(parentRssItem);
@ -228,7 +228,7 @@ void FeedListWidget::dropEvent(QDropEvent *event)
QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem) QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem)
{ {
auto *item = new QTreeWidgetItem; auto *item = new QTreeWidgetItem;
item->setData(0, Qt::DisplayRole, QString("%1 (%2)").arg(rssItem->name()).arg(rssItem->unreadCount())); item->setData(0, Qt::DisplayRole, QString::fromLatin1("%1 (%2)").arg(rssItem->name(), QString::number(rssItem->unreadCount())));
item->setData(0, Qt::UserRole, reinterpret_cast<quintptr>(rssItem)); item->setData(0, Qt::UserRole, reinterpret_cast<quintptr>(rssItem));
m_rssToTreeItemMapping[rssItem] = item; m_rssToTreeItemMapping[rssItem] = item;

View File

@ -80,20 +80,19 @@ void StatsDialog::update()
: "-"); : "-");
// Cache hits // Cache hits
qreal readRatio = cs.readRatio; qreal readRatio = cs.readRatio;
m_ui->labelCacheHits->setText(QString("%1%").arg( m_ui->labelCacheHits->setText(QString::fromLatin1("%1%").arg((readRatio > 0)
readRatio > 0
? Utils::String::fromDouble(100 * readRatio, 2) ? Utils::String::fromDouble(100 * readRatio, 2)
: "0")); : QLatin1String("0")));
// Buffers size // Buffers size
m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024)); m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024));
// Disk overload (100%) equivalent // Disk overload (100%) equivalent
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read // From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
// to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are. // to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are.
m_ui->labelWriteStarve->setText(QString("%1%").arg(((ss.diskWriteQueue > 0) && (ss.peersCount > 0)) m_ui->labelWriteStarve->setText(QString::fromLatin1("%1%").arg(((ss.diskWriteQueue > 0) && (ss.peersCount > 0))
? Utils::String::fromDouble((100. * ss.diskWriteQueue / ss.peersCount), 2) ? Utils::String::fromDouble((100. * ss.diskWriteQueue / ss.peersCount), 2)
: QLatin1String("0"))); : QLatin1String("0")));
m_ui->labelReadStarve->setText(QString("%1%").arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0)) m_ui->labelReadStarve->setText(QString::fromLatin1("%1%").arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0))
? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2) ? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2)
: QLatin1String("0"))); : QLatin1String("0")));

View File

@ -319,7 +319,7 @@ QVector<TagModelItem *> TagFilterModel::findItems(const QSet<QString> &tags)
if (item) if (item)
items.push_back(item); items.push_back(item);
else else
qWarning() << QString("Requested tag '%1' missing from the model.").arg(tag); qWarning() << QString::fromLatin1("Requested tag '%1' missing from the model.").arg(tag);
} }
return items; return items;
} }

View File

@ -215,7 +215,7 @@ void TorrentCreatorDialog::handleCreationSuccess(const QString &path, const QStr
BitTorrent::Session::instance()->addTorrent(info, params); BitTorrent::Session::instance()->addTorrent(info, params);
} }
QMessageBox::information(this, tr("Torrent creator") QMessageBox::information(this, tr("Torrent creator")
, QString("%1\n%2").arg(tr("Torrent created:"), Utils::Fs::toNativePath(path))); , QString::fromLatin1("%1\n%2").arg(tr("Torrent created:"), Utils::Fs::toNativePath(path)));
setInteractionEnabled(true); setInteractionEnabled(true);
} }

View File

@ -327,7 +327,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
trackerItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon("network-server")); trackerItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon("network-server"));
const QString scheme = getScheme(tracker); const QString scheme = getScheme(tracker);
downloadFavicon(QString("%1://%2/favicon.ico").arg((scheme.startsWith("http") ? scheme : "http"), host)); downloadFavicon(QString::fromLatin1("%1://%2/favicon.ico").arg((scheme.startsWith("http") ? scheme : "http"), host));
} }
if (!trackerItem) return; if (!trackerItem) return;
@ -340,7 +340,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
return; return;
} }
trackerItem->setText(QString("%1 (%2)").arg(host).arg(tmp.size())); trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(tmp.size())));
if (exists) { if (exists) {
if (currentRow() == rowFromTracker(host)) if (currentRow() == rowFromTracker(host))
applyFilter(currentRow()); applyFilter(currentRow());
@ -384,7 +384,7 @@ void TrackerFiltersList::removeItem(const QString &tracker, const QString &hash)
return; return;
} }
if (trackerItem) if (trackerItem)
trackerItem->setText(QString("%1 (%2)").arg(host).arg(tmp.size())); trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(tmp.size())));
} }
else { else {
row = 1; row = 1;