Merge pull request #16669 from Chocobo1/literal

Use QString literals
This commit is contained in:
Chocobo1
2022-03-21 12:09:43 +08:00
committed by GitHub
25 changed files with 836 additions and 828 deletions

View File

@@ -1604,7 +1604,7 @@ void MainWindow::reloadSessionStats()
}
else if (!MacUtils::badgeLabelText().isEmpty())
{
MacUtils::setBadgeLabelText("");
MacUtils::setBadgeLabelText({});
}
#else
if (m_systrayIcon)
@@ -1905,8 +1905,8 @@ void MainWindow::handleUpdateCheckFinished(ProgramUpdater *updater, const bool i
const QString newVersion = updater->getNewVersion();
if (!newVersion.isEmpty())
{
const QString msg {tr("A new version is available.") + "<br/>"
+ tr("Do you want to download %1?").arg(newVersion) + "<br/><br/>"
const QString msg {tr("A new version is available.") + u"<br/>"
+ tr("Do you want to download %1?").arg(newVersion) + u"<br/><br/>"
+ QString::fromLatin1("<a href=\"https://www.qbittorrent.org/news.php\">%1</a>").arg(tr("Open changelog..."))};
auto *msgBox = new QMessageBox {QMessageBox::Question, tr("qBittorrent Update Available"), msg
, (QMessageBox::Yes | QMessageBox::No), this};
@@ -2082,9 +2082,9 @@ void MainWindow::installPython()
setCursor(QCursor(Qt::WaitCursor));
// Download python
#ifdef QBT_APP_64BIT
const QString installerURL = "https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe";
const auto installerURL = u"https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe"_qs;
#else
const QString installerURL = "https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe";
const auto installerURL = u"https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe"_qs;
#endif
Net::DownloadManager::instance()->download(
Net::DownloadRequest(installerURL).saveToFile(true)
@@ -2109,7 +2109,7 @@ void MainWindow::pythonDownloadFinished(const Net::DownloadResult &result)
const Path exePath = result.filePath + ".exe";
Utils::Fs::renameFile(result.filePath, exePath);
installer.start(exePath.toString(), {"/passive"});
installer.start(exePath.toString(), {u"/passive"_qs});
// Wait for setup to complete
installer.waitForFinished(10 * 60 * 1000);

View File

@@ -43,6 +43,7 @@
#include <QSysInfo>
#endif
#include "base/global.h"
#include "base/net/downloadmanager.h"
#include "base/utils/version.h"
#include "base/version.h"
@@ -79,7 +80,7 @@ void ProgramUpdater::checkForUpdates() const
// Don't change this User-Agent. In case our updater goes haywire,
// the filehost can identify it and contact us.
Net::DownloadManager::instance()->download(
Net::DownloadRequest(RSS_URL).userAgent("qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)")
Net::DownloadRequest(RSS_URL).userAgent(QStringLiteral("qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)"))
, this, &ProgramUpdater::rssDownloadFinished);
}
@@ -108,11 +109,11 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
};
#ifdef Q_OS_MACOS
const QString OS_TYPE {"Mac OS X"};
const QString OS_TYPE = u"Mac OS X"_qs;
#elif defined(Q_OS_WIN)
const QString OS_TYPE {(::IsWindows7OrGreater()
&& QSysInfo::currentCpuArchitecture().endsWith("64"))
? "Windows x64" : "Windows"};
const QString OS_TYPE = (::IsWindows7OrGreater() && QSysInfo::currentCpuArchitecture().endsWith(u"64"))
? u"Windows x64"_qs
: u"Windows"_qs;
#endif
bool inItem = false;

View File

@@ -37,10 +37,12 @@
#include <QProxyStyle>
#endif
#include "base/global.h"
ProgressBarPainter::ProgressBarPainter()
{
#if (defined(Q_OS_WIN) || defined(Q_OS_MACOS))
auto *fusionStyle = new QProxyStyle {"fusion"};
auto *fusionStyle = new QProxyStyle {u"fusion"_qs};
fusionStyle->setParent(&m_dummyProgressBar);
m_dummyProgressBar.setStyle(fusionStyle);
#endif

View File

@@ -168,7 +168,7 @@ QVariant TransferListModel::headerData(int section, Qt::Orientation orientation,
{
switch (section)
{
case TR_QUEUE_POSITION: return u'#';
case TR_QUEUE_POSITION: return QChar(u'#');
case TR_NAME: return tr("Name", "i.e: torrent name");
case TR_SIZE: return tr("Size", "i.e: torrent size");
case TR_PROGRESS: return tr("Progress", "% Done");