Skip to content

Commit

Permalink
Merge pull request #19188 from Chocobo1/literalOperator
Browse files Browse the repository at this point in the history
Rename literal operator
  • Loading branch information
Chocobo1 committed Jun 19, 2023
2 parents fc8c749 + b01a488 commit 1f2a645
Show file tree
Hide file tree
Showing 143 changed files with 3,697 additions and 3,635 deletions.
70 changes: 35 additions & 35 deletions src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ namespace
{
#define SETTINGS_KEY(name) u"Application/" name
#define FILELOGGER_SETTINGS_KEY(name) (SETTINGS_KEY(u"FileLogger/") name)
#define NOTIFICATIONS_SETTINGS_KEY(name) (SETTINGS_KEY(u"GUI/Notifications/"_qs) name)
#define NOTIFICATIONS_SETTINGS_KEY(name) (SETTINGS_KEY(u"GUI/Notifications/"_s) name)

const QString LOG_FOLDER = u"logs"_qs;
const QString LOG_FOLDER = u"logs"_s;
const QChar PARAMS_SEPARATOR = u'|';

const Path DEFAULT_PORTABLE_MODE_PROFILE_DIR {u"profile"_qs};
const Path DEFAULT_PORTABLE_MODE_PROFILE_DIR {u"profile"_s};

const int MIN_FILELOG_SIZE = 1024; // 1KiB
const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB
Expand All @@ -140,22 +140,22 @@ namespace
result.append(u"@savePath=" + addTorrentParams.savePath.data());

if (addTorrentParams.addPaused.has_value())
result.append(*addTorrentParams.addPaused ? u"@addPaused=1"_qs : u"@addPaused=0"_qs);
result.append(*addTorrentParams.addPaused ? u"@addPaused=1"_s : u"@addPaused=0"_s);

if (addTorrentParams.skipChecking)
result.append(u"@skipChecking"_qs);
result.append(u"@skipChecking"_s);

if (!addTorrentParams.category.isEmpty())
result.append(u"@category=" + addTorrentParams.category);

if (addTorrentParams.sequential)
result.append(u"@sequential"_qs);
result.append(u"@sequential"_s);

if (addTorrentParams.firstLastPiecePriority)
result.append(u"@firstLastPiecePriority"_qs);
result.append(u"@firstLastPiecePriority"_s);

if (params.skipDialog.has_value())
result.append(*params.skipDialog ? u"@skipDialog=1"_qs : u"@skipDialog=0"_qs);
result.append(*params.skipDialog ? u"@skipDialog=1"_s : u"@skipDialog=0"_s);

result += params.torrentSources;

Expand Down Expand Up @@ -225,29 +225,29 @@ namespace
Application::Application(int &argc, char **argv)
: BaseApplication(argc, argv)
, m_commandLineArgs(parseCommandLine(Application::arguments()))
, m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_qs))
, m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_qs))
, m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_qs))
, m_storeFileLoggerMaxSize(FILELOGGER_SETTINGS_KEY(u"MaxSizeBytes"_qs))
, m_storeFileLoggerAge(FILELOGGER_SETTINGS_KEY(u"Age"_qs))
, m_storeFileLoggerAgeType(FILELOGGER_SETTINGS_KEY(u"AgeType"_qs))
, m_storeFileLoggerPath(FILELOGGER_SETTINGS_KEY(u"Path"_qs))
, m_storeMemoryWorkingSetLimit(SETTINGS_KEY(u"MemoryWorkingSetLimit"_qs))
, m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_s))
, m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_s))
, m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_s))
, m_storeFileLoggerMaxSize(FILELOGGER_SETTINGS_KEY(u"MaxSizeBytes"_s))
, m_storeFileLoggerAge(FILELOGGER_SETTINGS_KEY(u"Age"_s))
, m_storeFileLoggerAgeType(FILELOGGER_SETTINGS_KEY(u"AgeType"_s))
, m_storeFileLoggerPath(FILELOGGER_SETTINGS_KEY(u"Path"_s))
, m_storeMemoryWorkingSetLimit(SETTINGS_KEY(u"MemoryWorkingSetLimit"_s))
#ifdef Q_OS_WIN
, m_processMemoryPriority(SETTINGS_KEY(u"ProcessMemoryPriority"_qs))
, m_processMemoryPriority(SETTINGS_KEY(u"ProcessMemoryPriority"_s))
#endif
#ifndef DISABLE_GUI
, m_startUpWindowState(u"GUI/StartUpWindowState"_qs)
, m_storeNotificationTorrentAdded(NOTIFICATIONS_SETTINGS_KEY(u"TorrentAdded"_qs))
, m_startUpWindowState(u"GUI/StartUpWindowState"_s)
, m_storeNotificationTorrentAdded(NOTIFICATIONS_SETTINGS_KEY(u"TorrentAdded"_s))
#endif
{
qRegisterMetaType<Log::Msg>("Log::Msg");
qRegisterMetaType<Log::Peer>("Log::Peer");

setApplicationName(u"qBittorrent"_qs);
setOrganizationDomain(u"qbittorrent.org"_qs);
setApplicationName(u"qBittorrent"_s);
setOrganizationDomain(u"qbittorrent.org"_s);
#if !defined(DISABLE_GUI)
setDesktopFileName(u"org.qbittorrent.qBittorrent"_qs);
setDesktopFileName(u"org.qbittorrent.qBittorrent"_s);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support
#endif
Expand Down Expand Up @@ -275,7 +275,7 @@ Application::Application(int &argc, char **argv)
if (!firstTimeUser)
{
if (!upgrade())
throw RuntimeError(u"Failed migration of old settings"_qs); // Not translatable. Translation isn't configured yet.
throw RuntimeError(u"Failed migration of old settings"_s); // Not translatable. Translation isn't configured yet.
handleChangedDefaults(DefaultPreferencesMode::Legacy);
}
else
Expand All @@ -296,7 +296,7 @@ Application::Application(int &argc, char **argv)
{
LogMsg(tr("Running in portable mode. Auto detected profile folder at: %1").arg(profileDir.toString()));
if (m_commandLineArgs.relativeFastresumePaths)
LogMsg(tr("Redundant command line flag detected: \"%1\". Portable mode implies relative fastresume.").arg(u"--relative-fastresume"_qs), Log::WARNING); // to avoid translating the `--relative-fastresume` string
LogMsg(tr("Redundant command line flag detected: \"%1\". Portable mode implies relative fastresume.").arg(u"--relative-fastresume"_s), Log::WARNING); // to avoid translating the `--relative-fastresume` string
}
else
{
Expand All @@ -311,7 +311,7 @@ Application::Application(int &argc, char **argv)

if (m_commandLineArgs.torrentingPort > 0) // it will be -1 when user did not set any value
{
SettingValue<int> port {u"BitTorrent/Session/Port"_qs};
SettingValue<int> port {u"BitTorrent/Session/Port"_s};
port = m_commandLineArgs.torrentingPort;
}
}
Expand Down Expand Up @@ -523,13 +523,13 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
str.replace(i, 2, torrent->contentPath().toString());
break;
case u'G':
str.replace(i, 2, torrent->tags().join(u","_qs));
str.replace(i, 2, torrent->tags().join(u","_s));
break;
case u'I':
str.replace(i, 2, (torrent->infoHash().v1().isValid() ? torrent->infoHash().v1().toString() : u"-"_qs));
str.replace(i, 2, (torrent->infoHash().v1().isValid() ? torrent->infoHash().v1().toString() : u"-"_s));
break;
case u'J':
str.replace(i, 2, (torrent->infoHash().v2().isValid() ? torrent->infoHash().v2().toString() : u"-"_qs));
str.replace(i, 2, (torrent->infoHash().v2().isValid() ? torrent->infoHash().v2().toString() : u"-"_s));
break;
case u'K':
str.replace(i, 2, torrent->id().toString());
Expand Down Expand Up @@ -792,7 +792,7 @@ try
#ifndef Q_OS_MACOS
auto *desktopIntegrationMenu = new QMenu;
auto *actionExit = new QAction(tr("E&xit"), desktopIntegrationMenu);
actionExit->setIcon(UIThemeManager::instance()->getIcon(u"application-exit"_qs));
actionExit->setIcon(UIThemeManager::instance()->getIcon(u"application-exit"_s));
actionExit->setMenuRole(QAction::QuitRole);
actionExit->setShortcut(Qt::CTRL | Qt::Key_Q);
connect(actionExit, &QAction::triggered, this, []
Expand Down Expand Up @@ -904,16 +904,16 @@ try

const Preferences *pref = Preferences::instance();

const auto scheme = pref->isWebUiHttpsEnabled() ? u"https"_qs : u"http"_qs;
const auto url = u"%1://localhost:%2\n"_qs.arg(scheme, QString::number(pref->getWebUiPort()));
const QString mesg = u"\n******** %1 ********\n"_qs.arg(tr("Information"))
const auto scheme = pref->isWebUiHttpsEnabled() ? u"https"_s : u"http"_s;
const auto url = u"%1://localhost:%2\n"_s.arg(scheme, QString::number(pref->getWebUiPort()));
const QString mesg = u"\n******** %1 ********\n"_s.arg(tr("Information"))
+ tr("To control qBittorrent, access the WebUI at: %1").arg(url);
printf("%s\n", qUtf8Printable(mesg));

if (pref->getWebUIPassword() == QByteArrayLiteral("ARQ77eY1NUZaQsuDHbIMCA==:0WMRkYTUWVT9wVvdDtHAjU9b3b7uB8NR1Gur2hmQCvCDpm39Q+PsJRJPaCU51dEiz+dTzh8qbPsL8WkFljQYFQ=="))
{
const QString warning = tr("The Web UI administrator username is: %1").arg(pref->getWebUiUsername()) + u'\n'
+ tr("The Web UI administrator password has not been changed from the default: %1").arg(u"adminadmin"_qs) + u'\n'
+ tr("The Web UI administrator password has not been changed from the default: %1").arg(u"adminadmin"_s) + u'\n'
+ tr("This is a security risk, please change your password in program preferences.") + u'\n';
printf("%s", qUtf8Printable(warning));
}
Expand Down Expand Up @@ -1165,12 +1165,12 @@ void Application::setProcessMemoryPriority(const MemoryPriority priority)
void Application::applyMemoryPriority() const
{
using SETPROCESSINFORMATION = BOOL (WINAPI *)(HANDLE, PROCESS_INFORMATION_CLASS, LPVOID, DWORD);
const auto setProcessInformation = Utils::Misc::loadWinAPI<SETPROCESSINFORMATION>(u"Kernel32.dll"_qs, "SetProcessInformation");
const auto setProcessInformation = Utils::Misc::loadWinAPI<SETPROCESSINFORMATION>(u"Kernel32.dll"_s, "SetProcessInformation");
if (!setProcessInformation) // only available on Windows >= 8
return;

using SETTHREADINFORMATION = BOOL (WINAPI *)(HANDLE, THREAD_INFORMATION_CLASS, LPVOID, DWORD);
const auto setThreadInformation = Utils::Misc::loadWinAPI<SETTHREADINFORMATION>(u"Kernel32.dll"_qs, "SetThreadInformation");
const auto setThreadInformation = Utils::Misc::loadWinAPI<SETTHREADINFORMATION>(u"Kernel32.dll"_s, "SetThreadInformation");
if (!setThreadInformation) // only available on Windows >= 8
return;

Expand Down
18 changes: 9 additions & 9 deletions src/app/cmdoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ namespace
{
QStringList parts = arg.split(u'=');
if (parts.size() == 2)
return Utils::String::unquote(parts[1], u"'\""_qs);
return Utils::String::unquote(parts[1], u"'\""_s);
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "Parameter '%1' must follow syntax '%1=%2'",
"e.g. Parameter '--webui-port' must follow syntax '--webui-port=value'")
.arg(fullParameter(), u"<value>"_qs));
.arg(fullParameter(), u"<value>"_s));
}

QString value(const QProcessEnvironment &env, const QString &defaultValue = {}) const
{
QString val = env.value(envVarName());
return val.isEmpty() ? defaultValue : Utils::String::unquote(val, u"'\""_qs);
return val.isEmpty() ? defaultValue : Utils::String::unquote(val, u"'\""_s);
}

QString usage(const QString &valueName) const
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace
{
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "Parameter '%1' must follow syntax '%1=%2'",
"e.g. Parameter '--webui-port' must follow syntax '--webui-port=<value>'")
.arg(fullParameter(), u"<integer value>"_qs));
.arg(fullParameter(), u"<integer value>"_s));
}
return res;
}
Expand Down Expand Up @@ -279,12 +279,12 @@ namespace
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "Parameter '%1' must follow syntax '%1=%2'",
"e.g. Parameter '--add-paused' must follow syntax "
"'--add-paused=<true|false>'")
.arg(fullParameter(), u"<true|false>"_qs));
.arg(fullParameter(), u"<true|false>"_s));
}

std::optional<bool> value(const QProcessEnvironment &env) const
{
const QString val = env.value(envVarName(), u"-1"_qs);
const QString val = env.value(envVarName(), u"-1"_s);

if (val.isEmpty())
{
Expand All @@ -304,7 +304,7 @@ namespace
}

qDebug() << QCoreApplication::translate("CMD Options", "Expected %1 in environment variable '%2', but got '%3'")
.arg(u"true|false"_qs, envVarName(), val);
.arg(u"true|false"_s, envVarName(), val);
return std::nullopt;
}

Expand Down Expand Up @@ -390,15 +390,15 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
result.webUiPort = WEBUI_PORT_OPTION.value(arg);
if ((result.webUiPort < 1) || (result.webUiPort > 65535))
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "%1 must specify a valid port (1 to 65535).")
.arg(u"--webui-port"_qs));
.arg(u"--webui-port"_s));
}
else if (arg == TORRENTING_PORT_OPTION)
{
result.torrentingPort = TORRENTING_PORT_OPTION.value(arg);
if ((result.torrentingPort < 1) || (result.torrentingPort > 65535))
{
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "%1 must specify a valid port (1 to 65535).")
.arg(u"--torrenting-port"_qs));
.arg(u"--torrenting-port"_s));
}
}
#ifndef DISABLE_GUI
Expand Down
4 changes: 2 additions & 2 deletions src/app/filelogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void FileLogger::changePath(const Path &newPath)

closeLogFile();

m_path = newPath / Path(u"qbittorrent.log"_qs);
m_path = newPath / Path(u"qbittorrent.log"_s);
m_logFile.setFileName(m_path.data());

Utils::Fs::mkpath(newPath);
Expand All @@ -89,7 +89,7 @@ void FileLogger::deleteOld(const int age, const FileLogAgeType ageType)
{
const QDateTime date = QDateTime::currentDateTime();
const QDir dir {m_path.parentPath().data()};
const QFileInfoList fileList = dir.entryInfoList(QStringList(u"qbittorrent.log.bak*"_qs)
const QFileInfoList fileList = dir.entryInfoList(QStringList(u"qbittorrent.log.bak*"_s)
, (QDir::Files | QDir::Writable), (QDir::Time | QDir::Reversed));

for (const QFileInfo &file : fileList)
Expand Down
16 changes: 8 additions & 8 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int main(int argc, char *argv[])
if (envValue.isEmpty())
qputenv(envName, Application::applicationDirPath().toLocal8Bit());
else
qputenv(envName, u"%1;%2"_qs.arg(envValue, Application::applicationDirPath()).toLocal8Bit());
qputenv(envName, u"%1;%2"_s.arg(envValue, Application::applicationDirPath()).toLocal8Bit());
#endif

const QBtCommandLineParameters params = app->commandLineArgs();
Expand All @@ -146,7 +146,7 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
throw CommandLineParameterError(QCoreApplication::translate("Main", "%1 must be the single command line parameter.")
.arg(u"-v (or --version)"_qs));
.arg(u"-v (or --version)"_s));
}
#endif
if (params.showHelp)
Expand All @@ -157,7 +157,7 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
throw CommandLineParameterError(QCoreApplication::translate("Main", "%1 must be the single command line parameter.")
.arg(u"-h (or --help)"_qs));
.arg(u"-h (or --help)"_s));
}

const bool firstTimeUser = !Preferences::instance()->getAcceptedLegal();
Expand Down Expand Up @@ -189,7 +189,7 @@ int main(int argc, char *argv[])
if (params.shouldDaemonize)
{
throw CommandLineParameterError(QCoreApplication::translate("Main", "You cannot use %1: qBittorrent is already running for this user.")
.arg(u"-d (or --daemon)"_qs));
.arg(u"-d (or --daemon)"_s));
}
#endif

Expand Down Expand Up @@ -276,11 +276,11 @@ int main(int argc, char *argv[])
#if !defined(DISABLE_GUI)
void showSplashScreen()
{
QPixmap splashImg(u":/icons/splash.png"_qs);
QPixmap splashImg(u":/icons/splash.png"_s);
QPainter painter(&splashImg);
const auto version = QStringLiteral(QBT_VERSION);
painter.setPen(QPen(Qt::white));
painter.setFont(QFont(u"Arial"_qs, 22, QFont::Black));
painter.setFont(QFont(u"Arial"_s, 22, QFont::Black));
painter.drawText(224 - painter.fontMetrics().horizontalAdvance(version), 270, version);
QSplashScreen *splash = new QSplashScreen(splashImg);
splash->show();
Expand Down Expand Up @@ -317,10 +317,10 @@ bool userAgreesWithLegalNotice()
Q_ASSERT(!pref->getAcceptedLegal());

#ifdef DISABLE_GUI
const QString eula = u"\n*** %1 ***\n"_qs.arg(QCoreApplication::translate("Main", "Legal Notice"))
const QString eula = u"\n*** %1 ***\n"_s.arg(QCoreApplication::translate("Main", "Legal Notice"))
+ QCoreApplication::translate("Main", "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.") + u"\n\n"
+ QCoreApplication::translate("Main", "No further notices will be issued.") + u"\n\n"
+ QCoreApplication::translate("Main", "Press %1 key to accept and continue...").arg(u"'y'"_qs) + u'\n';
+ QCoreApplication::translate("Main", "Press %1 key to accept and continue...").arg(u"'y'"_s) + u'\n';
printf("%s", qUtf8Printable(eula));

const char ret = getchar(); // Read pressed key
Expand Down
Loading

0 comments on commit 1f2a645

Please sign in to comment.