diff options
author | Robert Griebl <robert.griebl@qt.io> | 2023-12-20 23:29:01 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2024-01-08 22:12:23 +0100 |
commit | d82261fd1cce14a63902033e9b1305f0312af856 (patch) | |
tree | 26600b8bd23a9d6d69e41ccd959fd8fe3df18cbb | |
parent | 94abcf0a5b20aea8faa51068d7d243d3b83840a6 (diff) |
Modernize string literals
Replace all our custom qSL/qL1S/qL1C macros with standard C++ and
QString unicode string literals.
Change-Id: I9e0b69fb46525421f408f260518a69b8f8125d99
Pick-to: 6.7
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
93 files changed, 1579 insertions, 1408 deletions
diff --git a/doc/resources.qdoc b/doc/resources.qdoc index 1ca36302..9e3ca1c8 100644 --- a/doc/resources.qdoc +++ b/doc/resources.qdoc @@ -111,10 +111,10 @@ If your files aren't found in the resource file system, you can list the content resource file system with the following code snippet: \code -QDirIterator it(qSL(":"), QDirIterator::Subdirectories); +QDirIterator it(u":"_s, QDirIterator::Subdirectories); while (it.hasNext()) { const QString fn = it.next(); - if (!fn.startsWith(qSL(":/qt-project.org"))) // exclude Qt internal files + if (!fn.startsWith(u":/qt-project.org"_s)) // exclude Qt internal files qDebug() << fn; } \endcode diff --git a/examples/applicationmanager/custom-appman/custom-appman.cpp b/examples/applicationmanager/custom-appman/custom-appman.cpp index 97260814..28f7a1b9 100644 --- a/examples/applicationmanager/custom-appman/custom-appman.cpp +++ b/examples/applicationmanager/custom-appman/custom-appman.cpp @@ -13,13 +13,15 @@ QT_AM_MAIN() #include <QtAppManMain/main.h> #include <QtAppManMain/configuration.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM Q_DECL_EXPORT int main(int argc, char *argv[]) { - QCoreApplication::setApplicationName(QStringLiteral("Custom Application Manager")); - QCoreApplication::setApplicationVersion(QStringLiteral("0.1")); + QCoreApplication::setApplicationName(u"Custom Application Manager"_s); + QCoreApplication::setApplicationVersion(u"0.1"_s); try { Main a(argc, argv, Main::InitFlag::ForkSudoServer | Main::InitFlag::InitializeLogging); diff --git a/src/application-lib/applicationinfo.cpp b/src/application-lib/applicationinfo.cpp index 6298bb4b..3fd479a3 100644 --- a/src/application-lib/applicationinfo.cpp +++ b/src/application-lib/applicationinfo.cpp @@ -12,6 +12,8 @@ #include <memory> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM //TODO Make this really unique @@ -119,33 +121,33 @@ QVariantMap ApplicationInfo::toVariantMap() const // ApplicationManager::get(). // This is used for RuntimeInterface::startApplication() and the ContainerInterface - map[qSL("id")] = m_id; - map[qSL("uniqueNumber")] = m_uniqueNumber; + map[u"id"_s] = m_id; + map[u"uniqueNumber"_s] = m_uniqueNumber; { QVariantMap displayName; const auto n = names(); for (auto it = n.constBegin(); it != n.constEnd(); ++it) displayName.insert(it.key(), it.value()); - map[qSL("displayName")] = displayName; + map[u"displayName"_s] = displayName; } - map[qSL("displayIcon")] = icon(); - map[qSL("applicationProperties")] = m_allAppProperties; - map[qSL("codeFilePath")] = m_codeFilePath; - map[qSL("runtimeName")] = m_runtimeName; - map[qSL("runtimeParameters")] = m_runtimeParameters; - map[qSL("capabilities")] = m_capabilities; - map[qSL("mimeTypes")] = m_supportedMimeTypes; - - map[qSL("categories")] = categories(); - map[qSL("version")] = packageInfo()->version(); - map[qSL("baseDir")] = packageInfo()->baseDir().absolutePath(); - map[qSL("codeDir")] = map[qSL("baseDir")]; // 5.12 backward compatibility - map[qSL("manifestDir")] = map[qSL("baseDir")]; // 5.12 backward compatibility - map[qSL("installationLocationId")] = packageInfo()->installationReport() ? qSL("internal-0") : QString(); - map[qSL("supportsApplicationInterface")] = m_supportsApplicationInterface; - map[qSL("dlt")] = m_dltConfiguration; + map[u"displayIcon"_s] = icon(); + map[u"applicationProperties"_s] = m_allAppProperties; + map[u"codeFilePath"_s] = m_codeFilePath; + map[u"runtimeName"_s] = m_runtimeName; + map[u"runtimeParameters"_s] = m_runtimeParameters; + map[u"capabilities"_s] = m_capabilities; + map[u"mimeTypes"_s] = m_supportedMimeTypes; + + map[u"categories"_s] = categories(); + map[u"version"_s] = packageInfo()->version(); + map[u"baseDir"_s] = packageInfo()->baseDir().absolutePath(); + map[u"codeDir"_s] = map[u"baseDir"_s]; // 5.12 backward compatibility + map[u"manifestDir"_s] = map[u"baseDir"_s]; // 5.12 backward compatibility + map[u"installationLocationId"_s] = packageInfo()->installationReport() ? u"internal-0"_s : QString(); + map[u"supportsApplicationInterface"_s] = m_supportsApplicationInterface; + map[u"dlt"_s] = m_dltConfiguration; return map; } diff --git a/src/application-lib/installationreport.cpp b/src/application-lib/installationreport.cpp index 087360cd..c9f807fe 100644 --- a/src/application-lib/installationreport.cpp +++ b/src/application-lib/installationreport.cpp @@ -18,6 +18,8 @@ #include "exception.h" #include "installationreport.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM // you can generate a new set with @@ -135,55 +137,55 @@ void InstallationReport::deserialize(QIODevice *from) m_files.clear(); auto docs = YamlParser::parseAllDocuments(from->readAll()); - checkYamlFormat(docs, 3 /*number of expected docs*/, { { qSL("am-installation-report"), 3 } }); + checkYamlFormat(docs, 3 /*number of expected docs*/, { { u"am-installation-report"_s, 3 } }); const QVariantMap &root = docs.at(1).toMap(); try { if (m_packageId.isEmpty()) { - m_packageId = root[qSL("packageId")].toString(); + m_packageId = root[u"packageId"_s].toString(); if (m_packageId.isEmpty()) throw Exception("packageId is empty"); - } else if (root[qSL("packageId")].toString() != m_packageId) { + } else if (root[u"packageId"_s].toString() != m_packageId) { throw Exception("packageId does not match: expected '%1', but got '%2'") - .arg(m_packageId).arg(root[qSL("packageId")].toString()); + .arg(m_packageId).arg(root[u"packageId"_s].toString()); } - m_diskSpaceUsed = root[qSL("diskSpaceUsed")].toULongLong(); - m_digest = QByteArray::fromHex(root[qSL("digest")].toString().toLatin1()); + m_diskSpaceUsed = root[u"diskSpaceUsed"_s].toULongLong(); + m_digest = QByteArray::fromHex(root[u"digest"_s].toString().toLatin1()); if (m_digest.isEmpty()) throw Exception("digest is empty"); - auto devSig = root.find(qSL("developerSignature")); + auto devSig = root.find(u"developerSignature"_s); if (devSig != root.end()) { m_developerSignature = QByteArray::fromBase64(devSig.value().toString().toLatin1()); if (m_developerSignature.isEmpty()) throw Exception("developerSignature is empty"); } - auto storeSig = root.find(qSL("storeSignature")); + auto storeSig = root.find(u"storeSignature"_s); if (storeSig != root.end()) { m_storeSignature = QByteArray::fromBase64(storeSig.value().toString().toLatin1()); if (m_storeSignature.isEmpty()) throw Exception("storeSignature is empty"); } - auto extra = root.find(qSL("extra")); + auto extra = root.find(u"extra"_s); if (extra != root.end()) { m_extraMetaData = extra.value().toMap(); if (m_extraMetaData.isEmpty()) throw Exception("extra metadata is empty"); } - auto extraSigned = root.find(qSL("extraSigned")); + auto extraSigned = root.find(u"extraSigned"_s); if (extraSigned != root.end()) { m_extraSignedMetaData = extraSigned.value().toMap(); if (m_extraSignedMetaData.isEmpty()) throw Exception("extraSigned metadata is empty"); } - m_files = root[qSL("files")].toStringList(); + m_files = root[u"files"_s].toStringList(); if (m_files.isEmpty()) throw Exception("No files"); // see if the file has been tampered with by checking the hmac - QByteArray hmacFile = QByteArray::fromHex(docs[2].toMap().value(qSL("hmac")).toString().toLatin1()); + QByteArray hmacFile = QByteArray::fromHex(docs[2].toMap().value(u"hmac"_s).toString().toLatin1()); QByteArray hmacKey = QByteArray::fromRawData(reinterpret_cast<const char *>(privateHmacKeyData), sizeof(privateHmacKeyData)); @@ -209,24 +211,24 @@ bool InstallationReport::serialize(QIODevice *to) const return false; QVariantMap header { - { qSL("formatVersion"), 3 }, - { qSL("formatType"), qSL("am-installation-report") } + { u"formatVersion"_s, 3 }, + { u"formatType"_s, u"am-installation-report"_s } }; QVariantMap root { - { qSL("packageId"), packageId() }, - { qSL("diskSpaceUsed"), diskSpaceUsed() }, - { qSL("digest"), QLatin1String(digest().toHex()) } + { u"packageId"_s, packageId() }, + { u"diskSpaceUsed"_s, diskSpaceUsed() }, + { u"digest"_s, QString::fromLatin1(digest().toHex()) } }; if (!m_developerSignature.isEmpty()) - root[qSL("developerSignature")] = QLatin1String(m_developerSignature.toBase64()); + root[u"developerSignature"_s] = QString::fromLatin1(m_developerSignature.toBase64()); if (!m_storeSignature.isEmpty()) - root[qSL("storeSignature")] = QLatin1String(m_storeSignature.toBase64()); + root[u"storeSignature"_s] = QString::fromLatin1(m_storeSignature.toBase64()); if (!m_extraMetaData.isEmpty()) - root[qSL("extra")] = m_extraMetaData; + root[u"extra"_s] = m_extraMetaData; if (!m_extraSignedMetaData.isEmpty()) - root[qSL("extraSigned")] = m_extraSignedMetaData; + root[u"extraSigned"_s] = m_extraSignedMetaData; - root[qSL("files")] = files(); + root[u"files"_s] = files(); QVector<QVariant> docs; docs << header; diff --git a/src/application-lib/intentinfo.cpp b/src/application-lib/intentinfo.cpp index 700f9511..e602c9f6 100644 --- a/src/application-lib/intentinfo.cpp +++ b/src/application-lib/intentinfo.cpp @@ -9,6 +9,8 @@ #include <memory> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -76,7 +78,7 @@ void IntentInfo::writeToDataStream(QDataStream &ds) const //NOTE: increment dataStreamVersion() above, if you make any changes here ds << m_id - << (m_visibility == Public ? qSL("public") : qSL("private")) + << (m_visibility == Public ? u"public"_s : u"private"_s) << m_requiredCapabilities << m_parameterMatch << m_handlingApplicationId @@ -105,7 +107,7 @@ IntentInfo *IntentInfo::readFromDataStream(PackageInfo *pkg, QDataStream &ds) >> intent->m_icon >> intent->m_handleOnlyWhenRunning; - intent->m_visibility = (visibilityStr == qSL("public")) ? Public : Private; + intent->m_visibility = (visibilityStr == u"public") ? Public : Private; intent->m_categories.sort(); return intent.release(); diff --git a/src/application-lib/packagedatabase.cpp b/src/application-lib/packagedatabase.cpp index 65ed2c9b..c2d5b945 100644 --- a/src/application-lib/packagedatabase.cpp +++ b/src/application-lib/packagedatabase.cpp @@ -18,6 +18,8 @@ #include <memory> #include <cstdlib> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM // the templated adaptor class needed to instantiate ConfigCache<PackageInfo> in parse() below @@ -106,7 +108,7 @@ QStringList PackageDatabase::findManifestsInDir(const QDir &manifestDir, bool sc for (const QString &pkgDirName : pkgDirNames) { try { // ignore left-overs from the installer - if (pkgDirName.endsWith(qL1C('+')) || pkgDirName.endsWith(qL1C('-'))) + if (pkgDirName.endsWith(u'+') || pkgDirName.endsWith(u'-')) continue; // ignore filesystem problems @@ -119,12 +121,12 @@ QStringList PackageDatabase::findManifestsInDir(const QDir &manifestDir, bool sc if (!PackageInfo::isValidApplicationId(pkgDirName, &pkgIdError)) throw Exception("not a valid package-id: %1").arg(pkgIdError); - if (!pkgDir.exists(qSL("info.yaml"))) + if (!pkgDir.exists(u"info.yaml"_s)) throw Exception("couldn't find an info.yaml manifest"); - if (!scanningBuiltInApps && !pkgDir.exists(qSL(".installation-report.yaml"))) + if (!scanningBuiltInApps && !pkgDir.exists(u".installation-report.yaml"_s)) throw Exception("found a non-built-in package without an installation report"); - QString manifestPath = pkgDir.absoluteFilePath(qSL("info.yaml")); + QString manifestPath = pkgDir.absoluteFilePath(u"info.yaml"_s); files << manifestPath; } catch (const Exception &e) { @@ -159,7 +161,7 @@ void PackageDatabase::parse(PackageLocations packageLocations) for (const QString &dir : m_builtInPackagesDirs) manifestFiles << findManifestsInDir(dir, true); - ConfigCache<PackageInfo> cache(manifestFiles, qSL("appdb-builtin"), { 'P','K','G','B' }, + ConfigCache<PackageInfo> cache(manifestFiles, u"appdb-builtin"_s, { 'P','K','G','B' }, PackageInfo::dataStreamVersion(), cacheOptions); cache.parse(); @@ -245,7 +247,7 @@ void PackageDatabase::parseInstalled() if (!m_loadFromCache && !m_saveToCache) cacheOptions |= AbstractConfigCache::NoCache; - ConfigCache<PackageInfo> cache(manifestFiles, qSL("appdb-installed"), { 'P','K','G','I' }, + ConfigCache<PackageInfo> cache(manifestFiles, u"appdb-installed"_s, { 'P','K','G','I' }, PackageInfo::dataStreamVersion(), cacheOptions); cache.parse(); @@ -268,7 +270,7 @@ void PackageDatabase::parseInstalled() .arg(pkg->id(), pkgDir.path()); } - QFile f(pkgDir.absoluteFilePath(qSL(".installation-report.yaml"))); + QFile f(pkgDir.absoluteFilePath(u".installation-report.yaml"_s)); if (!f.open(QFile::ReadOnly)) throw Exception(f, "failed to open the installation report"); diff --git a/src/application-lib/yamlpackagescanner.cpp b/src/application-lib/yamlpackagescanner.cpp index b97b76c5..2f927c82 100644 --- a/src/application-lib/yamlpackagescanner.cpp +++ b/src/application-lib/yamlpackagescanner.cpp @@ -22,6 +22,8 @@ #include <memory> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM PackageInfo *YamlPackageScanner::scan(const QString &fileName) Q_DECL_NOEXCEPT_EXPR(false) @@ -40,9 +42,9 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName bool legacy = false; try { auto header = p.parseHeader(); - if (header.first == qL1S("am-application") && header.second == 1) + if ((header.first == u"am-application") && (header.second == 1)) legacy = true; - else if (!(header.first == qL1S("am-package") && header.second == 1)) + else if (!((header.first == u"am-package") && (header.second == 1))) throw Exception("Unsupported format type and/or version"); p.nextDocument(); } catch (const Exception &e) { @@ -115,9 +117,9 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName // sanity check - could be rewritten using the "fields" mechanism static QStringList validKeys = { - qSL("desktopProfile"), - qSL("esMajorVersion"), - qSL("esMinorVersion") + u"desktopProfile"_s, + u"esMajorVersion"_s, + u"esMinorVersion"_s }; for (auto it = legacyAppInfo->m_openGLConfiguration.cbegin(); it != legacyAppInfo->m_openGLConfiguration.cend(); ++it) { @@ -129,9 +131,9 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName }); fields.emplace_back("applicationProperties", false, YamlParser::Map, [&legacyAppInfo](YamlParser *p) { const QVariantMap rawMap = p->parseMap(); - legacyAppInfo->m_sysAppProperties = rawMap.value(qSL("protected")).toMap(); + legacyAppInfo->m_sysAppProperties = rawMap.value(u"protected"_s).toMap(); legacyAppInfo->m_allAppProperties = legacyAppInfo->m_sysAppProperties; - const QVariantMap pri = rawMap.value(qSL("private")).toMap(); + const QVariantMap pri = rawMap.value(u"private"_s).toMap(); for (auto it = pri.cbegin(); it != pri.cend(); ++it) legacyAppInfo->m_allAppProperties.insert(it.key(), it.value()); }); @@ -145,13 +147,13 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName fields.emplace_back("logging", false, YamlParser::Map, [&legacyAppInfo](YamlParser *p) { const QVariantMap logging = p->parseMap(); if (!logging.isEmpty()) { - if (logging.size() > 1 || logging.firstKey() != qSL("dlt")) + if (logging.size() > 1 || logging.firstKey() != u"dlt"_s) throw YamlParserException(p, "'logging' only supports the 'dlt' key"); - legacyAppInfo->m_dltConfiguration = logging.value(qSL("dlt")).toMap(); + legacyAppInfo->m_dltConfiguration = logging.value(u"dlt"_s).toMap(); // sanity check for (auto it = legacyAppInfo->m_dltConfiguration.cbegin(); it != legacyAppInfo->m_dltConfiguration.cend(); ++it) { - if (it.key() != qSL("id") && it.key() != qSL("description")) + if (it.key() != u"id"_s && it.key() != u"description"_s) throw YamlParserException(p, "unsupported key in 'logging/dlt'"); } } @@ -216,9 +218,9 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName // sanity check - could be rewritten using the "fields" mechanism static QStringList validKeys = { - qSL("desktopProfile"), - qSL("esMajorVersion"), - qSL("esMinorVersion") + u"desktopProfile"_s, + u"esMajorVersion"_s, + u"esMinorVersion"_s }; for (auto it = appInfo->m_openGLConfiguration.cbegin(); it != appInfo->m_openGLConfiguration.cend(); ++it) { @@ -230,22 +232,22 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName }); appFields.emplace_back("applicationProperties", false, YamlParser::Map, [&appInfo](YamlParser *p) { const QVariantMap rawMap = p->parseMap(); - appInfo->m_sysAppProperties = rawMap.value(qSL("protected")).toMap(); + appInfo->m_sysAppProperties = rawMap.value(u"protected"_s).toMap(); appInfo->m_allAppProperties = appInfo->m_sysAppProperties; - const QVariantMap pri = rawMap.value(qSL("private")).toMap(); + const QVariantMap pri = rawMap.value(u"private"_s).toMap(); for (auto it = pri.cbegin(); it != pri.cend(); ++it) appInfo->m_allAppProperties.insert(it.key(), it.value()); }); appFields.emplace_back("logging", false, YamlParser::Map, [&appInfo](YamlParser *p) { const QVariantMap logging = p->parseMap(); if (!logging.isEmpty()) { - if (logging.size() > 1 || logging.firstKey() != qSL("dlt")) + if (logging.size() > 1 || logging.firstKey() != u"dlt") throw YamlParserException(p, "'logging' only supports the 'dlt' key"); - appInfo->m_dltConfiguration = logging.value(qSL("dlt")).toMap(); + appInfo->m_dltConfiguration = logging.value(u"dlt"_s).toMap(); // sanity check for (auto it = appInfo->m_dltConfiguration.cbegin(); it != appInfo->m_dltConfiguration.cend(); ++it) { - if (it.key() != qSL("id") && it.key() != qSL("description")) + if (it.key() != u"id"_s && it.key() != u"description") throw YamlParserException(p, "unsupported key in 'logging/dlt'"); } } @@ -276,9 +278,9 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName }); intentFields.emplace_back("visibility", false, YamlParser::Scalar, [&intentInfo](YamlParser *p) { const QString visibilityStr = p->parseString(); - if (visibilityStr == qL1S("private")) { + if (visibilityStr == u"private") { intentInfo->m_visibility = IntentInfo::Private; - } else if (visibilityStr != qL1S("public")) { + } else if (visibilityStr != u"public") { throw YamlParserException(p, "intent visibilty '%2' is invalid on intent %1 (valid values are either 'public' or 'private'") .arg(intentInfo->m_id).arg(visibilityStr); } @@ -346,7 +348,7 @@ PackageInfo *YamlPackageScanner::scan(QIODevice *source, const QString &fileName return pkgInfo.release(); } catch (const Exception &e) { throw Exception(e.errorCode(), "Failed to parse manifest file %1: %2") - .arg(!fileName.isEmpty() ? QDir().relativeFilePath(fileName) : qSL("<stream>"), e.errorString()); + .arg(!fileName.isEmpty() ? QDir().relativeFilePath(fileName) : u"<stream>"_s, e.errorString()); } } diff --git a/src/application-main-lib/applicationmain.cpp b/src/application-main-lib/applicationmain.cpp index e9988dc8..8640f9dc 100644 --- a/src/application-main-lib/applicationmain.cpp +++ b/src/application-main-lib/applicationmain.cpp @@ -35,6 +35,9 @@ # undef interface #endif +using namespace Qt::StringLiterals; + + AM_QML_REGISTER_TYPES(QtApplicationManager) AM_QML_REGISTER_TYPES(QtApplicationManager_Application) @@ -124,12 +127,12 @@ QString ApplicationMain::dltLongMessageBehavior() const QString ApplicationMain::p2pDBusName() const { - return qSL("am"); + return u"am"_s; } QString ApplicationMain::notificationDBusName() const { - return m_dbusAddressNotifications.isEmpty() ? QString() : qSL("am_notification_bus"); + return m_dbusAddressNotifications.isEmpty() ? QString() : u"am_notification_bus"_s; } QVariantMap ApplicationMain::openGLConfiguration() const @@ -183,27 +186,27 @@ void ApplicationMain::clearWindowPropertyCache(QWindow *window) QString ApplicationMain::applicationId() const { - return m_application.value(qSL("id")).toString(); + return m_application.value(u"id"_s).toString(); } QVariantMap ApplicationMain::applicationName() const { - return m_application.value(qSL("displayName")).toMap(); + return m_application.value(u"displayName"_s).toMap(); } QUrl ApplicationMain::applicationIcon() const { - return m_application.value(qSL("displayIcon")).toUrl(); + return m_application.value(u"displayIcon"_s).toUrl(); } QString ApplicationMain::applicationVersion() const { - return m_application.value(qSL("version")).toString(); + return m_application.value(u"version"_s).toString(); } QVariantMap ApplicationMain::applicationProperties() const { - return m_application.value(qSL("applicationProperties")).toMap(); + return m_application.value(u"applicationProperties"_s).toMap(); } QVariantMap ApplicationMain::systemProperties() const @@ -243,27 +246,27 @@ void ApplicationMain::loadConfiguration(const QByteArray &configYaml) Q_DECL_NOE "application manager: %1").arg(e.errorString()); } - m_baseDir = m_configuration.value(qSL("baseDir")).toString() + qL1C('/'); - m_runtimeConfiguration = m_configuration.value(qSL("runtimeConfiguration")).toMap(); - m_securityToken = QByteArray::fromHex(m_configuration.value(qSL("")).toString().toLatin1()); - m_systemProperties = m_configuration.value(qSL("systemProperties")).toMap(); + m_baseDir = m_configuration.value(u"baseDir"_s).toString() + u'/'; + m_runtimeConfiguration = m_configuration.value(u"runtimeConfiguration"_s).toMap(); + m_securityToken = QByteArray::fromHex(m_configuration.value(u""_s).toString().toLatin1()); + m_systemProperties = m_configuration.value(u"systemProperties"_s).toMap(); - QVariantMap loggingConfig = m_configuration.value(qSL("logging")).toMap(); - m_loggingRules = variantToStringList(loggingConfig.value(qSL("rules"))); - m_useAMConsoleLogger = loggingConfig.value(qSL("useAMConsoleLogger")); - m_dltLongMessageBehavior = loggingConfig.value(qSL("dltLongMessageBehavior")).toString(); + QVariantMap loggingConfig = m_configuration.value(u"logging"_s).toMap(); + m_loggingRules = variantToStringList(loggingConfig.value(u"rules"_s)); + m_useAMConsoleLogger = loggingConfig.value(u"useAMConsoleLogger"_s); + m_dltLongMessageBehavior = loggingConfig.value(u"dltLongMessageBehavior"_s).toString(); - QVariantMap dbusConfig = m_configuration.value(qSL("dbus")).toMap(); - m_dbusAddressP2P = dbusConfig.value(qSL("p2p")).toString(); - m_dbusAddressNotifications = dbusConfig.value(qSL("org.freedesktop.Notifications")).toString(); + QVariantMap dbusConfig = m_configuration.value(u"dbus"_s).toMap(); + m_dbusAddressP2P = dbusConfig.value(u"p2p"_s).toString(); + m_dbusAddressNotifications = dbusConfig.value(u"org.freedesktop.Notifications"_s).toString(); - QVariantMap uiConfig = m_configuration.value(qSL("ui")).toMap(); - m_slowAnimations = uiConfig.value(qSL("slowAnimations")).toBool(); - m_openGLConfiguration = uiConfig.value(qSL("opengl")).toMap(); - m_iconThemeName = uiConfig.value(qSL("iconThemeName")).toString(); - m_iconThemeSearchPaths = uiConfig.value(qSL("iconThemeSearchPaths")).toStringList(); + QVariantMap uiConfig = m_configuration.value(u"ui"_s).toMap(); + m_slowAnimations = uiConfig.value(u"slowAnimations"_s).toBool(); + m_openGLConfiguration = uiConfig.value(u"opengl"_s).toMap(); + m_iconThemeName = uiConfig.value(u"iconThemeName"_s).toString(); + m_iconThemeSearchPaths = uiConfig.value(u"iconThemeSearchPaths"_s).toStringList(); - m_application = m_configuration.value(qSL("application")).toMap(); + m_application = m_configuration.value(u"application"_s).toMap(); // un-comment this if things go south: //qWarning() << "### LOG " << m_loggingRules; @@ -275,7 +278,7 @@ void ApplicationMain::loadConfiguration(const QByteArray &configYaml) Q_DECL_NOE //qWarning() << "### APP " << m_application; // sanity checks - if (m_baseDir == qL1S("/")) + if (m_baseDir == u"/") throw Exception("Runtime launcher received an empty baseDir"); if (loggingConfig.isEmpty()) throw Exception("Runtime launcher received no logging configuration"); @@ -296,9 +299,9 @@ void ApplicationMain::setupDBusConnections() Q_DECL_NOEXCEPT_EXPR(false) qCDebug(LogRuntime) << "Connected to the P2P D-Bus via:" << m_dbusAddressP2P; if (!m_dbusAddressNotifications.isEmpty()) { - if (m_dbusAddressNotifications == qL1S("system")) + if (m_dbusAddressNotifications == u"system") dbusConnection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, notificationDBusName()); - else if (m_dbusAddressNotifications == qL1S("session")) + else if (m_dbusAddressNotifications == u"session") dbusConnection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, notificationDBusName()); else dbusConnection = QDBusConnection::connectToBus(m_dbusAddressNotifications, notificationDBusName()); @@ -348,7 +351,7 @@ static T *tryConnectToDBusInterface(const QString &service, const QString &path, void ApplicationMain::connectDBusInterfaces(bool isRuntimeLauncher) Q_DECL_NOEXCEPT_EXPR(false) { m_dbusApplicationInterface = tryConnectToDBusInterface<IoQtApplicationManagerApplicationInterfaceInterface>( - { }, qSL("/ApplicationInterface"), p2pDBusName(), this); + { }, u"/ApplicationInterface"_s, p2pDBusName(), this); if (!m_dbusApplicationInterface) throw Exception("could not connect to the ApplicationInterface on the P2P D-Bus"); @@ -377,7 +380,7 @@ void ApplicationMain::connectDBusInterfaces(bool isRuntimeLauncher) Q_DECL_NOEXC if (isRuntimeLauncher) { m_dbusRuntimeInterface = tryConnectToDBusInterface<IoQtApplicationManagerRuntimeInterfaceInterface>( - { }, qSL("/RuntimeInterface"), p2pDBusName(), this); + { }, u"/RuntimeInterface"_s, p2pDBusName(), this); if (!m_dbusRuntimeInterface) throw Exception("could not connect to the RuntimeInterface on the P2P D-Bus"); @@ -396,7 +399,7 @@ void ApplicationMain::connectDBusInterfaces(bool isRuntimeLauncher) Q_DECL_NOEXC if (!m_dbusAddressNotifications.isEmpty()) { m_dbusNotificationInterface = tryConnectToDBusInterface<OrgFreedesktopNotificationsInterface>( - qSL("org.freedesktop.Notifications"), qSL("/org/freedesktop/Notifications"), + u"org.freedesktop.Notifications"_s, u"/org/freedesktop/Notifications"_s, notificationDBusName(), this); if (m_dbusNotificationInterface) { @@ -442,7 +445,7 @@ void ApplicationMain::connectDBusInterfaces(bool isRuntimeLauncher) Q_DECL_NOEXC if (!IntentClient::createInstance(intentClientDBusInterface)) throw Exception("could not connect to the IntentInterface on the P2P D-Bus"); - m_dbusApplicationInterface->asyncCall(qSL("finishedInitialization")); + m_dbusApplicationInterface->asyncCall(u"finishedInitialization"_s); } uint QtAM::ApplicationMain::showNotification(Notification *notification) diff --git a/src/application-main-lib/intentclientdbusimplementation.cpp b/src/application-main-lib/intentclientdbusimplementation.cpp index 655c2580..e97e927b 100644 --- a/src/application-main-lib/intentclientdbusimplementation.cpp +++ b/src/application-main-lib/intentclientdbusimplementation.cpp @@ -18,6 +18,8 @@ #include "intentinterface_interface.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM IntentClientDBusImplementation::IntentClientDBusImplementation(const QString &dbusName, QObject *parent) @@ -36,7 +38,7 @@ void IntentClientDBusImplementation::initialize(IntentClient *intentClient) Q_DE IntentClientSystemInterface::initialize(intentClient); m_dbusInterface = new IoQtApplicationManagerIntentInterfaceInterface( - QString(), qSL("/IntentServer"), QDBusConnection(m_dbusName), intentClient); + QString(), u"/IntentServer"_s, QDBusConnection(m_dbusName), intentClient); if (!m_dbusInterface->isValid()) throw std::logic_error("Could not connect to the /IntentServer object on the P2P D-Bus"); @@ -54,9 +56,9 @@ void IntentClientDBusImplementation::initialize(IntentClient *intentClient) Q_DE // "version 2" DBus interface, we simply append the string "@broadcast" to the requestId // for broadcasts. - bool isBroadcast = requestId.endsWith(qSL("@broadcast")); + bool isBroadcast = requestId.endsWith(u"@broadcast"_s); QUuid requestIdUuid = QUuid::fromString(isBroadcast ? requestId.chopped(10) : requestId); - QString requestingApplicationId = isBroadcast ? qSL(":broadcast:") : QString(); + QString requestingApplicationId = isBroadcast ? u":broadcast:"_s : QString(); emit requestToApplication(requestIdUuid, id, requestingApplicationId, applicationId, convertFromDBusVariant(parameters).toMap()); diff --git a/src/common-lib/architecture.cpp b/src/common-lib/architecture.cpp index 19db40fa..8f8b3291 100644 --- a/src/common-lib/architecture.cpp +++ b/src/common-lib/architecture.cpp @@ -7,6 +7,8 @@ #include "architecture.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -33,8 +35,8 @@ QString Architecture::identify(const QString &fileName) QString cpu; switch (cpuId & ~0x01000000u) { - case 0x07: cpu = qSL("x86"); break; - case 0x0c: cpu = qSL("arm"); break; + case 0x07: cpu = u"x86"_s; break; + case 0x0c: cpu = u"arm"_s; break; } if (!cpu.isEmpty()) return cpu + u'_' + QString::number(bits); @@ -58,14 +60,14 @@ QString Architecture::identify(const QString &fileName) QString cpu; switch (qFromLittleEndian<quint16>(peHeader.constData() + 4)) { - case 0x014c: bits = 32; cpu = qSL("x86"); break; - case 0x8664: bits = 64; cpu = qSL("x86"); break; - case 0xaa64: bits = 64; cpu = qSL("arm"); break; + case 0x014c: bits = 32; cpu = u"x86"_s; break; + case 0x8664: bits = 64; cpu = u"x86"_s; break; + case 0xaa64: bits = 64; cpu = u"arm"_s; break; } if (!cpu.isEmpty()) - arch = qSL("windows_") + cpu + u'_' + QString::number(bits); + arch = u"windows_"_s + cpu + u'_' + QString::number(bits); else - arch = qSL("windows_unknown"); + arch = u"windows_unknown"_s; } } } @@ -76,7 +78,7 @@ QString Architecture::identify(const QString &fileName) const int endianness = (elfHeader[5 /*EI_DATA*/] == 2) ? Q_BIG_ENDIAN : Q_LITTLE_ENDIAN; if ((elfHeader[6 /*EI_VERSION*/] == 1) && ((elfHeader[7 /*EI_OSABI*/] == 0) || (elfHeader[7 /*EI_OSABI*/] == 3))) { - QString os = qSL("linux"); + QString os = u"linux"_s; auto elfValue = [endianness, bits](const QByteArray &data, qsizetype baseOff, qsizetype size32, qsizetype off32, @@ -116,7 +118,7 @@ QString Architecture::identify(const QString &fileName) if ((type == 0x07 /*SHT_NOTE*/) && (name < strings.size()) && QByteArray(strings.constData() + name).startsWith(".note.android")) { - os = qSL("android"); + os = u"android"_s; break; } } @@ -129,16 +131,16 @@ QString Architecture::identify(const QString &fileName) switch (elfValue(elfHeader, 0, 2, 0x12, 2, 0x12)) { case 0x03: - case 0x3e: cpu = qSL("x86"); break; + case 0x3e: cpu = u"x86"_s; break; case 0x28: - case 0xb7: cpu = qSL("arm"); break; + case 0xb7: cpu = u"arm"_s; break; } if (!cpu.isEmpty()) arch = os + u'_' + cpu + u'_' + QString::number(bits); else - arch = os + qSL("_unknown"); + arch = os + u"_unknown"_s; if (endianness == Q_BIG_ENDIAN) - arch = arch + qSL("_be"); + arch = arch + u"_be"_s; } } } else if (magic == machoMagic) { @@ -146,9 +148,9 @@ QString Architecture::identify(const QString &fileName) if (machoHeader.size() == 8) { const quint32 cpuId = qFromLittleEndian<quint32>(machoHeader.constData() + 4); if (const QString s = machoCpuAndBits(cpuId); !s.isEmpty()) - arch = qSL("macos_") + s; + arch = u"macos_"_s + s; else - arch = qSL("macos_unknown"); + arch = u"macos_unknown"_s; } } else if (magic == machoUniversalMagic) { const QByteArray machoUniversalHeader = f.read(8); @@ -167,9 +169,9 @@ QString Architecture::identify(const QString &fileName) } if (!cpuAndBits.isEmpty()) { cpuAndBits.sort(); - arch = qSL("macos_universal_") + cpuAndBits.join(u'+'); + arch = u"macos_universal_"_s + cpuAndBits.join(u'+'); } else { - arch = qSL("macos_universal_unknown"); + arch = u"macos_universal_unknown"_s; } } } diff --git a/src/common-lib/configcache.cpp b/src/common-lib/configcache.cpp index 6d28d467..fe9bc40e 100644 --- a/src/common-lib/configcache.cpp +++ b/src/common-lib/configcache.cpp @@ -17,6 +17,8 @@ #include "exception.h" #include "logging.h" +using namespace Qt::StringLiterals; + // use QtConcurrent to parse the files, if there are more than x files constexpr int AM_PARALLEL_THRESHOLD = 1; @@ -148,7 +150,7 @@ void AbstractConfigCache::parse() qCDebug(LogCache) << d->cacheBaseName << "cache file:" << cacheFile.fileName(); qCDebug(LogCache) << d->cacheBaseName << "read cache:" << ((d->options & (ClearCache | NoCache)) ? "no" : "yes") << "/ write cache:" << ((d->options & NoCache) ? "no" : "yes"); - qCDebug(LogCache) << d->cacheBaseName << "reading:" << qPrintable(rawFilePaths.join(qSL(", "))); + qCDebug(LogCache) << d->cacheBaseName << "reading:" << qPrintable(rawFilePaths.join(u", "_s)); if (!d->options.testFlag(NoCache) && !d->options.testFlag(ClearCache)) { if (cacheFile.open(QFile::ReadOnly)) { @@ -409,8 +411,8 @@ QString AbstractConfigCache::cacheFilePath() const // find the correct cache location and make sure it exists static const QDir dir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)); if (!dir.exists()) - dir.mkpath(qSL(".")); - return dir.absoluteFilePath(qSL("appman-%1.cache").arg(d->cacheBaseName)); + dir.mkpath(u"."_s); + return dir.absoluteFilePath(u"appman-%1.cache"_s.arg(d->cacheBaseName)); } QT_END_NAMESPACE_AM diff --git a/src/common-lib/console.cpp b/src/common-lib/console.cpp index 6f70fb7c..b4c208a0 100644 --- a/src/common-lib/console.cpp +++ b/src/common-lib/console.cpp @@ -27,6 +27,9 @@ Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char* str); # include "unixsignalhandler.h" #endif +using namespace Qt::StringLiterals; + + struct ConsoleGlobal { bool stdoutSupportsAnsiColor = false; @@ -94,9 +97,8 @@ ConsoleGlobal::ConsoleGlobal() break; #if defined(Q_OS_LINUX) - static QString checkCreator = qSL("/proc/%1/exe"); - QFileInfo fi(checkCreator.arg(pid)); - if (fi.symLinkTarget().contains(qSL("qtcreator"))) { + QFileInfo fi(u"/proc/%1/exe"_s.arg(pid)); + if (fi.symLinkTarget().contains(u"qtcreator")) { isRunningInQtCreator = true; break; } @@ -113,7 +115,7 @@ ConsoleGlobal::ConsoleGlobal() wchar_t exeName[1024] = { 0 }; DWORD exeNameSize = sizeof(exeName) - 1; if (QueryFullProcessImageNameW(hProcess, 0, exeName, &exeNameSize)) { - if (QString::fromWCharArray(exeName, exeNameSize).contains(qSL("qtcreator"))) { + if (QString::fromWCharArray(exeName, exeNameSize).contains(u"qtcreator"_s)) { isRunningInQtCreator = true; break; } diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp index 84b32d16..ed02208a 100644 --- a/src/common-lib/crashhandler.cpp +++ b/src/common-lib/crashhandler.cpp @@ -42,6 +42,8 @@ # endif #endif +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -84,13 +86,13 @@ Q_GLOBAL_STATIC(CrashHandlerGlobal, chg); void CrashHandler::setCrashActionConfiguration(const QVariantMap &config) { - chg()->printBacktrace = config.value(qSL("printBacktrace"), chg()->printBacktrace).toBool(); - chg()->printQmlStack = config.value(qSL("printQmlStack"), chg()->printQmlStack).toBool(); - chg()->waitForGdbAttach = config.value(qSL("waitForGdbAttach"), chg()->waitForGdbAttach).toInt() * timeoutFactor(); - chg()->dumpCore = config.value(qSL("dumpCore"), chg()->dumpCore).toBool(); - QVariantMap stackFramesToIgnore = config.value(qSL("stackFramesToIgnore")).toMap(); - chg()->stackFramesToIgnoreOnCrash = stackFramesToIgnore.value(qSL("onCrash"), chg()->stackFramesToIgnoreOnCrash).toInt(); - chg()->stackFramesToIgnoreOnException = stackFramesToIgnore.value(qSL("onException"), chg()->stackFramesToIgnoreOnException).toInt(); + chg()->printBacktrace = config.value(u"printBacktrace"_s, chg()->printBacktrace).toBool(); + chg()->printQmlStack = config.value(u"printQmlStack"_s, chg()->printQmlStack).toBool(); + chg()->waitForGdbAttach = config.value(u"waitForGdbAttach"_s, chg()->waitForGdbAttach).toInt() * timeoutFactor(); + chg()->dumpCore = config.value(u"dumpCore"_s, chg()->dumpCore).toBool(); + QVariantMap stackFramesToIgnore = config.value(u"stackFramesToIgnore"_s).toMap(); + chg()->stackFramesToIgnoreOnCrash = stackFramesToIgnore.value(u"onCrash"_s, chg()->stackFramesToIgnoreOnCrash).toInt(); + chg()->stackFramesToIgnoreOnException = stackFramesToIgnore.value(u"onException"_s, chg()->stackFramesToIgnoreOnException).toInt(); } void CrashHandler::setQmlEngine(QQmlEngine *engine) @@ -169,7 +171,7 @@ static void logMsg(LogToDestination logTo, const char *msg, int msgLen = -1) dummy += write(STDERR_FILENO, "\n", 1); Q_UNUSED(dummy) } else if (logTo == Dlt) { - Logging::logToDlt(QtMsgType::QtFatalMsg, QMessageLogContext(), QLatin1String(msg, msgLen)); + Logging::logToDlt(QtMsgType::QtFatalMsg, QMessageLogContext(), QString::fromLatin1(msg, msgLen)); } } diff --git a/src/common-lib/exception.cpp b/src/common-lib/exception.cpp index 83f806f3..d00412d9 100644 --- a/src/common-lib/exception.cpp +++ b/src/common-lib/exception.cpp @@ -12,7 +12,7 @@ QT_BEGIN_NAMESPACE_AM Exception::Exception(const char *errorString) Q_DECL_NOEXCEPT : m_errorCode(Error::System) - , m_errorString(errorString ? qL1S(errorString) : QString()) + , m_errorString(errorString ? QString::fromLatin1(errorString) : QString()) { } Exception::Exception(const QString &errorString) Q_DECL_NOEXCEPT @@ -22,7 +22,7 @@ Exception::Exception(const QString &errorString) Q_DECL_NOEXCEPT Exception::Exception(Error errorCode, const char *errorString) Q_DECL_NOEXCEPT : m_errorCode(errorCode) - , m_errorString(errorString ? qL1S(errorString) : QString()) + , m_errorString(errorString ? QString::fromLatin1(errorString) : QString()) { } Exception::Exception(Error errorCode, const QString &errorString) Q_DECL_NOEXCEPT @@ -32,12 +32,12 @@ Exception::Exception(Error errorCode, const QString &errorString) Q_DECL_NOEXCEP Exception::Exception(int _errno, const char *errorString) Q_DECL_NOEXCEPT : m_errorCode(_errno == EACCES ? Error::Permissions : Error::IO) - , m_errorString(qL1S(errorString) + qSL(": ") + QString::fromLocal8Bit(strerror(_errno))) + , m_errorString(QString::fromLatin1(errorString) + u": " + QString::fromLocal8Bit(strerror(_errno))) { } Exception::Exception(const QFileDevice &file, const char *errorString) Q_DECL_NOEXCEPT : m_errorCode(file.error() == QFileDevice::PermissionsError ? Error::Permissions : Error::IO) - , m_errorString(qL1S(errorString) + qSL(" (") + file.fileName() + qSL("): ") + file.errorString()) + , m_errorString(QString::fromLatin1(errorString) + u" (" + file.fileName() + u"): " + file.errorString()) { } Exception::Exception(const Exception ©) Q_DECL_NOEXCEPT diff --git a/src/common-lib/exception.h b/src/common-lib/exception.h index 30424046..961ec0a6 100644 --- a/src/common-lib/exception.h +++ b/src/common-lib/exception.h @@ -57,9 +57,9 @@ public: { QString s; for (int i = 0; i < c.size(); ++i) { - s += qSL("%1").arg(c.at(i)); + s += QStringLiteral("%1").arg(c.at(i)); if (i < (c.size() - 1)) - s.append(qL1S(", ")); + s.append(u", "); } m_errorString = m_errorString.arg(s); return *this; diff --git a/src/common-lib/global.h b/src/common-lib/global.h index b22edf28..b73f7df3 100644 --- a/src/common-lib/global.h +++ b/src/common-lib/global.h @@ -16,11 +16,6 @@ QT_BEGIN_NAMESPACE_AM // make sure the namespace exists QT_END_NAMESPACE_AM -// make the source a lot less ugly and more readable (until we can finally use user defined literals) -#define qL1S(x) QLatin1String(x) -#define qL1C(x) QLatin1Char(x) -#define qSL(x) QStringLiteral(x) - #if !defined(AM_COMPILING_APPMAN) && !defined(AM_COMPILING_LAUNCHER) && !defined(QT_TESTCASE_BUILDDIR) # if defined(AM_FORCE_COMPILING_AGAINST_MODULES) # warning "You have forced compiling against AppMan modules outside of a (custom) appman binary or launcher build." diff --git a/src/common-lib/logging.cpp b/src/common-lib/logging.cpp index 3d3ae236..a471b03a 100644 --- a/src/common-lib/logging.cpp +++ b/src/common-lib/logging.cpp @@ -434,9 +434,9 @@ QStringList Logging::filterRules() void Logging::setFilterRules(const QStringList &rules) { lg()->rules = rules; - QString rulesStr = rules.join(qL1C('\n')); + QString rulesStr = rules.join(u'\n'); if (QT_CONFIG(am_dltlogging) && lg()->dltEnabled) - rulesStr += qSL("\ngeneral=true"); + rulesStr += u"\ngeneral=true"; QLoggingCategory::setFilterRules(rulesStr); } @@ -554,9 +554,9 @@ void Logging::setDltLongMessageBehavior(const QString &behaviorString) #if QT_CONFIG(am_dltlogging) QDltRegistration::LongMessageBehavior behavior = QDltRegistration::LongMessageBehavior::Truncate; - if (behaviorString == qL1S("split")) + if (behaviorString == u"split") behavior = QDltRegistration::LongMessageBehavior::Split; - else if (behaviorString == qL1S("pass")) + else if (behaviorString == u"pass") behavior = QDltRegistration::LongMessageBehavior::Pass; globalDltRegistration()->setLongMessageBehavior(behavior); diff --git a/src/common-lib/qml-utilities.cpp b/src/common-lib/qml-utilities.cpp index 9891b5c0..2c3f3152 100644 --- a/src/common-lib/qml-utilities.cpp +++ b/src/common-lib/qml-utilities.cpp @@ -12,12 +12,14 @@ #include "utilities.h" #include "qml-utilities.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM // copied straight from Qt 5.1.0 qmlscene/main.cpp for now - needs to be revised void loadQmlDummyDataFiles(QQmlEngine *engine, const QString &directory) { - QDir dir(directory + qSL("/dummydata"), qSL("*.qml")); + QDir dir(directory + u"/dummydata"_s, u"*.qml"_s); QStringList list = dir.entryList(); for (int i = 0; i < list.size(); ++i) { QString qml = list.at(i); diff --git a/src/common-lib/qtyaml.cpp b/src/common-lib/qtyaml.cpp index 5dc3cb91..e8fef242 100644 --- a/src/common-lib/qtyaml.cpp +++ b/src/common-lib/qtyaml.cpp @@ -16,6 +16,8 @@ #include "qtyaml.h" #include "exception.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -174,7 +176,7 @@ static QString mapEventNames(const QVector<yaml_event_type_t> &events) QString names; for (int i = 0; i < events.size(); ++i) { if (i) - names.append(i == (events.size() - 1) ? qL1S(" or ") : qL1S(", ")); + names.append(i == (events.size() - 1) ? u" or " : u", "); names.append(QString::fromLatin1(eventNames.value(events.at(i), "<unknown>"))); } return names; @@ -342,39 +344,39 @@ QVariant YamlParser::parseScalar() const }; static const StaticMapping staticMappings[] = { // keep this sorted for bsearch !! - { qSL(""), ValueNull }, - { qSL(".INF"), ValueInf }, - { qSL(".Inf"), ValueInf }, - { qSL(".NAN"), ValueNaN }, - { qSL(".NaN"), ValueNaN }, - { qSL(".inf"), ValueInf }, - { qSL(".nan"), ValueNaN }, - { qSL("FALSE"), ValueFalse }, - { qSL("False"), ValueFalse }, - { qSL("N"), ValueFalse }, - { qSL("NO"), ValueFalse }, - { qSL("NULL"), ValueNull }, - { qSL("No"), ValueFalse }, - { qSL("Null"), ValueNull }, - { qSL("OFF"), ValueFalse }, - { qSL("Off"), ValueFalse }, - { qSL("ON"), ValueTrue }, - { qSL("On"), ValueTrue }, - { qSL("TRUE"), ValueTrue }, - { qSL("True"), ValueTrue }, - { qSL("Y"), ValueTrue }, - { qSL("YES"), ValueTrue }, - { qSL("Yes"), ValueTrue }, - { qSL("false"), ValueFalse }, - { qSL("n"), ValueFalse }, - { qSL("no"), ValueFalse }, - { qSL("null"), ValueNull }, - { qSL("off"), ValueFalse }, - { qSL("on"), ValueTrue }, - { qSL("true"), ValueTrue }, - { qSL("y"), ValueTrue }, - { qSL("yes"), ValueTrue }, - { qSL("~"), ValueNull } + { u""_s, ValueNull }, + { u".INF"_s, ValueInf }, + { u".Inf"_s, ValueInf }, + { u".NAN"_s, ValueNaN }, + { u".NaN"_s, ValueNaN }, + { u".inf"_s, ValueInf }, + { u".nan"_s, ValueNaN }, + { u"FALSE"_s, ValueFalse }, + { u"False"_s, ValueFalse }, + { u"N"_s, ValueFalse }, + { u"NO"_s, ValueFalse }, + { u"NULL"_s, ValueNull }, + { u"No"_s, ValueFalse }, + { u"Null"_s, ValueNull }, + { u"OFF"_s, ValueFalse }, + { u"Off"_s, ValueFalse }, + { u"ON"_s, ValueTrue }, + { u"On"_s, ValueTrue }, + { u"TRUE"_s, ValueTrue }, + { u"True"_s, ValueTrue }, + { u"Y"_s, ValueTrue }, + { u"YES"_s, ValueTrue }, + { u"Yes"_s, ValueTrue }, + { u"false"_s, ValueFalse }, + { u"n"_s, ValueFalse }, + { u"no"_s, ValueFalse }, + { u"null"_s, ValueNull }, + { u"off"_s, ValueFalse }, + { u"on"_s, ValueTrue }, + { u"true"_s, ValueTrue }, + { u"y"_s, ValueTrue }, + { u"yes"_s, ValueTrue }, + { u"~"_s, ValueNull } }; static const char *firstCharStaticMappings = ".FNOTYfnoty~"; @@ -404,11 +406,11 @@ QVariant YamlParser::parseScalar() const // QRegularExpression is lacking such a functionality. Creating all the objects from // scratch in every thread is expensive though, so we count on match() being thread-safe. static const QRegularExpression numberRegExps[] = { - QRegularExpression(qSL("\\A[-+]?(0|[1-9][0-9_]*)\\z")), // decimal - QRegularExpression(qSL("\\A[-+]?([0-9][0-9_]*)?\\.[0-9.]*([eE][-+][0-9]+)?\\z")), // float - QRegularExpression(qSL("\\A[-+]?0x[0-9a-fA-F_]+\\z")), // hexadecimal - QRegularExpression(qSL("\\A[-+]?0b[0-1_]+\\z")), // binary - QRegularExpression(qSL("\\A[-+]?0[0-7_]+\\z")), // octal + QRegularExpression(u"\\A[-+]?(0|[1-9][0-9_]*)\\z"_s), // decimal + QRegularExpression(u"\\A[-+]?([0-9][0-9_]*)?\\.[0-9.]*([eE][-+][0-9]+)?\\z"_s), // float + QRegularExpression(u"\\A[-+]?0x[0-9a-fA-F_]+\\z"_s), // hexadecimal + QRegularExpression(u"\\A[-+]?0b[0-1_]+\\z"_s), // binary + QRegularExpression(u"\\A[-+]?0[0-7_]+\\z"_s), // octal }; for (size_t numberIndex = 0; numberIndex < (sizeof(numberRegExps) / sizeof(*numberRegExps)); ++numberIndex) { if (numberRegExps[numberIndex].match(scalar).hasMatch()) { @@ -416,8 +418,8 @@ QVariant YamlParser::parseScalar() const QVariant val; // YAML allows _ as a grouping separator - if (scalar.contains(qL1C('_'))) - scalar = scalar.replace(qL1C('_'), qSL("")); + if (scalar.contains(u'_')) + scalar = scalar.replace(u'_', u""_s); if (numberIndex == 1) { val = scalar.toDouble(&ok); @@ -427,7 +429,7 @@ QVariant YamlParser::parseScalar() const switch (numberIndex) { case 0: base = 10; break; case 2: base = 16; break; - case 3: base = 2; scalar.replace(qSL("0b"), qSL("")); break; // Qt chokes on 0b + case 3: base = 2; scalar.replace(u"0b"_s, u""_s); break; // Qt chokes on 0b case 4: base = 8; break; } @@ -575,13 +577,13 @@ void YamlParser::parseFields(const std::vector<Field> &fields) nextEvent(); // read key if (d->event.type == YAML_MAPPING_END_EVENT) break; - QString key = parseMapKey(); + const QString key = parseMapKey(); if (fieldsFound.contains(key)) throw YamlParserException(this, "Found duplicate key '%1' in mapping").arg(key); auto field = fields.cbegin(); for (; field != fields.cend(); ++field) { - if (key == QString::fromLatin1(field->name)) + if (key == field->name) break; } if (field == fields.cend()) @@ -618,8 +620,8 @@ void YamlParser::parseFields(const std::vector<Field> &fields) } QStringList fieldsMissing; for (const auto &field : fields) { - if (field.required && !fieldsFound.contains(qL1S(field.name))) - fieldsMissing.append(qL1S(field.name)); + if (field.required && !fieldsFound.contains(field.name)) + fieldsMissing.append(field.name); } if (!fieldsMissing.isEmpty()) throw YamlParserException(this, "Required fields are missing: %1").arg(fieldsMissing); @@ -632,18 +634,18 @@ YamlParserException::YamlParserException(YamlParser *p, const char *errorString) yaml_mark_t &mark = isProblem ? p->d->parser.problem_mark : p->d->parser.mark; QString context = QString::fromUtf8(p->d->data); - qsizetype lpos = context.lastIndexOf(qL1C('\n'), qsizetype(mark.index ? mark.index - 1 : 0)); - qsizetype rpos = context.indexOf(qL1C('\n'), qsizetype(mark.index)); + qsizetype lpos = context.lastIndexOf(u'\n', qsizetype(mark.index ? mark.index - 1 : 0)); + qsizetype rpos = context.indexOf(u'\n', qsizetype(mark.index)); context = context.mid(lpos + 1, rpos == -1 ? context.size() : rpos - lpos - 1); qsizetype contextPos = qsizetype(mark.index) - (lpos + 1); - m_errorString.append(qSL(":\nfile://%1:%2:%3: error").arg(p->sourcePath()).arg(mark.line + 1).arg(mark.column + 1)); + m_errorString.append(u":\nfile://%1:%2:%3: error"_s.arg(p->sourcePath()).arg(mark.line + 1).arg(mark.column + 1)); if (errorString) - m_errorString.append(qSL(": %1").arg(qL1S(errorString))); + m_errorString.append(u": %1"_s.arg(QString::fromLatin1(errorString))); if (isProblem) - m_errorString.append(qSL(": %1").arg(QString::fromUtf8(p->d->parser.problem))); + m_errorString.append(u": %1"_s.arg(QString::fromUtf8(p->d->parser.problem))); if (!context.isEmpty()) - m_errorString.append(qSL("\n %1\n %2^").arg(context, QString(contextPos, qL1C(' ')))); + m_errorString.append(u"\n %1\n %2^"_s.arg(context, QString(contextPos, u' '))); } QT_END_NAMESPACE_AM diff --git a/src/common-lib/qtyaml.h b/src/common-lib/qtyaml.h index 1e4c414f..a604ed27 100644 --- a/src/common-lib/qtyaml.h +++ b/src/common-lib/qtyaml.h @@ -92,14 +92,14 @@ public: Q_DECLARE_FLAGS(FieldTypes, FieldType) struct Field { - QByteArray name; + QString name; bool required; FieldTypes types; std::function<void(YamlParser *)> callback; Field(const char *_name, bool _required, FieldTypes _types, const std::function<void(YamlParser *)> &_callback) - : name(_name) + : name(QString::fromLatin1(_name)) , required(_required) , types(_types) , callback(_callback) diff --git a/src/common-lib/utilities.cpp b/src/common-lib/utilities.cpp index be40c40a..f9c7cfd7 100644 --- a/src/common-lib/utilities.cpp +++ b/src/common-lib/utilities.cpp @@ -32,6 +32,8 @@ #include <memory> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM /*! \internal @@ -61,8 +63,8 @@ YamlFormat checkYamlFormat(const QVector<QVariant> &docs, int numberOfDocuments, const auto map = docs.constFirst().toMap(); YamlFormat actualFormatTypeAndVersion = { - map.value(qSL("formatType")).toString(), - map.value(qSL("formatVersion")).toInt() + map.value(u"formatType"_s).toString(), + map.value(u"formatVersion"_s).toInt() }; class StringifyTypeAndVersion @@ -80,9 +82,9 @@ YamlFormat checkYamlFormat(const QVector<QVariant> &docs, int numberOfDocuments, void operator()(const QPair<QString, int> &typeAndVersion) { if (!m_str.isEmpty()) - m_str += qSL(" or "); - m_str = m_str + qSL("type '") + typeAndVersion.first + qSL("', version '") - + QString::number(typeAndVersion.second) + qL1C('\''); + m_str += u" or "; + m_str = m_str + u"type '" + typeAndVersion.first + u"', version '" + + QString::number(typeAndVersion.second) + u'\''; } private: QString m_str; @@ -125,8 +127,7 @@ qint64 getParentPid(qint64 pid) qint64 ppid = 0; #if defined(Q_OS_LINUX) - static QString proc = qSL("/proc/%1/stat"); - QFile f(proc.arg(pid)); + QFile f(u"/proc/%1/stat"_s.arg(pid)); if (f.open(QIODevice::ReadOnly)) { // we need just the 4th field, but the 2nd is the binary name, which could be long QByteArray ba = f.read(512); @@ -271,9 +272,9 @@ QString translateFromMap(const QMap<QString, QString> &languageToName, const QSt if (!languageToName.isEmpty()) { QString name = languageToName.value(QLocale::system().name()); //TODO: language changes if (name.isNull()) - name = languageToName.value(qSL("en")); + name = languageToName.value(u"en"_s); if (name.isNull()) - name = languageToName.value(qSL("en_US")); + name = languageToName.value(u"en_US"_s); if (name.isNull()) name = languageToName.first(); return name; @@ -288,14 +289,14 @@ void loadResource(const QString &resource) Q_DECL_NOEXCEPT_EXPR(false) QStringList errors; QString debugSuffix; #if defined(Q_OS_WINDOWS) - debugSuffix = qSL("d"); + debugSuffix = u"d"_s; #elif defined(Q_OS_MACOS) - debugSuffix = qSL("_debug"); + debugSuffix = u"_debug"_s; #endif if (QResource::registerResource(resource)) return; - errors.append(qL1S("Cannot load as Qt Resource file")); + errors.append(u"Cannot load as Qt Resource file"_s); QLibrary lib(afp); if (lib.load()) @@ -308,7 +309,7 @@ void loadResource(const QString &resource) Q_DECL_NOEXCEPT_EXPR(false) return; errors.append(libd.errorString()); } - throw Exception("Failed to load resource %1:\n * %2").arg(resource).arg(errors.join(qSL("\n * "))); + throw Exception("Failed to load resource %1:\n * %2").arg(resource).arg(errors.join(u"\n * "_s)); } void closeAndClearFileDescriptors(QVector<int> &fdList) diff --git a/src/common-lib/utilities.h b/src/common-lib/utilities.h index 9bd60f77..b42f222a 100644 --- a/src/common-lib/utilities.h +++ b/src/common-lib/utilities.h @@ -45,8 +45,8 @@ inline QStringList variantToStringList(const QVariant &v) // For some weird reason, QFile cannot cope with "qrc:" and QUrl cannot cope with ":". inline QUrl filePathToUrl(const QString &path, const QString &baseDir) { - return path.startsWith(qSL(":")) ? QUrl(qSL("qrc") + path) - : QUrl::fromUserInput(path, baseDir, QUrl::AssumeLocalFile); + return path.startsWith(u":") ? QUrl(QStringLiteral("qrc") + path) + : QUrl::fromUserInput(path, baseDir, QUrl::AssumeLocalFile); } // Used in {Package,Application,Intent}::name() @@ -56,14 +56,14 @@ inline QString urlToLocalFilePath(const QUrl &url) { if (url.isLocalFile()) return url.toLocalFile(); - else if (url.scheme() == qSL("qrc")) - return qL1C(':') + url.path(); + else if (url.scheme() == u"qrc") + return u':' + url.path(); return { }; } inline QString toAbsoluteFilePath(const QString &path, const QString &baseDir = QDir::currentPath()) { - return path.startsWith(qSL("qrc:")) ? path.mid(3) : QDir(baseDir).absoluteFilePath(path); + return path.startsWith(u"qrc:") ? path.mid(3) : QDir(baseDir).absoluteFilePath(path); } /*! \internal diff --git a/src/crypto-lib/cryptography.cpp b/src/crypto-lib/cryptography.cpp index 9f781db4..05fc5145 100644 --- a/src/crypto-lib/cryptography.cpp +++ b/src/crypto-lib/cryptography.cpp @@ -40,6 +40,9 @@ QT_END_NAMESPACE_AM #endif +using namespace Qt::StringLiterals; + + QT_BEGIN_NAMESPACE_AM @@ -49,7 +52,7 @@ QByteArray Cryptography::generateRandomBytes(int size) if (size > 0) { #if defined(Q_OS_UNIX) - QFile f(qSL("/dev/urandom")); + QFile f(u"/dev/urandom"_s); if (f.open(QIODevice::ReadOnly)) { result = f.read(size); if (result.size() != size) @@ -93,7 +96,7 @@ QString Cryptography::errorString(qint64 osCryptoError, const char *errorDescrip QString result; if (errorDescription && *errorDescription) { result = QString::fromLatin1(errorDescription); - result.append(QLatin1String(": ")); + result.append(u": "_s); } #if defined(QT_AM_USE_LIBCRYPTO) diff --git a/src/crypto-lib/signature_win.cpp b/src/crypto-lib/signature_win.cpp index 7efd0548..73fb6d88 100644 --- a/src/crypto-lib/signature_win.cpp +++ b/src/crypto-lib/signature_win.cpp @@ -197,8 +197,8 @@ bool SignaturePrivate::verify(const QByteArray &signaturePkcs7, if (chainContext->TrustStatus.dwErrorStatus != CERT_TRUST_NO_ERROR) { throw Exception("Failed to verify signature (error: 0x%1, info: 0x%2") - .arg(chainContext->TrustStatus.dwErrorStatus, 8, 16, qL1C('0')) - .arg(chainContext->TrustStatus.dwInfoStatus, 8, 16, qL1C('0')); + .arg(chainContext->TrustStatus.dwErrorStatus, 8, 16, QChar(u'0')) + .arg(chainContext->TrustStatus.dwInfoStatus, 8, 16, QChar(u'0')); } cleanup(); diff --git a/src/dbus-lib/dbusdaemon.cpp b/src/dbus-lib/dbusdaemon.cpp index aff76402..25f8750e 100644 --- a/src/dbus-lib/dbusdaemon.cpp +++ b/src/dbus-lib/dbusdaemon.cpp @@ -19,6 +19,8 @@ #include "exception.h" #include "logging.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM #if defined(Q_OS_LINUX) @@ -42,29 +44,29 @@ static QVersionNumber dbusVersion() DBusDaemonProcess::DBusDaemonProcess(QObject *parent) : QProcess(parent) { - QString program = qSL("dbus-daemon"); - QStringList arguments = { qSL("--nofork"), qSL("--print-address"), qSL("--session") }; + QString program = u"dbus-daemon"_s; + QStringList arguments = { u"--nofork"_s, u"--print-address"_s, u"--session"_s }; #if defined(Q_OS_MACOS) // there's no native dbus support on macOS, so we try to use brew's dbus support - program = qSL("/usr/local/bin/dbus-daemon"); + program = u"/usr/local/bin/dbus-daemon"_s; // brew's dbus-daemon needs an address, because it will otherwise assume that it was // started via launchd and expects its address in $DBUS_LAUNCHD_SESSION_BUS_SOCKET - QString address = qSL("--address=unix:path=") + QDir::tempPath() + qSL("/am-") - + QString::number(QCoreApplication::applicationPid()) + qSL("-session.bus"); + QString address = u"--address=unix:path="_s + QDir::tempPath() + u"/am-"_s + + QString::number(QCoreApplication::applicationPid()) + u"-session.bus"_s; arguments << address; #elif defined(Q_OS_WIN) - arguments << qSL("--address=tcp:host=localhost"); + arguments << u"--address=tcp:host=localhost"_s; #elif defined(Q_OS_LINUX) // some dbus implementations create an abstract socket by default, while others create // a file based one. we need a file based one however, because that socket might get // mapped into a container. if (dbusVersion() >= QVersionNumber(1, 11, 14)) { - arguments << qSL("--address=unix:dir=/tmp"); + arguments << u"--address=unix:dir=/tmp"_s; } else { - arguments << QString(qSL("--address=unix:path=") + QDir::tempPath() + qSL("/am-") - + QString::number(QCoreApplication::applicationPid()) + qSL("-session.bus")); + arguments << QString(u"--address=unix:path="_s + QDir::tempPath() + u"/am-"_s + + QString::number(QCoreApplication::applicationPid()) + u"-session.bus"_s); } #endif setProgram(program); diff --git a/src/dbus-lib/dbuspolicy.cpp b/src/dbus-lib/dbuspolicy.cpp index 72bb40da..1feffb63 100644 --- a/src/dbus-lib/dbuspolicy.cpp +++ b/src/dbus-lib/dbuspolicy.cpp @@ -17,6 +17,8 @@ #include "dbuspolicy.h" #include "dbuscontextadaptor.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -69,16 +71,16 @@ bool DBusPolicy::add(const QDBusAbstractAdaptor *dbusAdaptor, const QVariantMap DBusPolicyEntry dbp; bool ok; - const QVariantList uidList = policy.value(qSL("uids")).toList(); + const QVariantList uidList = policy.value(u"uids"_s).toList(); for (const QVariant &v : uidList) { uint uid = v.toUInt(&ok); if (ok) dbp.m_uids << uid; } std::sort(dbp.m_uids.begin(), dbp.m_uids.end()); - dbp.m_executables = variantToStringList(policy.value(qSL("executables"))); + dbp.m_executables = variantToStringList(policy.value(u"executables"_s)); dbp.m_executables.sort(); - dbp.m_capabilities = variantToStringList(policy.value(qSL("capabilities"))); + dbp.m_capabilities = variantToStringList(policy.value(u"capabilities"_s)); dbp.m_capabilities.sort(); result.insert(func, dbp); @@ -136,7 +138,7 @@ bool DBusPolicy::check(const QDBusAbstractAdaptor *dbusAdaptor, const QByteArray # if defined(Q_OS_LINUX) if (pid == uint(-1)) pid = dbusContext->connection().interface()->servicePid(dbusContext->message().service()); - QString executable = QFileInfo(qSL("/proc/") + QString::number(pid) + qSL("/exe")).symLinkTarget(); + QString executable = QFileInfo(u"/proc/"_s + QString::number(pid) + u"/exe"_s).symLinkTarget(); if (executable.isEmpty()) throw "cannot get executable"; if (std::binary_search(ip->m_executables.cbegin(), ip->m_executables.cend(), executable)) @@ -154,7 +156,7 @@ bool DBusPolicy::check(const QDBusAbstractAdaptor *dbusAdaptor, const QByteArray return true; } catch (const char *msg) { - dbusContext->sendErrorReply(QDBusError::AccessDenied, QString::fromLatin1("Protected function call (%1)").arg(qL1S(msg))); + dbusContext->sendErrorReply(QDBusError::AccessDenied, u"Protected function call (%1)"_s.arg(QString::fromLatin1(msg))); return false; } #endif // !defined(Q_OS_UNIX) diff --git a/src/intent-client-lib/intentclient.cpp b/src/intent-client-lib/intentclient.cpp index 69c10c67..c4bdfbb0 100644 --- a/src/intent-client-lib/intentclient.cpp +++ b/src/intent-client-lib/intentclient.cpp @@ -15,6 +15,9 @@ #include <exception> #include <memory> +using namespace Qt::StringLiterals; + + QT_BEGIN_NAMESPACE_AM /*! @@ -77,7 +80,7 @@ IntentClient *IntentClient::instance() */ QString IntentClient::systemUiId() const { - return qSL(":sysui:"); + return u":sysui:"_s; } int IntentClient::replyFromSystemTimeout() const @@ -169,7 +172,7 @@ IntentClientRequest *IntentClient::sendIntentRequest(const QString &intentId, co { if (intentId.isEmpty()) return nullptr; - if (applicationId == qSL(":broadcast:")) // reserved + if (applicationId == u":broadcast:") // reserved return nullptr; //TODO: check that parameters only contains basic datatypes. convertFromJSVariant() does most of @@ -200,7 +203,7 @@ bool IntentClient::broadcastIntentRequest(const QString &intentId, const QVarian //TODO: check that parameters only contains basic datatypes. convertFromJSVariant() does most of // this already, but doesn't bail out on unconvertible types (yet) - requestToSystem(m_systemInterface->currentApplicationId(this), intentId, qSL(":broadcast:"), parameters); + requestToSystem(m_systemInterface->currentApplicationId(this), intentId, u":broadcast:"_s, parameters); return true; } @@ -211,7 +214,7 @@ IntentClientRequest *IntentClient::requestToSystem(const QString &requestingAppl IntentClientRequest *ir = new IntentClientRequest(IntentClientRequest::Direction::ToSystem, requestingApplicationId, QUuid(), intentId, applicationId, parameters, - applicationId == qSL(":broadcast:")); + applicationId == u":broadcast:"); qCDebug(LogIntents) << "Application" << requestingApplicationId << "created an intent request for" << intentId << "(application:" << applicationId << ")"; @@ -232,7 +235,7 @@ void IntentClient::requestToSystemFinished(IntentClientRequest *icr, const QUuid if (error) { icr->setErrorMessage(errorMessage); } else if (newRequestId.isNull()) { - icr->setErrorMessage(qL1S("No matching Intent found in the system")); + icr->setErrorMessage(u"No matching Intent found in the system"_s); } else { icr->setRequestId(newRequestId); m_waiting << icr; @@ -250,7 +253,7 @@ void IntentClient::replyFromSystem(const QUuid &requestId, bool error, const QVa if (it == m_waiting.cend()) { qCWarning(LogIntents) << "IntentClient received an unexpected intent reply for request" << requestId << " succeeded:" << !error << "error:" - << result.value(qL1S("errorMessage")).toString() << "result:" << result; + << result.value(u"errorMessage"_s).toString() << "result:" << result; return; } icr = *it; @@ -263,7 +266,7 @@ void IntentClient::replyFromSystem(const QUuid &requestId, bool error, const QVa } if (error) - icr->setErrorMessage(result.value(qSL("errorMessage")).toString()); + icr->setErrorMessage(result.value(u"errorMessage"_s).toString()); else icr->setResult(result); @@ -276,7 +279,7 @@ void IntentClient::requestToApplication(const QUuid &requestId, const QString &i const QString &requestingApplicationId, const QString &applicationId, const QVariantMap ¶meters) { - bool broadcast = (requestingApplicationId == qSL(":broadcast:")); + bool broadcast = (requestingApplicationId == u":broadcast:"); qCDebug(LogIntents) << "Client: Incoming intent request" << requestId << "to application" << applicationId << "for intent" << intentId << (broadcast ? "(broadcast)" : "") << "parameters" << parameters; @@ -294,7 +297,7 @@ void IntentClient::requestToApplication(const QUuid &requestId, const QString &i handler->internalRequestReceived(icr); } else { qCDebug(LogIntents) << "No Intent handler registered for intent" << intentId; - errorReplyFromApplication(icr, qSL("No matching IntentHandler found.")); + errorReplyFromApplication(icr, u"No matching IntentHandler found."_s); delete icr; } } @@ -316,7 +319,7 @@ void IntentClient::errorReplyFromApplication(IntentClientRequest *icr, const QSt return; icr->m_succeeded = false; icr->m_finished = true; - icr->m_result = QVariantMap{ { qSL("errorMessage"), errorMessage } }; + icr->m_result = QVariantMap{ { u"errorMessage"_s, errorMessage } }; m_systemInterface->replyFromApplication(icr); } diff --git a/src/intent-client-lib/intentclientrequest.cpp b/src/intent-client-lib/intentclientrequest.cpp index e077fe35..a11e697b 100644 --- a/src/intent-client-lib/intentclientrequest.cpp +++ b/src/intent-client-lib/intentclientrequest.cpp @@ -12,6 +12,9 @@ #include <QPointer> #include <QTimer> +using namespace Qt::StringLiterals; + + QT_BEGIN_NAMESPACE_AM /*! \qmltype IntentRequest @@ -155,7 +158,7 @@ IntentClientRequest::~IntentClientRequest() { // the incoming request was gc'ed on the JavaScript side, but no reply was sent yet if ((direction() == Direction::ToApplication) && !m_finished && !m_broadcast) - sendErrorReply(qSL("Request not handled")); + sendErrorReply(u"Request not handled"_s); } QUuid IntentClientRequest::requestId() const @@ -285,9 +288,9 @@ void IntentClientRequest::startTimeout(int timeout) QTimer::singleShot(timeout, this, [this, timeout]() { if (!m_finished) { if (direction() == Direction::ToApplication) - sendErrorReply(qSL("Intent request to application timed out after %1 ms").arg(timeout)); + sendErrorReply(u"Intent request to application timed out after %1 ms"_s.arg(timeout)); else - setErrorMessage(qSL("No reply received from Intent server after %1 ms").arg(timeout)); + setErrorMessage(u"No reply received from Intent server after %1 ms"_s.arg(timeout)); } }); } diff --git a/src/intent-server-lib/intentserver.cpp b/src/intent-server-lib/intentserver.cpp index 5eeb3a02..a51684df 100644 --- a/src/intent-server-lib/intentserver.cpp +++ b/src/intent-server-lib/intentserver.cpp @@ -23,6 +23,9 @@ #include <memory> +using namespace Qt::StringLiterals; + + QT_BEGIN_NAMESPACE_AM /*! @@ -369,7 +372,7 @@ QVariantMap IntentServer::get(int index) const QVariantMap map; QHash<int, QByteArray> roles = roleNames(); for (auto it = roles.begin(); it != roles.end(); ++it) - map.insert(qL1S(it.value()), data(this->index(index), it.key())); + map.insert(QString::fromLatin1(it.value()), data(this->index(index), it.key())); return map; } @@ -517,7 +520,7 @@ void IntentServer::processRequestQueue() if (m_disambiguationTimeout > 0) { QTimer::singleShot(m_disambiguationTimeout, this, [this, isr]() { if (m_disambiguationQueue.removeOne(isr)) { - isr->setRequestFailed(qSL("Disambiguation timed out after %1 ms").arg(m_disambiguationTimeout)); + isr->setRequestFailed(u"Disambiguation timed out after %1 ms"_s.arg(m_disambiguationTimeout)); enqueueRequest(isr); } }); @@ -539,14 +542,14 @@ void IntentServer::processRequestQueue() if (isr->selectedIntent()->handleOnlyWhenRunning()) { qCDebug(LogIntents) << " * skipping, because 'handleOnlyWhenRunning' is set"; - isr->setRequestFailed(qSL("Skipping delivery due to handleOnlyWhenRunning")); + isr->setRequestFailed(u"Skipping delivery due to handleOnlyWhenRunning"_s); } else { m_startingAppQueue.enqueue(isr); isr->setState(IntentServerRequest::State::WaitingForApplicationStart); if (m_startingAppTimeout > 0) { QTimer::singleShot(m_startingAppTimeout, this, [this, isr]() { if (m_startingAppQueue.removeOne(isr)) { - isr->setRequestFailed(qSL("Starting handler application timed out after %1 ms").arg(m_startingAppTimeout)); + isr->setRequestFailed(u"Starting handler application timed out after %1 ms"_s.arg(m_startingAppTimeout)); enqueueRequest(isr); } }); @@ -565,7 +568,7 @@ void IntentServer::processRequestQueue() qCWarning(LogIntents) << "Could not find an IPC connection for application" << isr->selectedIntent()->applicationId() << "to forward the intent request" << isr->requestId(); - isr->setRequestFailed(qSL("No IPC channel to reach target application.")); + isr->setRequestFailed(u"No IPC channel to reach target application."_s); } else { qCDebug(LogIntents) << "Sending intent request to handler application" << isr->selectedIntent()->applicationId(); @@ -575,7 +578,7 @@ void IntentServer::processRequestQueue() if (m_sentToAppTimeout > 0) { QTimer::singleShot(m_sentToAppTimeout, this, [this, isr]() { if (m_sentToAppQueue.removeOne(isr)) { - isr->setRequestFailed(qSL("Waiting for reply from handler application timed out after %1 ms").arg(m_sentToAppTimeout)); + isr->setRequestFailed(u"Waiting for reply from handler application timed out after %1 ms"_s.arg(m_sentToAppTimeout)); enqueueRequest(isr); } }); @@ -679,7 +682,7 @@ void IntentServer::internalDisambiguateRequest(const QUuid &requestId, bool reje << ", but no disambiguation was expected for this intent"; } else { if (reject) { - isr->setRequestFailed(qSL("Disambiguation was rejected")); + isr->setRequestFailed(u"Disambiguation was rejected"_s); } else if (isr->potentialIntents().contains(selectedIntent)) { isr->setSelectedIntent(selectedIntent); isr->setState(IntentServerRequest::State::Disambiguated); @@ -688,7 +691,7 @@ void IntentServer::internalDisambiguateRequest(const QUuid &requestId, bool reje << requestId << "tried to disambiguate to the intent" << selectedIntent->intentId() << "which was not in the list of potential disambiguations"; - isr->setRequestFailed(qSL("Failed to disambiguate")); + isr->setRequestFailed(u"Failed to disambiguate"_s); } enqueueRequest(isr); } @@ -736,11 +739,11 @@ void IntentServer::replyFromApplication(const QString &replyingApplicationId, co qCWarning(LogIntents) << "Got a reply for intent" << isr->requestId() << "from application" << replyingApplicationId << "but expected a reply from" << isr->selectedIntent()->applicationId() << "instead"; - isr->setRequestFailed(qSL("Request reply received from wrong application")); + isr->setRequestFailed(u"Request reply received from wrong application"_s); } else { QString errorMessage; if (error) { - errorMessage = result.value(qSL("errorMessage")).toString(); + errorMessage = result.value(u"errorMessage"_s).toString(); qCDebug(LogIntents) << "Got an error reply for intent" << isr->requestId() << "from application" << replyingApplicationId << ":" << errorMessage; isr->setRequestFailed(errorMessage); @@ -768,7 +771,7 @@ IntentServerRequest *IntentServer::requestToSystem(const QString &requestingAppl } QVector<Intent *> intents; - bool broadcast = (applicationId == qSL(":broadcast:")); + bool broadcast = (applicationId == u":broadcast:"); if (applicationId.isEmpty() || broadcast) { intents = filterByIntentId(m_intents, intentId, parameters); } else { diff --git a/src/intent-server-lib/intentserverrequest.cpp b/src/intent-server-lib/intentserverrequest.cpp index 302230b4..f468b1c9 100644 --- a/src/intent-server-lib/intentserverrequest.cpp +++ b/src/intent-server-lib/intentserverrequest.cpp @@ -5,6 +5,8 @@ #include "intentserverrequest.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM IntentServerRequest::IntentServerRequest(const QString &requestingApplicationId, const QString &intentId, @@ -87,7 +89,7 @@ void IntentServerRequest::setRequestFailed(const QString &errorMessage) { m_succeeded = false; m_result.clear(); - m_result[qSL("errorMessage")] = errorMessage; + m_result[u"errorMessage"_s] = errorMessage; m_state = State::ReceivedReplyFromApplication; } diff --git a/src/main-lib/applicationmanageradaptor_dbus.cpp b/src/main-lib/applicationmanageradaptor_dbus.cpp index e8355a1f..3f361c7f 100644 --- a/src/main-lib/applicationmanageradaptor_dbus.cpp +++ b/src/main-lib/applicationmanageradaptor_dbus.cpp @@ -18,6 +18,8 @@ #include "intentclient.h" #include "intentclientrequest.h" +using namespace Qt::StringLiterals; + //NOTE: The header for this class is autogenerated from the XML interface definition. // We are NOT using the generated cpp, but instead implement the adaptor manually. @@ -121,11 +123,11 @@ bool ApplicationManagerAdaptor::debugApplication(const QString &id, const QStrin int fd = dfd.fileDescriptor(); const QString &which = it.key(); - if (which == qL1S("in")) + if (which == u"in") stdioRedirections[0] = dup(fd); - else if (which == qL1S("out")) + else if (which == u"out") stdioRedirections[1] = dup(fd); - else if (which == qL1S("err")) + else if (which == u"err") stdioRedirections[2] = dup(fd); } # else @@ -147,8 +149,8 @@ QVariantMap ApplicationManagerAdaptor::get(const QString &id) { QT_AM_AUTHENTICATE_DBUS(QVariantMap) auto map = ApplicationManager::instance()->get(id); - map.remove(qSL("application")); // cannot marshall QObject * - map.remove(qSL("applicationObject")); // cannot marshall QObject * + map.remove(u"application"_s); // cannot marshall QObject * + map.remove(u"applicationObject"_s); // cannot marshall QObject * return convertFromJSVariant(map).toMap(); } @@ -192,11 +194,11 @@ bool ApplicationManagerAdaptor::startApplication(const QString &id, const QtAM:: int fd = dfd.fileDescriptor(); const QString &which = it.key(); - if (which == qL1S("in")) + if (which == u"in") stdioRedirections[0] = dup(fd); - else if (which == qL1S("out")) + else if (which == u"out") stdioRedirections[1] = dup(fd); - else if (which == qL1S("err")) + else if (which == u"err") stdioRedirections[2] = dup(fd); } # else @@ -247,12 +249,12 @@ QString ApplicationManagerAdaptor::sendIntentRequestAs(const QString &requesting if (!PackageManager::instance()->developmentMode()) { dbusContext->sendErrorReply(QDBusError::Failed, - qL1S("Only supported if 'developmentMode' is active")); + u"Only supported if 'developmentMode' is active"_s); return { }; } if (intentId.isEmpty()) { - dbusContext->sendErrorReply(QDBusError::Failed, qL1S("intentId cannot be empty")); + dbusContext->sendErrorReply(QDBusError::Failed, u"intentId cannot be empty"_s); return { }; } @@ -262,7 +264,7 @@ QString ApplicationManagerAdaptor::sendIntentRequestAs(const QString &requesting auto jsDoc = QJsonDocument::fromJson(jsonParameters.toUtf8(), &parseError); if (jsDoc.isNull()) { dbusContext->sendErrorReply(QDBusError::Failed, - qL1S("jsonParameters is not a valid JSON document: ") + u"jsonParameters is not a valid JSON document: "_s + parseError.errorString()); return { }; } @@ -307,12 +309,12 @@ void ApplicationManagerAdaptor::broadcastIntentRequestAs(const QString &requesti if (!PackageManager::instance()->developmentMode()) { dbusContext->sendErrorReply(QDBusError::Failed, - qL1S("Only supported if 'developmentMode' is active")); + u"Only supported if 'developmentMode' is active"_s); return; } if (intentId.isEmpty()) { - dbusContext->sendErrorReply(QDBusError::Failed, qL1S("intentId cannot be empty")); + dbusContext->sendErrorReply(QDBusError::Failed, u"intentId cannot be empty"_s); return; } @@ -322,7 +324,7 @@ void ApplicationManagerAdaptor::broadcastIntentRequestAs(const QString &requesti auto jsDoc = QJsonDocument::fromJson(jsonParameters.toUtf8(), &parseError); if (jsDoc.isNull()) { dbusContext->sendErrorReply(QDBusError::Failed, - qL1S("jsonParameters is not a valid JSON document: ") + u"jsonParameters is not a valid JSON document: "_s + parseError.errorString()); return; } @@ -332,5 +334,5 @@ void ApplicationManagerAdaptor::broadcastIntentRequestAs(const QString &requesti const QString reqAppId = requestingApplicationId.isEmpty() ? IntentClient::instance()->systemUiId() : requestingApplicationId; - IntentClient::instance()->requestToSystem(reqAppId, intentId, qSL(":broadcast:"), parameters); + IntentClient::instance()->requestToSystem(reqAppId, intentId, u":broadcast:"_s, parameters); } diff --git a/src/main-lib/configuration.cpp b/src/main-lib/configuration.cpp index ee29a538..01d07743 100644 --- a/src/main-lib/configuration.cpp +++ b/src/main-lib/configuration.cpp @@ -34,24 +34,26 @@ #include "configuration.h" #include "configuration_p.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM template<> bool Configuration::value(const char *clname, const bool &cfvalue) const { - return (clname && m_clp.isSet(qL1S(clname))) || cfvalue; + return (clname && m_clp.isSet(QString::fromLatin1(clname))) || cfvalue; } template<> QString Configuration::value(const char *clname, const QString &cfvalue) const { - return (clname && m_clp.isSet(qL1S(clname))) ? m_clp.value(qL1S(clname)) : cfvalue; + return (clname && m_clp.isSet(QString::fromLatin1(clname))) ? m_clp.value(QString::fromLatin1(clname)) : cfvalue; } template<> QStringList Configuration::value(const char *clname, const QStringList &cfvalue) const { QStringList result; if (clname) - result = m_clp.values(qL1S(clname)); + result = m_clp.values(QString::fromLatin1(clname)); if (!cfvalue.isEmpty()) result += cfvalue; return result; @@ -87,7 +89,7 @@ public: Configuration::Configuration(const char *additionalDescription, bool onlyOnePositionalArgument) - : Configuration(QStringList(), qSL(":/build-config.yaml"), + : Configuration(QStringList(), u":/build-config.yaml"_s, additionalDescription, onlyOnePositionalArgument) { } @@ -123,62 +125,62 @@ Configuration::Configuration(const QStringList &defaultConfigFilePaths, " this, if the application manager's crash handler is\n" " interfering with other debugging tools you are using.\n"; - m_clp.setApplicationDescription(qSL("\n") + QCoreApplication::applicationName() + qSL("\n\n") - + (additionalDescription ? (qL1S(additionalDescription) + qSL("\n\n")) : QString()) - + qL1S(description)); + m_clp.setApplicationDescription(u"\n"_s + QCoreApplication::applicationName() + u"\n\n"_s + + (additionalDescription ? (QString::fromLatin1(additionalDescription) + u"\n\n"_s) : QString()) + + QString::fromLatin1(description)); - m_clp.addOption({ { qSL("h"), qSL("help") + m_clp.addOption({ { u"h"_s, u"help"_s #if defined(Q_OS_WINDOWS) - , qSL("?") + , u"?"_s #endif - }, qSL("Displays this help.") }); - m_clp.addOption({ qSL("version"), qSL("Displays version information.") }); - QCommandLineOption cf { { qSL("c"), qSL("config-file") }, - qSL("Load configuration from file (can be given multiple times)."), qSL("files") }; + }, u"Displays this help."_s }); + m_clp.addOption({ u"version"_s, u"Displays version information."_s }); + QCommandLineOption cf { { u"c"_s, u"config-file"_s }, + u"Load configuration from file (can be given multiple times)."_s, u"files"_s }; cf.setDefaultValues(m_defaultConfigFilePaths); m_clp.addOption(cf); - m_clp.addOption({ { qSL("o"), qSL("option") }, qSL("Override a specific config option."), qSL("yaml-snippet") }); - m_clp.addOption({ { qSL("no-cache"), qSL("no-config-cache") }, - qSL("Disable the use of the config and appdb file cache.") }); - m_clp.addOption({ { qSL("clear-cache"), qSL("clear-config-cache") }, - qSL("Ignore an existing config and appdb file cache.") }); - m_clp.addOption({ { qSL("r"), qSL("recreate-database") }, - qSL("Backwards compatibility: synonyms for --clear-cache.") }); + m_clp.addOption({ { u"o"_s, u"option"_s }, u"Override a specific config option."_s, u"yaml-snippet"_s }); + m_clp.addOption({ { u"no-cache"_s, u"no-config-cache"_s }, + u"Disable the use of the config and appdb file cache."_s }); + m_clp.addOption({ { u"clear-cache"_s, u"clear-config-cache"_s }, + u"Ignore an existing config and appdb file cache."_s }); + m_clp.addOption({ { u"r"_s, u"recreate-database"_s }, + u"Backwards compatibility: synonyms for --clear-cache."_s }); if (!buildConfigFilePath.isEmpty()) - m_clp.addOption({ qSL("build-config"), qSL("Dumps the build configuration and exits.") }); - - m_clp.addPositionalArgument(qSL("qml-file"), qSL("The main QML file.")); - m_clp.addOption({ qSL("log-instant"), qSL("Log instantly at start-up, neglect logging configuration.") }); - m_clp.addOption({ qSL("database"), qSL("Deprecated (ignored)."), qSL("file") }); - m_clp.addOption({ qSL("builtin-apps-manifest-dir"), qSL("Base directory for built-in application manifests."), qSL("dir") }); - m_clp.addOption({ qSL("installation-dir"), qSL("Base directory for package installations."), qSL("dir") }); - m_clp.addOption({ qSL("document-dir"), qSL("Base directory for per-package document directories."), qSL("dir") }); - m_clp.addOption({ qSL("installed-apps-manifest-dir"), qSL("Deprecated (ignored)."), qSL("dir") }); - m_clp.addOption({ qSL("app-image-mount-dir"), qSL("Deprecated (ignored)."), qSL("dir") }); - m_clp.addOption({ qSL("disable-installer"), qSL("Disable the application installer sub-system.") }); - m_clp.addOption({ qSL("disable-intents"), qSL("Disable the intents sub-system.") }); - m_clp.addOption({ qSL("dbus"), qSL("Register on the specified D-Bus."), qSL("<bus>|system|session|none|auto"), qSL("auto") }); - m_clp.addOption({ qSL("fullscreen"), qSL("Display in full-screen.") }); - m_clp.addOption({ qSL("no-fullscreen"), qSL("Do not display in full-screen.") }); - m_clp.addOption({ qSL("I"), qSL("Additional QML import path."), qSL("dir") }); - m_clp.addOption({ { qSL("v"), qSL("verbose") }, qSL("Verbose output.") }); - m_clp.addOption({ qSL("slow-animations"), qSL("Run all animations in slow motion.") }); - m_clp.addOption({ qSL("load-dummydata"), qSL("Deprecated. Loads QML dummy-data.") }); - m_clp.addOption({ qSL("no-security"), qSL("Disables all security related checks (dev only!)") }); - m_clp.addOption({ qSL("development-mode"), qSL("Enable development mode, allowing installation of dev-signed packages.") }); - m_clp.addOption({ qSL("no-ui-watchdog"), qSL("Disables detecting hung UI applications (e.g. via Wayland's ping/pong).") }); - m_clp.addOption({ qSL("no-dlt-logging"), qSL("Disables logging using automotive DLT.") }); - m_clp.addOption({ qSL("force-single-process"), qSL("Forces single-process mode even on a wayland enabled build.") }); - m_clp.addOption({ qSL("force-multi-process"), qSL("Forces multi-process mode. Will exit immediately if this is not possible.") }); - m_clp.addOption({ qSL("wayland-socket-name"), qSL("Use this file name to create the wayland socket."), qSL("socket") }); - m_clp.addOption({ qSL("single-app"), qSL("Runs a single application only (ignores the database)"), qSL("info.yaml file") }); // rename single-package - m_clp.addOption({ qSL("logging-rule"), qSL("Adds a standard Qt logging rule."), qSL("rule") }); - m_clp.addOption({ qSL("qml-debug"), qSL("Enables QML debugging and profiling.") }); - m_clp.addOption({ qSL("enable-touch-emulation"), qSL("Deprecated (ignored).") }); - m_clp.addOption({ qSL("instance-id"), qSL("Use this id to distinguish between multiple instances."), qSL("id") }); + m_clp.addOption({ u"build-config"_s, u"Dumps the build configuration and exits."_s }); + + m_clp.addPositionalArgument(u"qml-file"_s, u"The main QML file."_s); + m_clp.addOption({ u"log-instant"_s, u"Log instantly at start-up, neglect logging configuration."_s }); + m_clp.addOption({ u"database"_s, u"Deprecated (ignored)."_s, u"file"_s }); + m_clp.addOption({ u"builtin-apps-manifest-dir"_s, u"Base directory for built-in application manifests."_s, u"dir"_s }); + m_clp.addOption({ u"installation-dir"_s, u"Base directory for package installations."_s, u"dir"_s }); + m_clp.addOption({ u"document-dir"_s, u"Base directory for per-package document directories."_s, u"dir"_s }); + m_clp.addOption({ u"installed-apps-manifest-dir"_s, u"Deprecated (ignored)."_s, u"dir"_s }); + m_clp.addOption({ u"app-image-mount-dir"_s, u"Deprecated (ignored)."_s, u"dir"_s }); + m_clp.addOption({ u"disable-installer"_s, u"Disable the application installer sub-system."_s }); + m_clp.addOption({ u"disable-intents"_s, u"Disable the intents sub-system."_s }); + m_clp.addOption({ u"dbus"_s, u"Register on the specified D-Bus."_s, u"<bus>|system|session|none|auto"_s, u"auto"_s }); + m_clp.addOption({ u"fullscreen"_s, u"Display in full-screen."_s }); + m_clp.addOption({ u"no-fullscreen"_s, u"Do not display in full-screen."_s }); + m_clp.addOption({ u"I"_s, u"Additional QML import path."_s, u"dir"_s }); + m_clp.addOption({ { u"v"_s, u"verbose"_s }, u"Verbose output."_s }); + m_clp.addOption({ u"slow-animations"_s, u"Run all animations in slow motion."_s }); + m_clp.addOption({ u"load-dummydata"_s, u"Deprecated. Loads QML dummy-data."_s }); + m_clp.addOption({ u"no-security"_s, u"Disables all security related checks (dev only!)"_s }); + m_clp.addOption({ u"development-mode"_s, u"Enable development mode, allowing installation of dev-signed packages."_s }); + m_clp.addOption({ u"no-ui-watchdog"_s, u"Disables detecting hung UI applications (e.g. via Wayland's ping/pong)."_s }); + m_clp.addOption({ u"no-dlt-logging"_s, u"Disables logging using automotive DLT."_s }); + m_clp.addOption({ u"force-single-process"_s, u"Forces single-process mode even on a wayland enabled build."_s }); + m_clp.addOption({ u"force-multi-process"_s, u"Forces multi-process mode. Will exit immediately if this is not possible."_s }); + m_clp.addOption({ u"wayland-socket-name"_s, u"Use this file name to create the wayland socket."_s, u"socket"_s }); + m_clp.addOption({ u"single-app"_s, u"Runs a single application only (ignores the database)"_s, u"info.yaml file"_s }); // rename single-package + m_clp.addOption({ u"logging-rule"_s, u"Adds a standard Qt logging rule."_s, u"rule"_s }); + m_clp.addOption({ u"qml-debug"_s, u"Enables QML debugging and profiling."_s }); + m_clp.addOption({ u"enable-touch-emulation"_s, u"Deprecated (ignored)."_s }); + m_clp.addOption({ u"instance-id"_s, u"Use this id to distinguish between multiple instances."_s, u"id"_s }); { // qmltestrunner specific, necessary for CI blacklisting - QCommandLineOption qtrsf { qSL("qmltestrunner-source-file"), qSL("appman-qmltestrunner only: set the source file path of the test."), qSL("file") }; + QCommandLineOption qtrsf { u"qmltestrunner-source-file"_s, u"appman-qmltestrunner only: set the source file path of the test."_s, u"file"_s }; qtrsf.setFlags(QCommandLineOption::HiddenFromHelp); m_clp.addOption(qtrsf); } @@ -204,13 +206,13 @@ void Configuration::parseWithArguments(const QStringList &arguments) if (!m_clp.parse(arguments)) throw Exception(m_clp.errorText()); - if (m_clp.isSet(qSL("version"))) + if (m_clp.isSet(u"version"_s)) m_clp.showVersion(); - if (m_clp.isSet(qSL("help"))) + if (m_clp.isSet(u"help"_s)) m_clp.showHelp(); - if (!m_buildConfigFilePath.isEmpty() && m_clp.isSet(qSL("build-config"))) { + if (!m_buildConfigFilePath.isEmpty() && m_clp.isSet(u"build-config"_s)) { QFile f(m_buildConfigFilePath); if (f.open(QFile::ReadOnly)) { ::fprintf(stdout, "%s\n", f.readAll().constData()); @@ -220,8 +222,8 @@ void Configuration::parseWithArguments(const QStringList &arguments) } } - if (m_clp.isSet(qSL("instance-id"))) { - auto id = m_clp.value(qSL("instance-id")); + if (m_clp.isSet(u"instance-id"_s)) { + auto id = m_clp.value(u"instance-id"_s); try { validateIdForFilesystemUsage(id); } catch (const Exception &e) { @@ -234,12 +236,12 @@ void Configuration::parseWithArguments(const QStringList &arguments) timer.start(); #endif - const QStringList rawConfigFilePaths = m_clp.values(qSL("config-file")); + const QStringList rawConfigFilePaths = m_clp.values(u"config-file"_s); QStringList configFilePaths; configFilePaths.reserve(rawConfigFilePaths.size()); for (const auto &path : rawConfigFilePaths) { if (QFileInfo(path).isDir()) { - const auto entries = QDir(path).entryInfoList({ qSL("*.yaml") }, QDir::Files, QDir::Name); + const auto entries = QDir(path).entryInfoList({ u"*.yaml"_s }, QDir::Files, QDir::Name); for (const auto &entry : entries) configFilePaths << entry.filePath(); } else { @@ -256,7 +258,7 @@ void Configuration::parseWithArguments(const QStringList &arguments) if (configFilePaths.isEmpty()) { m_data.reset(new ConfigurationData()); } else { - ConfigCache<ConfigurationData> cache(configFilePaths, qSL("config"), { 'C','F','G','D' }, + ConfigCache<ConfigurationData> cache(configFilePaths, u"config"_s, { 'C','F','G','D' }, ConfigurationData::dataStreamVersion(), cacheOptions); cache.parse(); @@ -265,14 +267,14 @@ void Configuration::parseWithArguments(const QStringList &arguments) m_data.reset(new ConfigurationData()); } - const QStringList options = m_clp.values(qSL("o")); + const QStringList options = m_clp.values(u"o"_s); for (const QString &option : options) { QByteArray yaml("formatVersion: 1\nformatType: am-configuration\n---\n"); yaml.append(option.toUtf8()); QBuffer buffer(&yaml); buffer.open(QIODevice::ReadOnly); try { - ConfigurationData *cd = ConfigCacheAdaptor<ConfigurationData>::loadFromSource(&buffer, qSL("command line")); + ConfigurationData *cd = ConfigCacheAdaptor<ConfigurationData>::loadFromSource(&buffer, u"command line"_s); if (cd) { ConfigCacheAdaptor<ConfigurationData>::merge(m_data.get(), cd); delete cd; @@ -295,10 +297,10 @@ void Configuration::parseWithArguments(const QStringList &arguments) for (const auto &iloc : ilocs) { QVariantMap map = iloc.toMap(); - QString id = map.value(qSL("id")).toString(); - if (id == qSL("internal-0")) { - m_installationDir = map.value(qSL("installationPath")).toString(); - m_documentDir = map.value(qSL("documentPath")).toString(); + QString id = map.value(u"id"_s).toString(); + if (id == u"internal-0") { + m_installationDir = map.value(u"installationPath"_s).toString(); + m_documentDir = map.value(u"documentPath"_s).toString(); qCWarning(LogDeployment) << " * still using installation location \"internal-0\" for backward " "compatibility"; } else { @@ -597,7 +599,7 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS try { YamlParser p(source->readAll(), fileName); auto header = p.parseHeader(); - if (!(header.first == qL1S("am-configuration") && header.second == 1)) + if (!(header.first == u"am-configuration" && header.second == 1)) throw Exception("Unsupported format type and/or version"); p.nextDocument(); @@ -619,13 +621,13 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS } }, { "runtimes", false, YamlParser::Map, [&cd](YamlParser *p) { cd->runtimes.configurations = p->parseMap(); - QVariant additionalLaunchers = cd->runtimes.configurations.take(qSL("additionalLaunchers")); + QVariant additionalLaunchers = cd->runtimes.configurations.take(u"additionalLaunchers"_s); cd->runtimes.additionalLaunchers = variantToStringList(additionalLaunchers); } }, { "containers", false, YamlParser::Map, [&cd](YamlParser *p) { cd->containers.configurations = p->parseMap(); - QVariant containerSelection = cd->containers.configurations.take(qSL("selection")); + QVariant containerSelection = cd->containers.configurations.take(u"selection"_s); QList<QPair<QString, QString>> config; @@ -636,7 +638,7 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS containerSelection = QVariantList { containerSelection }; if (containerSelection.metaType() == QMetaType::fromType<QString>()) { - config.append(qMakePair(qSL("*"), containerSelection.toString())); + config.append(qMakePair(u"*"_s, containerSelection.toString())); } else if (containerSelection.metaType() == QMetaType::fromType<QVariantList>()) { QVariantList list = containerSelection.toList(); for (const QVariant &v : list) { @@ -682,7 +684,7 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS cd->logging.dlt.description = p->parseScalar().toString(); } }, { "longMessageBehavior", false, YamlParser::Scalar, [&cd](YamlParser *p) { static const QStringList validValues { - qL1S("split"), qL1S("truncate"), qL1S("pass") + u"split"_s, u"truncate"_s, u"pass"_s }; QString s = p->parseScalar().toString().trimmed(); if (!s.isEmpty() && !validValues.contains(s)) { @@ -709,7 +711,7 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS // - a "<container-id>": mapping -> you can map to // - just a number -> the same count for any runtime in these containers // - a "<runtime-id>": mapping -> a specific count for this container/runtime combo - static const QString anyId = qSL("*"); + static const QString anyId = u"*"_s; if (p->isScalar()) { bool ok; @@ -779,11 +781,11 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS { "opengl", false, YamlParser::Map, [&cd](YamlParser *p) { p->parseFields({ { "desktopProfile", false, YamlParser::Scalar, [&cd](YamlParser *p) { - cd->ui.opengl.insert(qSL("desktopProfile"), p->parseScalar().toString()); } }, + cd->ui.opengl.insert(u"desktopProfile"_s, p->parseScalar().toString()); } }, { "esMajorVersion", false, YamlParser::Scalar, [&cd](YamlParser *p) { - cd->ui.opengl.insert(qSL("esMajorVersion"), p->parseScalar().toInt()); } }, + cd->ui.opengl.insert(u"esMajorVersion"_s, p->parseScalar().toInt()); } }, { "esMinorVersion", false, YamlParser::Scalar, [&cd](YamlParser *p) { - cd->ui.opengl.insert(qSL("esMinorVersion"), p->parseScalar().toInt()); } } + cd->ui.opengl.insert(u"esMinorVersion"_s, p->parseScalar().toInt()); } } }); } }, }); } }, @@ -833,13 +835,13 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS QVariantMap wes; p->parseFields({ { "path", true, YamlParser::Scalar, [&wes](YamlParser *p) { - wes.insert(qSL("path"), p->parseScalar().toString()); } }, + wes.insert(u"path"_s, p->parseScalar().toString()); } }, { "permissions", false, YamlParser::Scalar, [&wes](YamlParser *p) { - wes.insert(qSL("permissions"), p->parseScalar().toInt()); } }, + wes.insert(u"permissions"_s, p->parseScalar().toInt()); } }, { "userId", false, YamlParser::Scalar, [&wes](YamlParser *p) { - wes.insert(qSL("userId"), p->parseScalar().toInt()); } }, + wes.insert(u"userId"_s, p->parseScalar().toInt()); } }, { "groupId", false, YamlParser::Scalar, [&wes](YamlParser *p) { - wes.insert(qSL("groupId"), p->parseScalar().toInt()); } } + wes.insert(u"groupId"_s, p->parseScalar().toInt()); } } }); cd->wayland.extraSockets.append(wes); }); } } @@ -870,11 +872,11 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS const QString &ifaceName = it.key(); const QVariantMap &ifaceData = it.value().toMap(); - auto rit = ifaceData.constFind(qSL("register")); + auto rit = ifaceData.constFind(u"register"_s); if (rit != ifaceData.cend()) cd->dbus.registrations.insert(ifaceName, rit->toString()); - auto pit = ifaceData.constFind(qSL("policy")); + auto pit = ifaceData.constFind(u"policy"_s); if (pit != ifaceData.cend()) cd->dbus.policies.insert(ifaceName, pit->toMap()); } @@ -885,7 +887,7 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS return cd.release(); } catch (const Exception &e) { throw Exception(e.errorCode(), "Failed to parse config file %1: %2") - .arg(!fileName.isEmpty() ? QDir().relativeFilePath(fileName) : qSL("<stream>"), e.errorString()); + .arg(!fileName.isEmpty() ? QDir().relativeFilePath(fileName) : u"<stream>"_s, e.errorString()); } } @@ -1162,17 +1164,17 @@ QVariantMap Configuration::runtimeConfigurations() const QVariantMap Configuration::dbusPolicy(const char *interfaceName) const { - return m_data->dbus.policies.value(qL1S(interfaceName)).toMap(); + return m_data->dbus.policies.value(QString::fromLatin1(interfaceName)).toMap(); } QString Configuration::dbusRegistration(const char *interfaceName) const { - auto hasConfig = m_data->dbus.registrations.constFind(qL1S(interfaceName)); + auto hasConfig = m_data->dbus.registrations.constFind(QString::fromLatin1(interfaceName)); if (hasConfig != m_data->dbus.registrations.cend()) return hasConfig->toString(); else - return m_clp.value(qSL("dbus")); + return m_clp.value(u"dbus"_s); } QVariantMap Configuration::rawSystemProperties() const @@ -1202,7 +1204,7 @@ int Configuration::quickLaunchFailedStartLimitIntervalSec() const QString Configuration::waylandSocketName() const { - QString socketName = m_clp.value(qSL("wayland-socket-name")); // get the default value + QString socketName = m_clp.value(u"wayland-socket-name"_s); // get the default value if (!socketName.isEmpty()) return socketName; @@ -1211,9 +1213,9 @@ QString Configuration::waylandSocketName() const #if defined(Q_OS_LINUX) // modelled after wl_socket_lock() in wayland_server.c - const QString xdgDir = qEnvironmentVariable("XDG_RUNTIME_DIR") + qSL("/"); - const QString pattern = qSL("qtam-wayland-%1"); - const QString lockSuffix = qSL(".lock"); + const QString xdgDir = qEnvironmentVariable("XDG_RUNTIME_DIR") + u"/"_s; + const QString pattern = u"qtam-wayland-%1"_s; + const QString lockSuffix = u".lock"_s; for (int i = 0; i < 32; ++i) { socketName = pattern.arg(i); @@ -1259,7 +1261,7 @@ QStringList Configuration::pluginFilePaths(const char *type) const QStringList Configuration::testRunnerArguments() const { QStringList targs = m_clp.positionalArguments(); - if (!targs.isEmpty() && targs.constFirst().endsWith(qL1S(".qml"))) + if (!targs.isEmpty() && targs.constFirst().endsWith(u".qml")) targs.removeFirst(); targs.prepend(QCoreApplication::arguments().constFirst()); return targs; @@ -1267,7 +1269,7 @@ QStringList Configuration::testRunnerArguments() const QString Configuration::testRunnerSourceFile() const { - return m_clp.value(qSL("qmltestrunner-source-file")); + return m_clp.value(u"qmltestrunner-source-file"_s); } QT_END_NAMESPACE_AM diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp index 4b65eee8..695eaaef 100644 --- a/src/main-lib/main.cpp +++ b/src/main-lib/main.cpp @@ -96,6 +96,8 @@ #include "../plugin-interfaces/startupinterface.h" +using namespace Qt::StringLiterals; + AM_QML_REGISTER_TYPES(QtApplicationManager_SystemUI) AM_QML_REGISTER_TYPES(QtApplicationManager) @@ -115,28 +117,28 @@ static void registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, if (dbusName.isEmpty()) { return; - } else if (dbusName == qL1S("system")) { + } else if (dbusName == u"system") { dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SYSTEM_BUS_ADDRESS")); # if defined(Q_OS_LINUX) if (dbusAddress.isEmpty()) - dbusAddress = qL1S("unix:path=/var/run/dbus/system_bus_socket"); + dbusAddress = u"unix:path=/var/run/dbus/system_bus_socket"_s; # endif conn = QDBusConnection::systemBus(); - } else if (dbusName == qL1S("session")) { + } else if (dbusName == u"session") { dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SESSION_BUS_ADDRESS")); conn = QDBusConnection::sessionBus(); - } else if (dbusName == qL1S("auto")) { + } else if (dbusName == u"auto") { dbusAddress = QString::fromLocal8Bit(qgetenv("DBUS_SESSION_BUS_ADDRESS")); // we cannot be using QDBusConnection::sessionBus() here, because some plugin // might have called that function before we could spawn our own session bus. In // this case, Qt has cached the bus name and we would get the old one back. - conn = QDBusConnection::connectToBus(dbusAddress, qSL("qtam_session")); + conn = QDBusConnection::connectToBus(dbusAddress, u"qtam_session"_s); if (!conn.isConnected()) return; - dbusName = qL1S("session"); + dbusName = u"session"_s; } else { dbusAddress = dbusName; - conn = QDBusConnection::connectToBus(dbusAddress, qSL("custom")); + conn = QDBusConnection::connectToBus(dbusAddress, u"custom"_s); } if (!conn.isConnected()) { @@ -150,14 +152,14 @@ static void registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, adaptor->parent()->parent()->setProperty("_am_dbus_address", dbusAddress); } - if (!conn.registerObject(qL1S(path), adaptor->parent(), QDBusConnection::ExportAdaptors)) { + if (!conn.registerObject(QString::fromLatin1(path), adaptor->parent(), QDBusConnection::ExportAdaptors)) { throw Exception("could not register object %1 on D-Bus (%2): %3") - .arg(qL1S(path)).arg(dbusName).arg(conn.lastError().message()); + .arg(QString::fromLatin1(path)).arg(dbusName).arg(conn.lastError().message()); } - if (!conn.registerService(qL1S(serviceName))) { + if (!conn.registerService(QString::fromLatin1(serviceName))) { throw Exception("could not register service %1 on D-Bus (%2): %3") - .arg(qL1S(serviceName)).arg(dbusName).arg(conn.lastError().message()); + .arg(QString::fromLatin1(serviceName)).arg(dbusName).arg(conn.lastError().message()); } qCDebug(LogSystem).nospace().noquote() << " * " << serviceName << path << " [on bus: " << dbusName << "]"; @@ -166,14 +168,14 @@ static void registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, // Write the bus address of the interface to a file in /tmp. This is needed for the // controller tool, which does not even have a session bus, when started via ssh. - QString fileName = qL1S(interfaceName) % qSL(".dbus"); + QString fileName = QString::fromLatin1(interfaceName) % u".dbus"_s; if (!instanceId.isEmpty()) fileName = instanceId % u'-' % fileName; QFile f(QDir::temp().absoluteFilePath(fileName)); QByteArray dbusUtf8 = dbusAddress.isEmpty() ? dbusName.toUtf8() : dbusAddress.toUtf8(); if (!f.open(QFile::WriteOnly | QFile::Truncate) || (f.write(dbusUtf8) != dbusUtf8.size())) - throw Exception(f, "Could not write D-Bus address of interface %1").arg(qL1S(interfaceName)); + throw Exception(f, "Could not write D-Bus address of interface %1").arg(QString::fromLatin1(interfaceName)); static QStringList filesToDelete; if (filesToDelete.isEmpty()) @@ -212,7 +214,7 @@ Main::Main(int &argc, char **argv, InitFlags initFlags) #endif // this might be needed later on by the native runtime to find a suitable qml runtime launcher - setProperty("_am_build_dir", qSL(AM_BUILD_DIR)); + setProperty("_am_build_dir", QString::fromLatin1(AM_BUILD_DIR)); UnixSignalHandler::instance()->install(UnixSignalHandler::ForwardedToEventLoopHandler, { SIGINT, SIGTERM }, @@ -363,13 +365,13 @@ void Main::shutDown(int exitCode) QTimer::singleShot(5000, this, [exitCode] { QStringList resources; if (!(down & ApplicationManagerDown)) - resources << qSL("runtimes"); + resources << u"runtimes"_s; if (!(down & QuickLauncherDown)) - resources << qSL("quick-launchers"); + resources << u"quick-launchers"_s; if (!(down & WindowManagerDown)) - resources << qSL("windows"); + resources << u"windows"_s; qCCritical(LogSystem, "There are still resources in use (%s). Check your System UI implementation. " - "Exiting anyhow.", resources.join(qSL(", ")).toLocal8Bit().constData()); + "Exiting anyhow.", resources.join(u", "_s).toLocal8Bit().constData()); QCoreApplication::exit(exitCode); }); } @@ -401,7 +403,7 @@ void Main::registerResources(const QStringList &resources) const void Main::loadStartupPlugins(const QStringList &startupPluginPaths) Q_DECL_NOEXCEPT_EXPR(false) { QStringList systemStartupPluginPaths; - const QDir systemStartupPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + qSL("appman_startup")); + const QDir systemStartupPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + u"appman_startup"_s); for (const auto &pluginName : systemStartupPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { const QString filePath = systemStartupPluginDir.absoluteFilePath(pluginName); if (!QLibrary::isLibrary(filePath)) @@ -418,15 +420,15 @@ void Main::parseSystemProperties(const QVariantMap &rawSystemProperties) m_systemProperties.resize(SP_SystemUi + 1); QVariantMap rawMap = rawSystemProperties; - m_systemProperties[SP_ThirdParty] = rawMap.value(qSL("public")).toMap(); + m_systemProperties[SP_ThirdParty] = rawMap.value(u"public"_s).toMap(); m_systemProperties[SP_BuiltIn] = m_systemProperties.at(SP_ThirdParty); - const QVariantMap pro = rawMap.value(qSL("protected")).toMap(); + const QVariantMap pro = rawMap.value(u"protected"_s).toMap(); for (auto it = pro.cbegin(); it != pro.cend(); ++it) m_systemProperties[SP_BuiltIn].insert(it.key(), it.value()); m_systemProperties[SP_SystemUi] = m_systemProperties.at(SP_BuiltIn); - const QVariantMap pri = rawMap.value(qSL("private")).toMap(); + const QVariantMap pri = rawMap.value(u"private"_s).toMap(); for (auto it = pri.cbegin(); it != pri.cend(); ++it) m_systemProperties[SP_SystemUi].insert(it.key(), it.value()); @@ -474,12 +476,12 @@ void Main::setupRuntimesAndContainers(const QVariantMap &runtimeConfigurations, if (m_isSingleProcessMode) { RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager()); - RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(qSL("qml"))); + RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(u"qml"_s)); } else { RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager()); #if QT_CONFIG(am_multi_process) RuntimeFactory::instance()->registerRuntime(new NativeRuntimeManager()); - RuntimeFactory::instance()->registerRuntime(new NativeRuntimeManager(qSL("qml"))); + RuntimeFactory::instance()->registerRuntime(new NativeRuntimeManager(u"qml"_s)); for (const QString &runtimeId : runtimeAdditionalLaunchers) RuntimeFactory::instance()->registerRuntime(new NativeRuntimeManager(runtimeId)); @@ -490,7 +492,7 @@ void Main::setupRuntimesAndContainers(const QVariantMap &runtimeConfigurations, qCWarning(LogSystem) << "Addtional runtime launchers are ignored in single-process mode"; #endif QStringList systemContainerPluginPaths; - const QDir systemContainerPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + qSL("appman_container")); + const QDir systemContainerPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + u"appman_container"_s); for (const auto &pluginName : systemContainerPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { const QString filePath = systemContainerPluginDir.absoluteFilePath(pluginName); if (!QLibrary::isLibrary(filePath)) @@ -722,14 +724,14 @@ void Main::setupWindowManager(const QString &waylandSocketName, const QVariantLi for (const auto &v : waylandExtraSockets) { const QVariantMap &wes = v.toMap(); - const QString path = wes.value(qSL("path")).toString(); + const QString path = wes.value(u"path"_s).toString(); if (path.isEmpty()) continue; try { QFileInfo fi(path); - if (!fi.dir().mkpath(qSL("."))) + if (!fi.dir().mkpath(u"."_s)) throw Exception("could not create path to extra Wayland socket: %1").arg(path); auto sudo = SudoClient::instance(); @@ -748,9 +750,9 @@ void Main::setupWindowManager(const QString &waylandSocketName, const QVariantLi throw Exception("could not listen on extra Wayland socket %1: %2") .arg(path, extraSocket->errorString()); } - int mode = wes.value(qSL("permissions"), -1).toInt(); - int uid = wes.value(qSL("userId"), -1).toInt(); - int gid = wes.value(qSL("groupId"), -1).toInt(); + int mode = wes.value(u"permissions"_s, -1).toInt(); + int uid = wes.value(u"userId"_s, -1).toInt(); + int gid = wes.value(u"groupId"_s, -1).toInt(); QByteArray encodedPath = QFile::encodeName(path); @@ -881,7 +883,7 @@ void Main::showWindow(bool showFullscreen) #endif auto st = StartupTimer::instance(); st->checkFirstFrame(); - st->createAutomaticReport(qSL("System UI")); + st->createAutomaticReport(u"System UI"_s); } }); @@ -906,7 +908,7 @@ void Main::showWindow(bool showFullscreen) checkOpenGLFormat("first window", win->format()); } }); - StartupTimer::instance()->createAutomaticReport(qSL("System UI")); + StartupTimer::instance()->createAutomaticReport(u"System UI"_s); } } @@ -932,7 +934,7 @@ void Main::setupDBus(const std::function<QString(const char *)> &busForInterface int idx = adaptor->parent()->metaObject()->indexOfClassInfo("D-Bus Interface"); if (idx < 0) { throw Exception("Could not get class-info \"D-Bus Interface\" for D-Bus adapter %1") - .arg(qL1S(adaptor->parent()->metaObject()->className())); + .arg(QString::fromLatin1(adaptor->parent()->metaObject()->className())); } const char *interfaceName = adaptor->parent()->metaObject()->classInfo(idx).value(); ifaces.emplace_back(adaptor, busForInterface(interfaceName), service, path, interfaceName); @@ -953,9 +955,9 @@ void Main::setupDBus(const std::function<QString(const char *)> &busForInterface // check if all interfaces are on the "auto" bus and replace the "none" bus with nullptr for (auto &&iface : ifaces) { QString dbusName = std::get<1>(iface); - if (dbusName != qSL("auto")) + if (dbusName != u"auto"_s) autoOnly = false; - if (dbusName == qSL("none")) + if (dbusName == u"none") std::get<1>(iface).clear(); else noneOnly = false; @@ -989,7 +991,7 @@ void Main::setupDBus(const std::function<QString(const char *)> &busForInterface std::get<2>(iface),interfaceName, std::get<3>(iface), instanceId); if (!DBusPolicy::instance()->add(generatedAdaptor, policyForInterface(interfaceName))) - throw Exception(Error::DBus, "could not set DBus policy for %1").arg(qL1S(interfaceName)); + throw Exception(Error::DBus, "could not set DBus policy for %1").arg(QString::fromLatin1(interfaceName)); } } #else @@ -1005,7 +1007,7 @@ QString Main::hardwareId() const if (hardwareId.isEmpty()) { #if defined(QT_AM_HARDWARE_ID) hardwareId = QString::fromLocal8Bit(QT_AM_HARDWARE_ID); - if (hardwareId.startsWith(qL1C('@'))) { + if (hardwareId.startsWith(u'@')) { QFile f(hardwareId.mid(1)); hardwareId.clear(); if (f.open(QFile::ReadOnly)) @@ -1025,7 +1027,7 @@ QString Main::hardwareId() const std::sort(candidateIfaces.begin(), candidateIfaces.end(), [](const QNetworkInterface &first, const QNetworkInterface &second) { return first.name().compare(second.name()) < 0; }); - hardwareId = candidateIfaces.constFirst().hardwareAddress().replace(qL1C(':'), qL1S("-")); + hardwareId = candidateIfaces.constFirst().hardwareAddress().replace(u':', u'-'); } #endif } diff --git a/src/main-lib/packagemanageradaptor_dbus.cpp b/src/main-lib/packagemanageradaptor_dbus.cpp index f47a3b33..93f8fbae 100644 --- a/src/main-lib/packagemanageradaptor_dbus.cpp +++ b/src/main-lib/packagemanageradaptor_dbus.cpp @@ -12,6 +12,8 @@ #include "exception.h" #include "logging.h" +using namespace Qt::StringLiterals; + //NOTE: The header for this class is autogenerated from the XML interface definition. // We are NOT using the generated cpp, but instead implement the adaptor manually. @@ -52,19 +54,19 @@ PackageManagerAdaptor::PackageManagerAdaptor(QObject *parent) const QVariantMap &packageExtraMetaData, const QVariantMap &packageExtraSignedMetaData) { auto map = PackageManager::instance()->get(package); - map.remove(qSL("package")); // cannot marshall QObject * - map.remove(qSL("packageObject")); // cannot marshall QObject * + map.remove(u"package"_s); // cannot marshall QObject * + map.remove(u"packageObject"_s); // cannot marshall QObject * const auto apps = package->applications(); // these are QObject * (legacy API) QVariantList appList; appList.reserve(apps.size()); for (const auto *obj : apps) { QVariantMap app = ApplicationManager::instance()->get(obj->property("id").toString()); - app.remove(qSL("application")); // cannot marshall QObject * - app.remove(qSL("applicationObject")); // cannot marshall QObject * + app.remove(u"application"_s); // cannot marshall QObject * + app.remove(u"applicationObject"_s); // cannot marshall QObject * appList.append(app); } - map.insert(qSL("applications"), appList); + map.insert(u"applications"_s, appList); map = convertFromJSVariant(map).toMap(); emit taskRequestingInstallationAcknowledge(taskId, map, packageExtraMetaData, @@ -149,8 +151,8 @@ QVariantMap PackageManagerAdaptor::get(const QString &id) { QT_AM_AUTHENTICATE_DBUS(QVariantMap) auto map = PackageManager::instance()->get(id); - map.remove(qSL("package")); // cannot marshall QObject * - map.remove(qSL("packageObject")); // cannot marshall QObject * + map.remove(u"package"_s); // cannot marshall QObject * + map.remove(u"packageObject"_s); // cannot marshall QObject * return convertFromJSVariant(map).toMap(); } diff --git a/src/manager-lib/application.cpp b/src/manager-lib/application.cpp index 0e91625e..791ac0bb 100644 --- a/src/manager-lib/application.cpp +++ b/src/manager-lib/application.cpp @@ -453,9 +453,10 @@ QString Application::codeDir() const return packageInfo()->baseDir().absolutePath(); case Package::BeingInstalled: case Package::BeingUpdated: - return packageInfo()->baseDir().absolutePath() + QLatin1Char('+'); + case Package::BeingDowngraded: + return packageInfo()->baseDir().absolutePath() + u'+'; case Package::BeingRemoved: - return packageInfo()->baseDir().absolutePath() + QLatin1Char('-'); + return packageInfo()->baseDir().absolutePath() + u'-'; } } diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp index fa922b3f..8773f6d6 100644 --- a/src/manager-lib/applicationmanager.cpp +++ b/src/manager-lib/applicationmanager.cpp @@ -48,6 +48,8 @@ #include <memory> +using namespace Qt::StringLiterals; + /*! \qmltype ApplicationManager \inqmlmodule QtApplicationManager.SystemUI @@ -538,10 +540,10 @@ QVector<Application *> ApplicationManager::schemeHandlers(const QString &scheme) for (Application *app : d->apps) { const auto mimeTypes = app->supportedMimeTypes(); for (const QString &mime : mimeTypes) { - int pos = mime.indexOf(QLatin1Char('/')); + auto pos = mime.indexOf(u'/'); if ((pos > 0) - && (mime.left(pos) == qL1S("x-scheme-handler")) + && (mime.left(pos) == u"x-scheme-handler") && (mime.mid(pos + 1) == scheme)) { handlers << app; } @@ -565,14 +567,14 @@ void ApplicationManager::registerMimeTypes() { #if defined(QT_GUI_LIB) QSet<QString> schemes; - schemes << qSL("file") << qSL("http") << qSL("https"); + schemes << u"file"_s << u"http"_s << u"https"_s; for (Application *app : std::as_const(d->apps)) { const auto mimeTypes = app->supportedMimeTypes(); for (const QString &mime : mimeTypes) { - int pos = mime.indexOf(QLatin1Char('/')); + auto pos = mime.indexOf(u'/'); - if ((pos > 0) && (mime.left(pos) == qL1S("x-scheme-handler"))) + if ((pos > 0) && (mime.left(pos) == u"x-scheme-handler")) schemes << mime.mid(pos + 1); } } @@ -681,13 +683,13 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS if (!inProcess) { if (d->containerSelectionConfig.isEmpty()) { - containerId = qSL("process"); + containerId = u"process"_s; } else { // check config file for (const auto &it : std::as_const(d->containerSelectionConfig)) { const QString &key = it.first; const QString &value = it.second; - bool hasAsterisk = key.contains(qL1C('*')); + bool hasAsterisk = key.contains(u'*'); if ((hasAsterisk && key.length() == 1) || (!hasAsterisk && key == app->id()) @@ -722,7 +724,7 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS cannotUseQuickLaunch = "the app is started using a debug-wrapper"; else if (hasStdioRedirections) cannotUseQuickLaunch = "standard I/O is redirected"; - else if (!app->runtimeParameters().value(qSL("environmentVariables")).toMap().isEmpty()) + else if (!app->runtimeParameters().value(u"environmentVariables"_s).toMap().isEmpty()) cannotUseQuickLaunch = "the app requests custom environment variables"; else if (app->info()->openGLConfiguration() != runtimeManager->systemOpenGLConfiguration()) cannotUseQuickLaunch = "the app requests a custom OpenGL configuration"; @@ -1011,7 +1013,7 @@ bool ApplicationManager::openUrl(const QString &urlStr) if (url.isValid()) { QString scheme = url.scheme(); - if (scheme != qL1S("file")) + if (scheme != u"file") apps = schemeHandlers(scheme); if (apps.isEmpty()) { @@ -1221,7 +1223,7 @@ void ApplicationManager::emitDataChanged(Application *app, const QVector<int> &r if (isSignalConnected(appChanged)) { QStringList stringRoles; for (auto role : roles) - stringRoles << qL1S(d->roleNames[role]); + stringRoles << QString::fromLatin1(d->roleNames[role]); emit applicationChanged(app->id(), stringRoles); } } @@ -1324,7 +1326,7 @@ QVariantMap ApplicationManager::get(int index) const QVariantMap map; QHash<int, QByteArray> roles = roleNames(); for (auto it = roles.begin(); it != roles.end(); ++it) - map.insert(qL1S(it.value()), data(this->index(index), it.key())); + map.insert(QString::fromLatin1(it.value()), data(this->index(index), it.key())); return map; } diff --git a/src/manager-lib/asynchronoustask.cpp b/src/manager-lib/asynchronoustask.cpp index d750946f..03cccdd7 100644 --- a/src/manager-lib/asynchronoustask.cpp +++ b/src/manager-lib/asynchronoustask.cpp @@ -8,6 +8,8 @@ #include "global.h" #include "asynchronoustask.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM AsynchronousTask::AsynchronousTask(QObject *parent) @@ -60,7 +62,7 @@ bool AsynchronousTask::cancel() bool AsynchronousTask::forceCancel() { if (state() == Queued) { - setError(Error::Canceled, qSL("canceled")); + setError(Error::Canceled, u"canceled"_s); return true; } return cancel(); diff --git a/src/manager-lib/debugwrapper.cpp b/src/manager-lib/debugwrapper.cpp index 7dc79d96..0f9906b0 100644 --- a/src/manager-lib/debugwrapper.cpp +++ b/src/manager-lib/debugwrapper.cpp @@ -5,6 +5,8 @@ #include "debugwrapper.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM namespace DebugWrapper { @@ -20,8 +22,8 @@ bool parseSpecification(const QString &debugWrapperSpecification, QStringList &r bool escaped = false; bool canBeEnvVar = true; bool isEnvVar = false; - static const QString program = qSL("%program%"); - static const QString arguments = qSL("%arguments%"); + static const QString program = u"%program%"_s; + static const QString arguments = u"%arguments%"_s; int foundProgram = 0; int foundArguments = 0; QString str; @@ -42,7 +44,7 @@ bool parseSpecification(const QString &debugWrapperSpecification, QStringList &r if (isEnvVar && current == &str) current = &value; else - current->append(qL1C('=')); + current->append(u'='); break; case ' ': case '\0': @@ -69,9 +71,9 @@ bool parseSpecification(const QString &debugWrapperSpecification, QStringList &r } } else { switch (c.unicode()) { - case '\\': current->append(qL1C('\\')); break; - case ' ': current->append(qL1C(' ')); break; - case 'n': current->append(qL1C('\n')); break; + case '\\': current->append(u'\\'); break; + case ' ': current->append(u' '); break; + case 'n': current->append(u'\n'); break; default: return false; } escaped = false; @@ -95,16 +97,16 @@ bool parseSpecification(const QString &debugWrapperSpecification, QStringList &r QStringList substituteCommand(const QStringList &debugWrapperCommand, const QString &program, const QStringList &arguments) { - QString stringifiedArguments = arguments.join(qL1C(' ')); + QString stringifiedArguments = arguments.join(u' '); QStringList result; for (const QString &s : debugWrapperCommand) { - if (s == qSL("%arguments%")) { + if (s == u"%arguments%") { result << arguments; } else { QString str(s); - str.replace(qL1S("%program%"), program); - str.replace(qL1S("%arguments%"), stringifiedArguments); + str.replace(u"%program%"_s, program); + str.replace(u"%arguments%"_s, stringifiedArguments); result << str; } } diff --git a/src/manager-lib/deinstallationtask.cpp b/src/manager-lib/deinstallationtask.cpp index cbd71e77..3bce645d 100644 --- a/src/manager-lib/deinstallationtask.cpp +++ b/src/manager-lib/deinstallationtask.cpp @@ -12,6 +12,8 @@ #include "scopeutilities.h" #include "deinstallationtask.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM DeinstallationTask::DeinstallationTask(const QString &packageId, const QString &installationPath, @@ -24,7 +26,7 @@ DeinstallationTask::DeinstallationTask(const QString &packageId, const QString & { Q_UNUSED(forceDeinstallation) // this was used in the past to deal with SD-Card problems - setObjectName(qSL("QtAM-DeinstallationTask")); + setObjectName(u"QtAM-DeinstallationTask"_s); m_packageId = packageId; // in base class } @@ -102,8 +104,8 @@ void DeinstallationTask::execute() for (ScopedRenamer *toDelete : { &docDirRename, &appDirRename }) { if (toDelete->isRenamed()) { - if (!removeRecursiveHelper(toDelete->baseName() + qL1C('-'))) - qCCritical(LogInstaller) << "ERROR: could not remove" << (toDelete->baseName() + qL1C('-')); + if (!removeRecursiveHelper(toDelete->baseName() + u'-')) + qCCritical(LogInstaller) << "ERROR: could not remove" << (toDelete->baseName() + u'-'); } } diff --git a/src/manager-lib/installationtask.cpp b/src/manager-lib/installationtask.cpp index 8f9b7efa..92e3c50f 100644 --- a/src/manager-lib/installationtask.cpp +++ b/src/manager-lib/installationtask.cpp @@ -25,6 +25,9 @@ # include <unistd.h> #endif +using namespace Qt::StringLiterals; + + /* Overview of what happens on an installation of an app with <id> to <location>: @@ -99,7 +102,7 @@ InstallationTask::InstallationTask(const QString &installationPath, const QStrin , m_documentPath(documentPath) , m_sourceUrl(sourceUrl) { - setObjectName(qSL("QtAM-InstallationTask")); + setObjectName(u"QtAM-InstallationTask"_s); } InstallationTask::~InstallationTask() @@ -252,7 +255,7 @@ void InstallationTask::checkExtractedFile(const QString &file) Q_DECL_NOEXCEPT_E ++m_extractedFileCount; if (m_extractedFileCount == 1) { - if (file != qL1S("info.yaml")) + if (file != u"info.yaml") throw Exception(Error::Package, "info.yaml must be the first file in the package. Got %1") .arg(file); @@ -319,7 +322,7 @@ void InstallationTask::checkExtractedFile(const QString &file) Q_DECL_NOEXCEPT_E startInstallation(); - QFile::copy(oldDestinationDirectory.filePath(qSL("info.yaml")), m_extractionDir.filePath(qSL("info.yaml"))); + QFile::copy(oldDestinationDirectory.filePath(u"info.yaml"_s), m_extractionDir.filePath(u"info.yaml"_s)); QFile::copy(oldDestinationDirectory.filePath(m_iconFileName), m_extractionDir.filePath(m_iconFileName)); { @@ -361,8 +364,8 @@ void InstallationTask::startInstallation() Q_DECL_NOEXCEPT_EXPR(false) { // 2. delete old, partial installation - QDir installationDir = QString(m_installationPath + qL1C('/')); - QString installationTarget = m_packageId + qL1C('+'); + QDir installationDir = QString(m_installationPath + u'/'); + QString installationTarget = m_packageId + u'+'; if (installationDir.exists(installationTarget)) { if (!removeRecursiveHelper(installationDir.absoluteFilePath(installationTarget))) throw Exception("could not remove old, partial installation %1/%2").arg(installationDir).arg(installationTarget); @@ -390,7 +393,7 @@ void InstallationTask::finishInstallation() Q_DECL_NOEXCEPT_EXPR(false) // create the installation report InstallationReport report = m_extractor->installationReport(); - QFile reportFile(m_extractionDir.absoluteFilePath(qSL(".installation-report.yaml"))); + QFile reportFile(m_extractionDir.absoluteFilePath(u".installation-report.yaml"_s)); if (!reportFile.open(QFile::WriteOnly) || !report.serialize(&reportFile)) throw Exception(reportFile, "could not write the installation report"); reportFile.close(); @@ -431,7 +434,7 @@ void InstallationTask::finishInstallation() Q_DECL_NOEXCEPT_EXPR(false) // this should not be necessary, but it also won't hurt if (mode == Update) - removeRecursiveHelper(m_applicationDir.absolutePath() + qL1C('-')); + removeRecursiveHelper(m_applicationDir.absolutePath() + u'-'); #ifdef Q_OS_UNIX // write files to the filesystem diff --git a/src/manager-lib/intentaminterface.cpp b/src/manager-lib/intentaminterface.cpp index 9acb1564..cb9e2ca3 100644 --- a/src/manager-lib/intentaminterface.cpp +++ b/src/manager-lib/intentaminterface.cpp @@ -37,6 +37,8 @@ #include "packagemanager.h" #include "applicationinfo.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -151,7 +153,7 @@ void IntentServerAMImplementation::initialize(IntentServer *server) connect(nativeRuntime, &NativeRuntime::applicationConnectedToPeerDBus, intentServer(), [this](const QDBusConnection &connection, Application *application) { qCDebug(LogIntents) << "IntentServer: applicationConnectedToPeerDBus" - << (application ? application->id() : qSL("<launcher>")); + << (application ? application->id() : u"<launcher>"_s); IntentServerDBusIpcConnection::create(connection, application, this); }); @@ -270,7 +272,7 @@ void IntentClientAMImplementation::requestToSystem(QPointer<IntentClientRequest> QMetaObject::invokeMethod(m_ic, [icr, requestId, this]() { emit requestToSystemFinished(icr.data(), requestId, requestId.isNull(), - requestId.isNull() ? qL1S("No matching intent handler registered.") : QString()); + requestId.isNull() ? u"No matching intent handler registered."_s : QString()); }, Qt::QueuedConnection); }, Qt::QueuedConnection); } @@ -389,7 +391,7 @@ void IntentServerInProcessIpcConnection::requestToApplication(IntentServerReques // we need decouple the server/client interface at this point to have a consistent // behavior in single- and multi-process mode QMetaObject::invokeMethod(this, [this, requestId = isr->requestId(), intentId = isr->intentId(), - requestingApplicationId = isr->isBroadcast() ? qSL(":broadcast:") + requestingApplicationId = isr->isBroadcast() ? u":broadcast:"_s : isr->requestingApplicationId(), applicationId = isr->selectedIntent()->applicationId(), parameters = isr->parameters()]() { @@ -424,12 +426,12 @@ IntentServerDBusIpcConnection::IntentServerDBusIpcConnection(QDBusConnection con { m_connectionName = connection.name(); m_adaptor = new IntentInterfaceAdaptor(this); - connection.registerObject(qSL("/IntentServer"), this, QDBusConnection::ExportAdaptors); + connection.registerObject(u"/IntentServer"_s, this, QDBusConnection::ExportAdaptors); } IntentServerDBusIpcConnection::~IntentServerDBusIpcConnection() { - QDBusConnection(m_connectionName).unregisterObject(qSL("/IntentServer")); + QDBusConnection(m_connectionName).unregisterObject(u"/IntentServer"_s); } IntentServerDBusIpcConnection *IntentServerDBusIpcConnection::create(QDBusConnection connection, @@ -464,7 +466,7 @@ void IntentServerDBusIpcConnection::requestToApplication(IntentServerRequest *is // for broadcasts. QString requestIdStr = isr->requestId().toString(); if (isr->isBroadcast()) - requestIdStr.append(qSL("@broadcast")); + requestIdStr.append(u"@broadcast"_s); emit m_adaptor->requestToApplication(requestIdStr, isr->intentId(), isr->selectedIntent()->applicationId(), @@ -487,7 +489,7 @@ QString IntentServerDBusIpcConnection::requestToSystem(const QString &intentId, auto isr = m_interface->requestToSystem(requestingApplicationId, intentId, applicationId, convertFromDBusVariant(parameters).toMap()); if (!isr) { - sendErrorReply(QDBusError::NotSupported, qL1S("No matching intent handler registered.")); + sendErrorReply(QDBusError::NotSupported, u"No matching intent handler registered."_s); return QString(); } else { return isr->requestId().toString(); diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp index 3ae5beb5..51195712 100644 --- a/src/manager-lib/nativeruntime.cpp +++ b/src/manager-lib/nativeruntime.cpp @@ -32,6 +32,8 @@ #include "runtimeinterface_adaptor.h" #include "applicationinterface_adaptor.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM // You can enable this define to get all P2P-bus objects onto the session bus @@ -72,13 +74,13 @@ static qint64 getDBusPeerPid(const QDBusConnection &conn) NativeRuntime::NativeRuntime(AbstractContainer *container, Application *app, NativeRuntimeManager *manager) : AbstractRuntime(container, app, manager) , m_isQuickLauncher(app == nullptr) - , m_startedViaLauncher(manager->identifier() != qL1S("native")) + , m_startedViaLauncher(manager->identifier() != u"native") , m_dbusApplicationInterface(DBusContextAdaptor::create<ApplicationInterfaceAdaptor>(this)) , m_dbusRuntimeInterface(DBusContextAdaptor::create<RuntimeInterfaceAdaptor>(this)) { - QDir().mkdir(qSL("/tmp/dbus-qtam")); + QDir().mkdir(u"/tmp/dbus-qtam"_s); QString dbusAddress = QUuid::createUuid().toString().mid(1,36); - m_applicationInterfaceServer = new QDBusServer(qSL("unix:path=/tmp/dbus-qtam/dbus-qtam-") + dbusAddress, this); + m_applicationInterfaceServer = new QDBusServer(u"unix:path=/tmp/dbus-qtam/dbus-qtam-"_s + dbusAddress, this); m_applicationInterfaceServer->setAnonymousAuthenticationAllowed(true); connect(m_applicationInterfaceServer, &QDBusServer::newConnection, @@ -165,14 +167,14 @@ bool NativeRuntime::initialize() // try Qt's bin folder possibleLocations.append(QLibraryInfo::path(QLibraryInfo::BinariesPath)); // try the AM's build directory - possibleLocations.append(qApp->property("_am_build_dir").toString() + qSL("/bin")); // set by main.cpp + possibleLocations.append(qApp->property("_am_build_dir").toString() + u"/bin"_s); // set by main.cpp // if everything fails, try to locate it in $PATH const auto paths = qgetenv("PATH").split(QDir::listSeparator().toLatin1()); for (const auto &path : paths) possibleLocations.append(QString::fromLocal8Bit(path)); } - const QString launcherName = qSL("/appman-launcher-") + manager()->identifier(); + const QString launcherName = u"/appman-launcher-"_s + manager()->identifier(); for (const QString &possibleLocation : possibleLocations) { QFileInfo fi(possibleLocation + launcherName); @@ -260,22 +262,22 @@ bool NativeRuntime::start() } QVariantMap dbusConfig = { - { qSL("p2p"), applicationInterfaceServer()->address() }, - { qSL("org.freedesktop.Notifications"), NotificationManager::instance()->property("_am_dbus_name").toString()} + { u"p2p"_s, applicationInterfaceServer()->address() }, + { u"org.freedesktop.Notifications"_s, NotificationManager::instance()->property("_am_dbus_name").toString()} }; QVariantMap loggingConfig = { - { qSL("dlt"), Logging::isDltEnabled() }, - { qSL("rules"), Logging::filterRules() }, - { qSL("useAMConsoleLogger"), Logging::useAMConsoleLogger() } + { u"dlt"_s, Logging::isDltEnabled() }, + { u"rules"_s, Logging::filterRules() }, + { u"useAMConsoleLogger"_s, Logging::useAMConsoleLogger() } }; if (Logging::isDltEnabled()) - loggingConfig.insert(qSL("dltLongMessageBehavior"), Logging::dltLongMessageBehavior()); + loggingConfig.insert(u"dltLongMessageBehavior"_s, Logging::dltLongMessageBehavior()); QVariantMap uiConfig; if (m_slowAnimations) - uiConfig.insert(qSL("slowAnimations"), true); + uiConfig.insert(u"slowAnimations"_s, true); QVariantMap openGLConfig; if (m_app) @@ -283,36 +285,36 @@ bool NativeRuntime::start() if (openGLConfig.isEmpty()) openGLConfig = manager()->systemOpenGLConfiguration(); if (!openGLConfig.isEmpty()) - uiConfig.insert(qSL("opengl"), openGLConfig); + uiConfig.insert(u"opengl"_s, openGLConfig); QString iconThemeName = manager()->iconThemeName(); QStringList iconThemeSearchPaths = manager()->iconThemeSearchPaths(); if (!iconThemeName.isEmpty()) - uiConfig.insert(qSL("iconThemeName"), iconThemeName); + uiConfig.insert(u"iconThemeName"_s, iconThemeName); if (!iconThemeSearchPaths.isEmpty()) - uiConfig.insert(qSL("iconThemeSearchPaths"), iconThemeSearchPaths); + uiConfig.insert(u"iconThemeSearchPaths"_s, iconThemeSearchPaths); QVariantMap config = { - { qSL("logging"), loggingConfig }, - { qSL("baseDir"), QDir::currentPath() }, - { qSL("runtimeConfiguration"), configuration() }, - { qSL("securityToken"), qL1S(securityToken().toHex()) }, - { qSL("dbus"), dbusConfig } + { u"logging"_s, loggingConfig }, + { u"baseDir"_s, QDir::currentPath() }, + { u"runtimeConfiguration"_s, configuration() }, + { u"securityToken"_s, QString::fromLatin1(securityToken().toHex()) }, + { u"dbus"_s, dbusConfig } }; if (!m_startedViaLauncher && !m_isQuickLauncher) - config.insert(qSL("systemProperties"), systemProperties()); + config.insert(u"systemProperties"_s, systemProperties()); if (m_app) - config.insert(qSL("application"), convertFromJSVariant(m_app->info()->toVariantMap()).toMap()); + config.insert(u"application"_s, convertFromJSVariant(m_app->info()->toVariantMap()).toMap()); if (!uiConfig.isEmpty()) - config.insert(qSL("ui"), uiConfig); + config.insert(u"ui"_s, uiConfig); QMap<QString, QString> env = { - { qSL("QT_QPA_PLATFORM"), qSL("wayland") }, - { qSL("QT_IM_MODULE"), QString() }, // Applications should use wayland text input - { qSL("QT_SCALE_FACTOR"), QString() }, // do not scale wayland clients - { qSL("AM_CONFIG"), QString::fromUtf8(QtYaml::yamlFromVariantDocuments({ config })) }, - { qSL("QT_WAYLAND_SHELL_INTEGRATION"), qSL("xdg-shell")}, + { u"QT_QPA_PLATFORM"_s, u"wayland"_s }, + { u"QT_IM_MODULE"_s, QString() }, // Applications should use wayland text input + { u"QT_SCALE_FACTOR"_s, QString() }, // do not scale wayland clients + { u"AM_CONFIG"_s, QString::fromUtf8(QtYaml::yamlFromVariantDocuments({ config })) }, + { u"QT_WAYLAND_SHELL_INTEGRATION"_s, u"xdg-shell"_s}, }; for (const auto *var : { @@ -324,17 +326,17 @@ bool NativeRuntime::start() if (!Logging::isDltEnabled()) { // we need this to disable DLT as soon as possible - env.insert(qSL("AM_NO_DLT_LOGGING"), qSL("1")); + env.insert(u"AM_NO_DLT_LOGGING"_s, u"1"_s); } - const auto envVars = configuration().value(qSL("environmentVariables")).toMap(); + const auto envVars = configuration().value(u"environmentVariables"_s).toMap(); for (auto it = envVars.cbegin(); it != envVars.cend(); ++it) { if (!it.key().isEmpty()) env.insert(it.key(), it.value().toString()); } if (m_app) { - const auto envVars = m_app->runtimeParameters().value(qSL("environmentVariables")).toMap(); + const auto envVars = m_app->runtimeParameters().value(u"environmentVariables"_s).toMap(); if (!envVars.isEmpty()) { if (ApplicationManager::instance()->securityChecksEnabled()) { @@ -352,16 +354,16 @@ bool NativeRuntime::start() QStringList args; if (!m_startedViaLauncher) { - args.append(variantToStringList(m_app->runtimeParameters().value(qSL("arguments")))); + args.append(variantToStringList(m_app->runtimeParameters().value(u"arguments"_s))); if (!m_document.isNull()) - args << qSL("--start-argument") << m_document; + args << u"--start-argument"_s << m_document; if (!Logging::isDltEnabled()) - args << qSL("--no-dlt-logging"); + args << u"--no-dlt-logging"_s; } else { if (m_isQuickLauncher) - args << qSL("--quicklaunch"); + args << u"--quicklaunch"_s; args << QString::fromLocal8Bit(ProcessTitle::placeholderArgument); // must be last argument } @@ -399,7 +401,7 @@ void NativeRuntime::stop(bool forceKill) m_process->terminate(); } else { bool ok; - int qt = configuration().value(qSL("quitTime")).toInt(&ok); + int qt = configuration().value(u"quitTime"_s).toInt(&ok); if (!ok || qt < 0) qt = 250; QTimer::singleShot(qt, this, [this]() { @@ -438,23 +440,23 @@ void NativeRuntime::onDBusPeerConnection(const QDBusConnection &connection) m_dbusConnectionName = connection.name(); QDBusConnection conn = connection; - if (!m_dbusApplicationInterface->registerOnDBus(conn, qSL("/ApplicationInterface"))) { + if (!m_dbusApplicationInterface->registerOnDBus(conn, u"/ApplicationInterface"_s)) { qCWarning(LogSystem) << "ERROR: could not register the /ApplicationInterface object on the peer DBus:" << conn.lastError().message(); } #ifdef EXPORT_P2PBUS_OBJECTS_TO_SESSION_BUS - m_dbusApplicationInterface->registerOnDBus(QDBusConnection::sessionBus(), qSL("/Application%1/ApplicationInterface").arg(applicationProcessId())); + m_dbusApplicationInterface->registerOnDBus(QDBusConnection::sessionBus(), u"/Application%1/ApplicationInterface"_s.arg(applicationProcessId())); #endif if (m_startedViaLauncher) { - if (!m_dbusRuntimeInterface->registerOnDBus(conn, qSL("/RuntimeInterface"))) { + if (!m_dbusRuntimeInterface->registerOnDBus(conn, u"/RuntimeInterface"_s)) { qCWarning(LogSystem) << "ERROR: could not register the /RuntimeInterface object on the peer DBus:" << conn.lastError().message(); } #ifdef EXPORT_P2PBUS_OBJECTS_TO_SESSION_BUS - m_dbusRuntimeInterface->registerOnDBus(QDBusConnection::sessionBus(), qSL("/Application%1/RuntimeInterface").arg(applicationProcessId())); + m_dbusRuntimeInterface->registerOnDBus(QDBusConnection::sessionBus(), u"/Application%1/RuntimeInterface"_s.arg(applicationProcessId())); #endif } // the server side of the p2p bus can be setup now, but the client is not able service any @@ -529,12 +531,12 @@ NativeRuntimeManager::NativeRuntimeManager(const QString &id, QObject *parent) QString NativeRuntimeManager::defaultIdentifier() { - return qSL("native"); + return u"native"_s; } bool NativeRuntimeManager::supportsQuickLaunch() const { - return identifier() != qL1S("native"); + return identifier() != u"native"; } AbstractRuntime *NativeRuntimeManager::create(AbstractContainer *container, Application *app) diff --git a/src/manager-lib/notificationmanager.cpp b/src/manager-lib/notificationmanager.cpp index 49474f28..13fea82a 100644 --- a/src/manager-lib/notificationmanager.cpp +++ b/src/manager-lib/notificationmanager.cpp @@ -19,6 +19,8 @@ #include "notificationmodel.h" #include "qmlinprocnotificationimpl.h" +using namespace Qt::StringLiterals; + /*! \qmltype NotificationManager \inqmlmodule QtApplicationManager.SystemUI @@ -321,14 +323,14 @@ QVariant NotificationManager::data(const QModelIndex &index, int role) const return n->showActionIcons; case NMRoles::Actions: { QVariantList actions = n->actions; - actions.removeAll(QVariantMap { { qSL("default"), QString() } }); + actions.removeAll(QVariantMap { { u"default"_s, QString() } }); return actions; } case NMRoles::DismissOnAction: return n->dismissOnAction; case NMRoles::IsClickable: // legacy case NMRoles::IsAcknowledgeable: - return n->actions.contains(QVariantMap { { qSL("default"), QString() } }); + return n->actions.contains(QVariantMap { { u"default"_s, QString() } }); case NMRoles::IsSystemNotification: return n->isSystemNotification; case NMRoles::IsShowingProgress: @@ -379,7 +381,7 @@ QVariantMap NotificationManager::get(int index) const QVariantMap map; QHash<int, QByteArray> roles = roleNames(); for (auto it = roles.begin(); it != roles.end(); ++it) - map.insert(qL1S(it.value()), data(QAbstractListModel::index(index), it.key())); + map.insert(QString::fromLatin1(it.value()), data(QAbstractListModel::index(index), it.key())); return map; } @@ -416,7 +418,7 @@ int NotificationManager::indexOfNotification(uint id) const */ void NotificationManager::acknowledgeNotification(uint id) { - triggerNotificationAction(id, qSL("default")); + triggerNotificationAction(id, u"default"_s); } /*! @@ -452,7 +454,7 @@ void NotificationManager::triggerNotificationAction(uint id, const QString &acti } if (!found) { qCDebug(LogNotifications) << "Requested to trigger a notification action, but the action is not registered:" - << (actionId.length() > 20 ? (actionId.left(20) + qSL("...")) : actionId); + << (actionId.length() > 20 ? (actionId.left(20) + u"..."_s) : actionId); } emit ActionInvoked(id, actionId); @@ -481,8 +483,8 @@ QString NotificationManager::GetServerInformation(QString &vendor, QString &vers { //qCDebug(LogNotifications) << "GetServerInformation"; vendor = qApp->organizationName(); - version = qSL("1.0"); - spec_version = qSL("1.2"); + version = u"1.0"_s; + spec_version = u"1.2"_s; return qApp->applicationName(); } @@ -492,14 +494,14 @@ QString NotificationManager::GetServerInformation(QString &vendor, QString &vers QStringList NotificationManager::GetCapabilities() { //qCDebug(LogNotifications) << "GetCapabilities"; - return QStringList() << qSL("action-icons") - << qSL("actions") - << qSL("body") - << qSL("body-hyperlinks") - << qSL("body-images") - << qSL("body-markup") - << qSL("icon-static") - << qSL("persistence"); + return QStringList() << u"action-icons"_s + << u"actions"_s + << u"body"_s + << u"body-hyperlinks"_s + << u"body-images"_s + << u"body-markup"_s + << u"icon-static"_s + << u"persistence"_s; } /*! \internal @@ -557,29 +559,29 @@ uint NotificationManager::notifyHelper(const QString &app_name, uint id, bool re return 0; } n->application = app; - n->priority = hints.value(qSL("urgency"), QVariant(0)).toUInt(); + n->priority = hints.value(u"urgency"_s, QVariant(0)).toUInt(); n->summary = summary; n->body = body; - n->category = hints.value(qSL("category")).toString(); + n->category = hints.value(u"category"_s).toString(); n->iconUrl = app_icon; - if (hints.contains(qSL("image-data"))) { + if (hints.contains(u"image-data"_s)) { //TODO: how can we parse this - the dbus sig of value is "(iiibiiay)" - } else if (hints.contains(qSL("image-path"))) { - n->imageUrl = hints.value(qSL("image-path")).toString(); + } else if (hints.contains(u"image-path"_s)) { + n->imageUrl = hints.value(u"image-path"_s).toString(); } - n->showActionIcons = hints.value(qSL("action-icons")).toBool(); + n->showActionIcons = hints.value(u"action-icons"_s).toBool(); n->actions.clear(); for (int ai = 0; ai != (actions.size() & ~1); ai += 2) n->actions.append(QVariantMap { { actions.at(ai), actions.at(ai + 1) } }); - n->dismissOnAction = !hints.value(qSL("resident")).toBool(); + n->dismissOnAction = !hints.value(u"resident"_s).toBool(); - n->isSystemNotification = hints.value(qSL("x-pelagicore-system-notification")).toBool(); - n->isShowingProgress = hints.value(qSL("x-pelagicore-show-progress")).toBool(); - n->progress = hints.value(qSL("x-pelagicore-progress")).toReal(); + n->isSystemNotification = hints.value(u"x-pelagicore-system-notification"_s).toBool(); + n->isShowingProgress = hints.value(u"x-pelagicore-show-progress"_s).toBool(); + n->progress = hints.value(u"x-pelagicore-progress"_s).toReal(); n->timeout = qMax(0, timeout); - n->extended = convertFromDBusVariant(hints.value(qSL("x-pelagicore-extended"))).toMap(); + n->extended = convertFromDBusVariant(hints.value(u"x-pelagicore-extended"_s)).toMap(); if (replaces) { QModelIndex idx = index(int(d->notifications.indexOf(n)), 0); diff --git a/src/manager-lib/packagemanager.cpp b/src/manager-lib/packagemanager.cpp index 6e5384f5..a816ea60 100644 --- a/src/manager-lib/packagemanager.cpp +++ b/src/manager-lib/packagemanager.cpp @@ -39,6 +39,9 @@ #include <memory> +using namespace Qt::StringLiterals; + + /*! \qmltype PackageManager \inqmlmodule QtApplicationManager.SystemUI @@ -498,7 +501,7 @@ QVariantMap PackageManager::get(Package *package) const if (package) { QHash<int, QByteArray> roles = roleNames(); for (auto it = roles.begin(); it != roles.end(); ++it) - map.insert(qL1S(it.value()), dataForRole(package, it.key())); + map.insert(QString::fromLatin1(it.value()), dataForRole(package, it.key())); } return map; } @@ -513,7 +516,7 @@ void PackageManager::emitDataChanged(Package *package, const QVector<int> &roles if (isSignalConnected(pkgChanged)) { QStringList stringRoles; for (auto role : roles) - stringRoles << qL1S(s_roleNames[role]); + stringRoles << QString::fromLatin1(s_roleNames[role]); emit packageChanged(package->id(), stringRoles); } } @@ -770,9 +773,9 @@ static QVariantMap locationMap(const QString &path) return QVariantMap { - { qSL("path"), path }, - { qSL("deviceSize"), bytesTotal }, - { qSL("deviceFree"), bytesFree } + { u"path"_s, path }, + { u"deviceSize"_s, bytesTotal }, + { u"deviceFree"_s, bytesFree } }; } @@ -860,8 +863,8 @@ void PackageManager::cleanupBrokenInstallations() Q_DECL_NOEXCEPT_EXPR(false) QStringList checkDirs; QStringList checkFiles; - checkFiles << pkgDir + qSL("/info.yaml"); - checkFiles << pkgDir + qSL("/.installation-report.yaml"); + checkFiles << pkgDir + u"/info.yaml"_s; + checkFiles << pkgDir + u"/.installation-report.yaml"_s; checkDirs << pkgDir; for (const QString &checkFile : std::as_const(checkFiles)) { @@ -1412,7 +1415,7 @@ bool PackageManager::finishedPackageInstall(const QString &id) // attach the installation report (unless we're just downgrading a built-in) if (!isDowngrade) { - QFile irfile(newPackageInfo->baseDir().absoluteFilePath(qSL(".installation-report.yaml"))); + QFile irfile(newPackageInfo->baseDir().absoluteFilePath(u".installation-report.yaml"_s)); auto ir = std::make_unique<InstallationReport>(package->id()); irfile.open(QFile::ReadOnly); try { @@ -1564,7 +1567,7 @@ bool PackageManager::validateDnsName(const QString &name, int minimalPartCount) { try { // check if we have enough parts: e.g. "tld.company.app" would have 3 parts - QStringList parts = name.split(qL1C('.')); + QStringList parts = name.split(u'.'); if (parts.size() < minimalPartCount) { throw Exception(Error::Parse, "the minimum amount of parts (subdomains) is %1 (found %2)") .arg(minimalPartCount).arg(parts.size()); diff --git a/src/manager-lib/plugincontainer.cpp b/src/manager-lib/plugincontainer.cpp index 2c1ac6a1..25fa76a8 100644 --- a/src/manager-lib/plugincontainer.cpp +++ b/src/manager-lib/plugincontainer.cpp @@ -10,6 +10,8 @@ #include "debugwrapper.h" #include "sudo.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM PluginContainerManager::PluginContainerManager(ContainerManagerInterface *managerInterface, QObject *parent) @@ -31,7 +33,7 @@ bool PluginContainerManager::initialize() QString PluginContainerManager::defaultIdentifier() { - return qSL("invalid-plugin"); + return u"invalid-plugin"_s; } bool PluginContainerManager::supportsQuickLaunch() const diff --git a/src/manager-lib/processcontainer.cpp b/src/manager-lib/processcontainer.cpp index b0d53dd8..236a073f 100644 --- a/src/manager-lib/processcontainer.cpp +++ b/src/manager-lib/processcontainer.cpp @@ -21,6 +21,9 @@ # include <fcntl.h> #endif +using namespace Qt::StringLiterals; + + QT_BEGIN_NAMESPACE_AM @@ -161,7 +164,7 @@ bool ProcessContainer::setControlGroup(const QString &groupName) if (groupName == m_currentControlGroup) return true; - QVariantMap map = m_manager->configuration().value(qSL("controlGroups")).toMap(); + QVariantMap map = m_manager->configuration().value(u"controlGroups"_s).toMap(); auto git = map.constFind(groupName); if (git != map.constEnd()) { QVariantMap mapping = (*git).toMap(); @@ -174,7 +177,7 @@ bool ProcessContainer::setControlGroup(const QString &groupName) //qWarning() << "Setting cgroup for" << m_program << ", pid" << m_process->processId() << ":" << resource << "->" << userclass; - QString file = QString(qSL("/sys/fs/cgroup/%1/%2/cgroup.procs")).arg(resource, userclass); + QString file = QString(u"/sys/fs/cgroup/%1/%2/cgroup.procs"_s).arg(resource, userclass); QFile f(file); bool ok = f.open(QFile::WriteOnly); ok = ok && (f.write(pidString) == pidString.size()); @@ -184,7 +187,7 @@ bool ProcessContainer::setControlGroup(const QString &groupName) return false; } - if (resource == qSL("memory")) { + if (resource == u"memory") { if (!m_memWatcher) { m_memWatcher = new MemoryWatcher(this); connect(m_memWatcher, &MemoryWatcher::memoryLow, @@ -240,7 +243,7 @@ AbstractContainerProcess *ProcessContainer::start(const QStringList &arguments, HostProcess *process = new HostProcess(); process->setWorkingDirectory(m_baseDirectory); process->setProcessEnvironment(penv); - process->setStopBeforeExec(configuration().value(qSL("stopBeforeExec")).toBool()); + process->setStopBeforeExec(configuration().value(u"stopBeforeExec"_s).toBool()); process->setStdioRedirections(std::move(m_stdioRedirections)); QString command = m_program; @@ -257,7 +260,7 @@ AbstractContainerProcess *ProcessContainer::start(const QStringList &arguments, process->start(command, args); m_process = process; - setControlGroup(configuration().value(qSL("defaultControlGroup")).toString()); + setControlGroup(configuration().value(u"defaultControlGroup"_s).toString()); return process; } @@ -271,7 +274,7 @@ ProcessContainerManager::ProcessContainerManager(const QString &id, QObject *par QString ProcessContainerManager::defaultIdentifier() { - return qSL("process"); + return u"process"_s; } bool ProcessContainerManager::supportsQuickLaunch() const diff --git a/src/manager-lib/processstatus.cpp b/src/manager-lib/processstatus.cpp index 1382e0f2..49447245 100644 --- a/src/manager-lib/processstatus.cpp +++ b/src/manager-lib/processstatus.cpp @@ -16,6 +16,9 @@ #include <limits> +using namespace Qt::StringLiterals; + + /*! \qmltype ProcessStatus \inqmlmodule QtApplicationManager.SystemUI @@ -109,7 +112,7 @@ ProcessStatus::ProcessStatus(QObject *parent) { if (m_instanceCount == 0) { m_workerThread = new QThread; - m_workerThread->setObjectName(qSL("QtAM-ProcessStatus")); + m_workerThread->setObjectName(u"QtAM-ProcessStatus"_s); m_workerThread->start(); } ++m_instanceCount; @@ -254,15 +257,15 @@ void ProcessStatus::fetchReadings() m_cpuLoad = m_reader->cpuLoad; // Although smaps claims to report kB it's actually KiB (2^10 = 1024 Bytes) - m_memoryVirtual[qSL("total")] = static_cast<quint64>(m_reader->memory.totalVm) << 10; - m_memoryVirtual[qSL("text")] = static_cast<quint64>(m_reader->memory.textVm) << 10; - m_memoryVirtual[qSL("heap")] = static_cast<quint64>(m_reader->memory.heapVm) << 10; - m_memoryRss[qSL("total")] = static_cast<quint64>(m_reader->memory.totalRss) << 10; - m_memoryRss[qSL("text")] = static_cast<quint64>(m_reader->memory.textRss) << 10; - m_memoryRss[qSL("heap")] = static_cast<quint64>(m_reader->memory.heapRss) << 10; - m_memoryPss[qSL("total")] = static_cast<quint64>(m_reader->memory.totalPss) << 10; - m_memoryPss[qSL("text")] = static_cast<quint64>(m_reader->memory.textPss) << 10; - m_memoryPss[qSL("heap")] = static_cast<quint64>(m_reader->memory.heapPss) << 10; + m_memoryVirtual[u"total"_s] = static_cast<quint64>(m_reader->memory.totalVm) << 10; + m_memoryVirtual[u"text"_s] = static_cast<quint64>(m_reader->memory.textVm) << 10; + m_memoryVirtual[u"heap"_s] = static_cast<quint64>(m_reader->memory.heapVm) << 10; + m_memoryRss[u"total"_s] = static_cast<quint64>(m_reader->memory.totalRss) << 10; + m_memoryRss[u"text"_s] = static_cast<quint64>(m_reader->memory.textRss) << 10; + m_memoryRss[u"heap"_s] = static_cast<quint64>(m_reader->memory.heapRss) << 10; + m_memoryPss[u"total"_s] = static_cast<quint64>(m_reader->memory.totalPss) << 10; + m_memoryPss[u"text"_s] = static_cast<quint64>(m_reader->memory.textPss) << 10; + m_memoryPss[u"heap"_s] = static_cast<quint64>(m_reader->memory.heapPss) << 10; } /*! @@ -352,7 +355,7 @@ void ProcessStatus::setMemoryReportingEnabled(bool enabled) */ QStringList ProcessStatus::roleNames() const { - return { qSL("cpuLoad"), qSL("memoryVirtual"), qSL("memoryRss"), qSL("memoryPss") }; + return { u"cpuLoad"_s, u"memoryVirtual"_s, u"memoryRss"_s, u"memoryPss"_s }; } #include "moc_processstatus.cpp" diff --git a/src/manager-lib/qmlinprocnotificationimpl.cpp b/src/manager-lib/qmlinprocnotificationimpl.cpp index 68926959..b60a1c47 100644 --- a/src/manager-lib/qmlinprocnotificationimpl.cpp +++ b/src/manager-lib/qmlinprocnotificationimpl.cpp @@ -12,6 +12,8 @@ #include "notification.h" #include "notificationmanager.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -30,7 +32,7 @@ void QmlInProcNotificationImpl::componentComplete() { QQmlContext *ctxt = QQmlEngine::contextForObject(notification()); if (ctxt) { - QQmlExpression expr(ctxt, nullptr, qSL("ApplicationInterface.applicationId"), nullptr); + QQmlExpression expr(ctxt, nullptr, u"ApplicationInterface.applicationId"_s, nullptr); QVariant v = expr.evaluate(); if (!v.isNull()) m_applicationId = v.toString(); diff --git a/src/manager-lib/qmlinprocruntime.cpp b/src/manager-lib/qmlinprocruntime.cpp index 1ec708fa..56dfbc8a 100644 --- a/src/manager-lib/qmlinprocruntime.cpp +++ b/src/manager-lib/qmlinprocruntime.cpp @@ -28,6 +28,8 @@ #include "utilities.h" #include "qml-utilities.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -62,25 +64,25 @@ bool QmlInProcRuntime::start() const QString currentDir = QDir::currentPath() + QDir::separator(); const QString codeDir = m_app->codeDir() + QDir::separator(); - loadResources(variantToStringList(configuration().value(qSL("resources"))), currentDir); - loadResources(variantToStringList(m_app->runtimeParameters().value(qSL("resources"))), codeDir); + loadResources(variantToStringList(configuration().value(u"resources"_s)), currentDir); + loadResources(variantToStringList(m_app->runtimeParameters().value(u"resources"_s)), codeDir); - if (m_app->runtimeParameters().value(qSL("loadDummyData")).toBool()) { + if (m_app->runtimeParameters().value(u"loadDummyData"_s).toBool()) { qCWarning(LogDeployment) << "Loading dummy data is deprecated and will be removed soon"; qCDebug(LogSystem) << "Loading dummy-data"; loadQmlDummyDataFiles(m_inProcessQmlEngine, QFileInfo(m_app->info()->absoluteCodeFilePath()).path()); } - const QStringList configPluginPaths = variantToStringList(configuration().value(qSL("pluginPaths"))); - const QStringList runtimePluginPaths = variantToStringList(m_app->runtimeParameters().value(qSL("pluginPaths"))); + const QStringList configPluginPaths = variantToStringList(configuration().value(u"pluginPaths"_s)); + const QStringList runtimePluginPaths = variantToStringList(m_app->runtimeParameters().value(u"pluginPaths"_s)); if (!configPluginPaths.isEmpty() || !runtimePluginPaths.isEmpty()) { addPluginPaths(configPluginPaths, currentDir); addPluginPaths(runtimePluginPaths, codeDir); qCDebug(LogSystem) << "Updated plugin paths:" << qApp->libraryPaths(); } - const QStringList configImportPaths = variantToStringList(configuration().value(qSL("importPaths"))); - const QStringList runtimeImportPaths = variantToStringList(m_app->runtimeParameters().value(qSL("importPaths"))); + const QStringList configImportPaths = variantToStringList(configuration().value(u"importPaths"_s)); + const QStringList runtimeImportPaths = variantToStringList(m_app->runtimeParameters().value(u"importPaths"_s)); if (!configImportPaths.isEmpty() || !runtimeImportPaths.isEmpty()) { addImportPaths(configImportPaths, currentDir); addImportPaths(runtimeImportPaths, codeDir); @@ -106,7 +108,7 @@ bool QmlInProcRuntime::start() QQmlContext *appContext = new QQmlContext(m_inProcessQmlEngine->rootContext(), this); m_applicationIf = ApplicationInterface::create<QmlInProcApplicationInterfaceImpl>(this, this); - appContext->setContextProperty(qSL("ApplicationInterface"), m_applicationIf); + appContext->setContextProperty(u"ApplicationInterface"_s, m_applicationIf); if (appContext->setProperty(s_runtimeKey, QVariant::fromValue(this))) qCritical() << "Could not set" << s_runtimeKey << "property in QML context"; @@ -162,7 +164,7 @@ void QmlInProcRuntime::stop(bool forceKill) } bool ok; - int qt = configuration().value(qSL("quitTime")).toInt(&ok); + int qt = configuration().value(u"quitTime"_s).toInt(&ok); if (!ok || qt < 0) qt = 250; QTimer::singleShot(qt, this, [this]() { @@ -173,7 +175,7 @@ void QmlInProcRuntime::stop(bool forceKill) void QmlInProcRuntime::finish(int exitCode, Am::ExitStatus status) { QMetaObject::invokeMethod(this, [this, exitCode, status]() { - qCDebug(LogSystem) << "QmlInProcRuntime (id:" << (m_app ? m_app->id() : qSL("(none)")) + qCDebug(LogSystem) << "QmlInProcRuntime (id:" << (m_app ? m_app->id() : u"(none)"_s) << ") exited with code:" << exitCode << "status:" << status; emit finished(exitCode, status); if (m_app) @@ -325,7 +327,7 @@ QmlInProcRuntimeManager::QmlInProcRuntimeManager(const QString &id, QObject *par QString QmlInProcRuntimeManager::defaultIdentifier() { - return qSL("qml-inprocess"); + return u"qml-inprocess"_s; } bool QmlInProcRuntimeManager::inProcess() const diff --git a/src/manager-lib/quicklauncher.cpp b/src/manager-lib/quicklauncher.cpp index a09b1abd..d328c5c1 100644 --- a/src/manager-lib/quicklauncher.cpp +++ b/src/manager-lib/quicklauncher.cpp @@ -18,6 +18,8 @@ #include <memory> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM QuickLauncher *QuickLauncher::s_instance = nullptr; @@ -55,7 +57,7 @@ QuickLauncher::QuickLauncher(const QHash<std::pair<QString, QString>, int> &runt , m_failedStartLimitIntervalSec(qMax(0, failedStartLimitIntervalSec)) { auto findMaximum = [&runtimesPerContainer](const QuickLaunchEntry &qle) -> int { - static const QString anyId = qSL("*"); + static const QString anyId = u"*"_s; for (const auto &key : { std::make_pair(qle.m_containerId, qle.m_runtimeId), std::make_pair(qle.m_containerId, anyId), @@ -111,7 +113,7 @@ QuickLauncher::QuickLauncher(const QHash<std::pair<QString, QString>, int> &runt qCDebug(LogQuickLaunch).nospace().noquote() << " * container: " << entry.m_containerId << " / runtime: " - << (entry.m_runtimeId.isEmpty() ? qSL("(none)") : entry.m_runtimeId) + << (entry.m_runtimeId.isEmpty() ? u"(none)"_s : entry.m_runtimeId) << " [at max: " << entry.m_maximum << "]"; } } @@ -216,7 +218,7 @@ void QuickLauncher::rebuild() qCDebug(LogQuickLaunch) << "Added new quick-launch entry for container:" << entry->m_containerId << "/ runtime:" - << (entry->m_runtimeId.isEmpty() ? qSL("(none)") : entry->m_runtimeId); + << (entry->m_runtimeId.isEmpty() ? u"(none)"_s : entry->m_runtimeId); } } @@ -243,7 +245,7 @@ void QuickLauncher::removeEntry(AbstractContainer *container, AbstractRuntime *r || (runtime && car.second == runtime)) { qCDebug(LogQuickLaunch) << "Removed quick-launch entry for container:" << entry->m_containerId << "/ runtime:" - << (entry->m_runtimeId.isEmpty() ? qSL("(none)") : entry->m_runtimeId); + << (entry->m_runtimeId.isEmpty() ? u"(none)"_s : entry->m_runtimeId); entry->m_containersAndRuntimes.removeAt(i--); carRemoved++; @@ -272,7 +274,7 @@ void QuickLauncher::checkFailedStarts() && (entry->m_failedTimeStamps.size() >= m_failedStartLimit)) { qCWarning(LogQuickLaunch) << "Disabling quick-launch for container:" << entry->m_containerId << "/ runtime:" - << (entry->m_runtimeId.isEmpty() ? qSL("(none)") : entry->m_runtimeId) + << (entry->m_runtimeId.isEmpty() ? u"(none)"_s : entry->m_runtimeId) << "due to too many failed start attempts:" << entry->m_failedTimeStamps.size() << "failed starts within" << m_failedStartLimitIntervalSec << "seconds"; diff --git a/src/manager-lib/runtimefactory.cpp b/src/manager-lib/runtimefactory.cpp index 4fbfc3af..d44acdac 100644 --- a/src/manager-lib/runtimefactory.cpp +++ b/src/manager-lib/runtimefactory.cpp @@ -13,6 +13,8 @@ #include <memory> +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM RuntimeFactory *RuntimeFactory::s_instance = nullptr; @@ -45,7 +47,7 @@ AbstractRuntimeManager *RuntimeFactory::manager(const QString &id) return nullptr; AbstractRuntimeManager *arm = m_runtimes.value(id); if (!arm) - arm = m_runtimes.value(id + qSL("-inprocess")); + arm = m_runtimes.value(id + u"-inprocess"_s); return arm; } diff --git a/src/manager-lib/scopeutilities.cpp b/src/manager-lib/scopeutilities.cpp index 7f24cfe5..71d9f9ff 100644 --- a/src/manager-lib/scopeutilities.cpp +++ b/src/manager-lib/scopeutilities.cpp @@ -95,14 +95,14 @@ bool ScopedRenamer::rename(const QString &baseName, ScopedRenamer::Modes modes) bool backupDone = false; if (m_requested & NameToNameMinus) { - backupDone = internalRename(m_basePath, m_name, m_name + qL1C('-')); + backupDone = internalRename(m_basePath, m_name, m_name + u'-'); if (backupDone) m_done |= NameToNameMinus; } if (m_requested & NamePlusToName) { // only try if no backup required, or it worked if (!backupRequired || backupDone) { - if (internalRename(m_basePath, m_name + qL1C('+'), m_name)) { + if (internalRename(m_basePath, m_name + u'+', m_name)) { m_done |= NamePlusToName; } else if (backupDone && !undoRename()) { @@ -149,11 +149,11 @@ bool ScopedRenamer::undoRename() bool ScopedRenamer::interalUndoRename() { if (m_done & NamePlusToName) { - if (internalRename(m_basePath, m_name, m_name + qL1C('+'))) + if (internalRename(m_basePath, m_name, m_name + u'+')) m_done &= ~NamePlusToName; } if (m_done & NameToNameMinus) { - if (internalRename(m_basePath, m_name + qL1C('-'), m_name)) + if (internalRename(m_basePath, m_name + u'-', m_name)) m_done &= ~NameToNameMinus; } diff --git a/src/manager-lib/sudo.cpp b/src/manager-lib/sudo.cpp index 95784c52..846367f0 100644 --- a/src/manager-lib/sudo.cpp +++ b/src/manager-lib/sudo.cpp @@ -20,6 +20,8 @@ #include <errno.h> +using namespace Qt::StringLiterals; + #if defined(Q_OS_LINUX) # include "processtitle.h" @@ -288,7 +290,7 @@ QByteArray SudoInterface::receiveMessage(int socket, MessageType type, QString * auto bytesReceived = EINTR_LOOP(recv(socket, recvBuffer, sizeof(recvBuffer), 0)); if ((bytesReceived < headerSize) || qstrncmp(recvBuffer, (type == Request ? "RQST" : "RPLY"), 4)) { - *errorString = qL1S("failed to receive command from the SudoClient process"); + *errorString = u"failed to receive command from the SudoClient process"_s; //qCCritical(LogSystem) << *errorString; return QByteArray(); } @@ -389,7 +391,7 @@ QByteArray SudoClient::call(const QByteArray &msg) #endif //qCCritical(LogSystem) << "failed to send command to the SudoServer process"; - m_errorString = qL1S("failed to send command to the SudoServer process"); + m_errorString = u"failed to send command to the SudoServer process"_s; return QByteArray(); } @@ -467,7 +469,7 @@ QByteArray SudoServer::receive(const QByteArray &msg) m_stop = true; } else { reply.truncate(0); - m_errorString = QString::fromLatin1("unknown function '%1' called in SudoServer").arg(qL1S(function)); + m_errorString = u"unknown function '%1' called in SudoServer"_s.arg(QString::fromLatin1(function)); } return reply; } @@ -581,7 +583,7 @@ bool SudoServer::bindMountFileSystem(const QString &from, const QString &to, boo Q_UNUSED(to) Q_UNUSED(readOnly) Q_UNUSED(namespacePid) - m_errorString = qL1S("bindMountFileSystem is only available on Linux"); + m_errorString = u"bindMountFileSystem is only available on Linux"_s; return false; #endif // Q_OS_LINUX } diff --git a/src/monitor-lib/systemreader.cpp b/src/monitor-lib/systemreader.cpp index 10993c76..cc84b839 100644 --- a/src/monitor-lib/systemreader.cpp +++ b/src/monitor-lib/systemreader.cpp @@ -9,10 +9,12 @@ #include "global.h" #include "logging.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM #if defined(Q_OS_LINUX) -QString g_systemRootDir(qSL("/")); +QString g_systemRootDir(u"/"_s); #endif quint64 MemoryReader::s_totalValue = 0; @@ -164,11 +166,11 @@ public: : QProcess(qApp) { if (GpuVendor::get() == GpuVendor::Intel) { - setProgram(qSL("intel_gpu_top")); - setArguments({ qSL("-o-"), qSL("-s 1000") }); + setProgram(u"intel_gpu_top"_s); + setArguments({ u"-o-"_s, u"-s 1000"_s }); } else if (GpuVendor::get() == GpuVendor::Nvidia) { - setProgram(qSL("nvidia-smi")); - setArguments({ qSL("dmon"), qSL("--select"), qSL("u") }); + setProgram(u"nvidia-smi"_s); + setArguments({ u"dmon"_s, u"--select"_s, u"u"_s }); } connect(this, static_cast<void(QProcess::*)(QProcess::ProcessError error)>(&QProcess::errorOccurred), @@ -289,7 +291,8 @@ MemoryReader::MemoryReader() : MemoryReader(QString()) MemoryReader::MemoryReader(const QString &groupPath) : m_groupPath(groupPath) { - const QString path = g_systemRootDir + cGroupsMemoryBaseDir + m_groupPath + qSL("/memory.stat"); + const QString path = g_systemRootDir + QString::fromLatin1(cGroupsMemoryBaseDir) + + m_groupPath + u"/memory.stat"_s; m_sysFs.reset(new SysFsReader(path.toLocal8Bit(), 1500)); if (!m_sysFs->isOpen()) { @@ -313,7 +316,8 @@ MemoryReader::MemoryReader(const QString &groupPath) quint64 MemoryReader::groupLimit() { - QString path = g_systemRootDir + cGroupsMemoryBaseDir + m_groupPath + qSL("/memory.limit_in_bytes"); + QString path = g_systemRootDir + QString::fromLatin1(cGroupsMemoryBaseDir) + + m_groupPath + u"/memory.limit_in_bytes"_s; QByteArray ba = SysFsReader(path.toLocal8Bit(), 41).readValue(); return ::strtoull(ba, nullptr, 10); } @@ -421,11 +425,11 @@ bool MemoryThreshold::setEnabled(bool enabled, const QString &groupPath, MemoryR m_eventFd = ::eventfd(0, EFD_CLOEXEC); if (m_eventFd >= 0) { - const QString usagePath = cGroup + qL1S("/memory.usage_in_bytes"); + const QString usagePath = cGroup + u"/memory.usage_in_bytes"; m_usageFd = QT_OPEN(usagePath.toLocal8Bit().constData(), QT_OPEN_RDONLY); if (m_usageFd >= 0) { - const QString eventControlPath = cGroup + qSL("/cgroup.event_control"); + const QString eventControlPath = cGroup + u"/cgroup.event_control"_s; m_controlFd = QT_OPEN(eventControlPath.toLocal8Bit().constData(), QT_OPEN_WRONLY); if (m_controlFd >= 0) { @@ -536,7 +540,7 @@ QMap<QByteArray, QByteArray> fetchCGroupProcessInfo(qint64 pid) { QMap<QByteArray, QByteArray> result; - auto cgroupPath = QString(qSL("%1/proc/%2/cgroup")) + auto cgroupPath = QString(u"%1/proc/%2/cgroup"_s) .arg(g_systemRootDir) .arg(pid); diff --git a/src/package-lib/packagecreator.cpp b/src/package-lib/packagecreator.cpp index d42a6103..c17c3ac4 100644 --- a/src/package-lib/packagecreator.cpp +++ b/src/package-lib/packagecreator.cpp @@ -34,6 +34,8 @@ # define S_IEXEC S_IXUSR #endif +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -56,7 +58,7 @@ QDir PackageCreator::sourceDirectory() const void PackageCreator::setSourceDirectory(const QDir &sourceDir) { - d->m_sourcePath = sourceDir.absolutePath() + QLatin1Char('/'); + d->m_sourcePath = sourceDir.absolutePath() + u'/'; } bool PackageCreator::create() @@ -94,7 +96,7 @@ Error PackageCreator::errorCode() const QString PackageCreator::errorString() const { - return wasCanceled() ? qSL("canceled") : (d->m_failed ? d->m_errorString : QString()); + return wasCanceled() ? u"canceled"_s : (d->m_failed ? d->m_errorString : QString()); } /*! \internal @@ -129,18 +131,18 @@ bool PackageCreatorPrivate::create() QCryptographicHash digest(QCryptographicHash::Sha256); QVariantMap headerFormat { - { qSL("formatType"), qSL("am-package-header") }, - { qSL("formatVersion"), 2 } + { u"formatType"_s, u"am-package-header"_s }, + { u"formatVersion"_s, 2 } }; m_metaData = QVariantMap { - { qSL("packageId"), m_report.packageId() }, - { qSL("diskSpaceUsed"), m_report.diskSpaceUsed() } + { u"packageId"_s, m_report.packageId() }, + { u"diskSpaceUsed"_s, m_report.diskSpaceUsed() } }; if (!m_report.extraMetaData().isEmpty()) - m_metaData[qSL("extra")] = m_report.extraMetaData(); + m_metaData[u"extra"_s] = m_report.extraMetaData(); if (!m_report.extraSignedMetaData().isEmpty()) - m_metaData[qSL("extraSigned")] = m_report.extraSignedMetaData(); + m_metaData[u"extraSigned"_s] = m_report.extraSignedMetaData(); PackageUtilities::addHeaderDataToDigest(m_metaData, digest); @@ -173,7 +175,7 @@ bool PackageCreatorPrivate::create() // Add the metadata header - if (!addVirtualFile(ar, qSL("--PACKAGE-HEADER--"), QtYaml::yamlFromVariantDocuments(QVector<QVariant> { headerFormat, m_metaData }))) + if (!addVirtualFile(ar, u"--PACKAGE-HEADER--"_s, QtYaml::yamlFromVariantDocuments(QVector<QVariant> { headerFormat, m_metaData }))) throw ArchiveException(ar, "could not write '--PACKAGE-HEADER--' to archive"); // Add all regular files @@ -290,33 +292,33 @@ bool PackageCreatorPrivate::create() // Add the metadata footer QVariantMap footerFormat { - { qSL("formatType"), qSL("am-package-footer") }, - { qSL("formatVersion"), 2 } + { u"formatType"_s, u"am-package-footer"_s }, + { u"formatVersion"_s, 2 } }; QVariantMap footerData { - { qSL("digest"), QLatin1String(m_digest.toHex()) }, + { u"digest"_s, QString::fromLatin1(m_digest.toHex()) }, }; - if (!addVirtualFile(ar, qSL("--PACKAGE-FOOTER--"), QtYaml::yamlFromVariantDocuments(QVector<QVariant> { footerFormat, footerData }))) + if (!addVirtualFile(ar, u"--PACKAGE-FOOTER--"_s, QtYaml::yamlFromVariantDocuments(QVector<QVariant> { footerFormat, footerData }))) throw ArchiveException(ar, "could not add '--PACKAGE-FOOTER--' to archive"); m_metaData.insert(footerData); if (!m_report.developerSignature().isEmpty()) { QVariantMap footerDevSig { - { qSL("developerSignature"), QLatin1String(m_report.developerSignature().toBase64()) } + { u"developerSignature"_s, QString::fromLatin1(m_report.developerSignature().toBase64()) } }; - if (!addVirtualFile(ar, qSL("--PACKAGE-FOOTER--"), QtYaml::yamlFromVariantDocuments(QVector<QVariant> { footerDevSig }))) + if (!addVirtualFile(ar, u"--PACKAGE-FOOTER--"_s, QtYaml::yamlFromVariantDocuments(QVector<QVariant> { footerDevSig }))) throw ArchiveException(ar, "could not add '--PACKAGE-FOOTER--' to archive"); m_metaData.insert(footerDevSig); } if (!m_report.storeSignature().isEmpty()) { QVariantMap footerStoreSig { - { qSL("storeSignature"), QLatin1String(m_report.storeSignature().toBase64()) } + { u"storeSignature"_s, QString::fromLatin1(m_report.storeSignature().toBase64()) } }; - if (!addVirtualFile(ar, qSL("--PACKAGE-FOOTER--"), QtYaml::yamlFromVariantDocuments(QVector<QVariant> { footerStoreSig }))) + if (!addVirtualFile(ar, u"--PACKAGE-FOOTER--"_s, QtYaml::yamlFromVariantDocuments(QVector<QVariant> { footerStoreSig }))) throw ArchiveException(ar, "could not add '--PACKAGE-FOOTER--' to archive"); m_metaData.insert(footerStoreSig); diff --git a/src/package-lib/packageextractor.cpp b/src/package-lib/packageextractor.cpp index 0dd66b7a..6a1c23d0 100644 --- a/src/package-lib/packageextractor.cpp +++ b/src/package-lib/packageextractor.cpp @@ -38,6 +38,8 @@ # define S_IEXEC S_IXUSR #endif +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM PackageExtractor::PackageExtractor(const QUrl &downloadUrl, const QDir &destinationDir, QObject *parent) @@ -54,7 +56,7 @@ QDir PackageExtractor::destinationDirectory() const void PackageExtractor::setDestinationDirectory(const QDir &destinationDir) { - d->m_destinationPath = destinationDir.absolutePath() + qL1C('/'); + d->m_destinationPath = destinationDir.absolutePath() + u'/'; } void PackageExtractor::setFileExtractedCallback(const std::function<void(const QString &)> &callback) @@ -100,7 +102,7 @@ Error PackageExtractor::errorCode() const QString PackageExtractor::errorString() const { - return wasCanceled() ? qSL("canceled") : (d->m_failed ? d->m_errorString : QString()); + return wasCanceled() ? u"canceled"_s : (d->m_failed ? d->m_errorString : QString()); } /*! \internal @@ -256,11 +258,11 @@ void PackageExtractorPrivate::extract() // Check if this entry is special (metadata vs. data) - if (entryPath == qL1S("--PACKAGE-HEADER--")) + if (entryPath == u"--PACKAGE-HEADER--") packageEntryType = PackageEntry_Header; - else if (entryPath.startsWith(qL1S("--PACKAGE-FOOTER--"))) + else if (entryPath.startsWith(u"--PACKAGE-FOOTER--")) packageEntryType = PackageEntry_Footer; - else if (entryPath.startsWith(qL1S("--"))) + else if (entryPath.startsWith(u"--")) throw Exception(Error::Package, "filename %1 in the archive starts with the reserved characters '--'").arg(entryPath); // The first (and only the first) file in every package needs to be --PACKAGE-HEADER-- @@ -274,28 +276,28 @@ void PackageExtractorPrivate::extract() switch (packageEntryType) { case PackageEntry_Dir: - if (!entryPath.endsWith(qL1C('/'))) + if (!entryPath.endsWith(u'/')) throw Exception(Error::Package, "invalid archive entry '%1': directory name is missing '/' at the end").arg(entryPath); entryPath.chop(1); Q_FALLTHROUGH(); case PackageEntry_File: { // get the directory, where the new entry will be created - QDir entryDir(QString(m_destinationPath + entryPath).section(qL1C('/'), 0, -2)); + QDir entryDir(QString(m_destinationPath + entryPath).section(u'/', 0, -2)); if (!entryDir.exists()) throw Exception(Error::Package, "invalid archive entry '%1': parent directory is missing").arg(entryPath); - QString entryCanonicalPath = entryDir.canonicalPath() + qL1C('/'); - QString baseCanonicalPath = QDir(m_destinationPath).canonicalPath() + qL1C('/'); + QString entryCanonicalPath = entryDir.canonicalPath() + u'/'; + QString baseCanonicalPath = QDir(m_destinationPath).canonicalPath() + u'/'; // security check: make sure that entryCanonicalPath is NOT outside of baseCanonicalPath if (!entryCanonicalPath.startsWith(baseCanonicalPath)) throw Exception(Error::Package, "invalid archive entry '%1': pointing outside of extraction directory").arg(entryPath); if (packageEntryType == PackageEntry_Dir) { - QString entryName = entryPath.section(qL1C('/'), -1, -1); + QString entryName = entryPath.section(u'/', -1, -1); - if ((entryName != qL1S(".")) && !entryDir.mkdir(entryName)) + if ((entryName != u".") && !entryDir.mkdir(entryName)) throw Exception(Error::IO, "could not create directory '%1'").arg(entryDir.filePath(entryName)); archive_read_data_skip(ar); @@ -425,7 +427,7 @@ void PackageExtractorPrivate::processMetaData(const QByteArray &metadata, QCrypt .arg(e.errorString()); } - const QString formatType = isHeader ? qSL("am-package-header") : qSL("am-package-footer"); + const QString formatType = isHeader ? u"am-package-header"_s : u"am-package-footer"_s; int formatVersion = 0; try { formatVersion = checkYamlFormat(docs, -2 /*at least 2 docs*/, { { formatType, 2 }, @@ -437,10 +439,10 @@ void PackageExtractorPrivate::processMetaData(const QByteArray &metadata, QCrypt QVariantMap map = docs.at(1).toMap(); if (isHeader) { - const QString idField = (formatVersion == 1) ? qSL("applicationId") : qSL("packageId"); + const QString idField = (formatVersion == 1) ? u"applicationId"_s : u"packageId"_s; QString packageId = map.value(idField).toString(); - quint64 diskSpaceUsed = map.value(qSL("diskSpaceUsed")).toULongLong(); + quint64 diskSpaceUsed = map.value(u"diskSpaceUsed"_s).toULongLong(); if (packageId.isNull() || !PackageInfo::isValidApplicationId(packageId)) throw Exception(Error::Package, "metadata has an invalid %2 field (%1)").arg(packageId).arg(idField); @@ -450,8 +452,8 @@ void PackageExtractorPrivate::processMetaData(const QByteArray &metadata, QCrypt throw Exception(Error::Package, "metadata has an invalid diskSpaceUsed field (%1)").arg(diskSpaceUsed); m_report.setDiskSpaceUsed(diskSpaceUsed); - m_report.setExtraMetaData(map.value(qSL("extra")).toMap()); - m_report.setExtraSignedMetaData(map.value(qSL("extraSigned")).toMap()); + m_report.setExtraMetaData(map.value(u"extra"_s).toMap()); + m_report.setExtraSignedMetaData(map.value(u"extraSigned"_s).toMap()); PackageUtilities::addHeaderDataToDigest(map, digest); @@ -459,7 +461,7 @@ void PackageExtractorPrivate::processMetaData(const QByteArray &metadata, QCrypt for (int i = 2; i < docs.size(); ++i) map.insert(docs.at(i).toMap()); - QByteArray packageDigest = QByteArray::fromHex(map.value(qSL("digest")).toString().toLatin1()); + QByteArray packageDigest = QByteArray::fromHex(map.value(u"digest"_s).toString().toLatin1()); if (packageDigest.isEmpty()) throw Exception(Error::Package, "metadata is missing the digest field"); @@ -469,8 +471,8 @@ void PackageExtractorPrivate::processMetaData(const QByteArray &metadata, QCrypt if (calculatedDigest != packageDigest) throw Exception(Error::Package, "package digest mismatch (is %1, but should be %2").arg(calculatedDigest.toHex()).arg(packageDigest.toHex()); - m_report.setStoreSignature(QByteArray::fromBase64(map.value(qSL("storeSignature")).toString().toLatin1())); - m_report.setDeveloperSignature(QByteArray::fromBase64(map.value(qSL("developerSignature")).toString().toLatin1())); + m_report.setStoreSignature(QByteArray::fromBase64(map.value(u"storeSignature"_s).toString().toLatin1())); + m_report.setDeveloperSignature(QByteArray::fromBase64(map.value(u"developerSignature"_s).toString().toLatin1())); } } diff --git a/src/package-lib/packageutilities.cpp b/src/package-lib/packageutilities.cpp index 4a362ea3..5c228168 100644 --- a/src/package-lib/packageutilities.cpp +++ b/src/package-lib/packageutilities.cpp @@ -17,6 +17,8 @@ #include "global.h" #include "logging.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -25,12 +27,12 @@ bool PackageUtilities::ensureCorrectLocale() { return true; } bool PackageUtilities::checkCorrectLocale() { return true; } ArchiveException::ArchiveException(struct ::archive *ar, const char *errorString) - : Exception(Error::Archive, qSL("[libarchive] ") + qL1S(errorString) + qSL(": ") + QString::fromLocal8Bit(::archive_error_string(ar))) + : Exception(Error::Archive, u"[libarchive] "_s + QString::fromLatin1(errorString) + u": "_s + QString::fromLocal8Bit(::archive_error_string(ar))) { } QVariantMap PackageUtilities::headerDataForDigest = QVariantMap { - { qSL("extraSigned"), QVariantMap() } + { u"extraSigned"_s, QVariantMap() } }; void PackageUtilities::addFileMetadataToDigest(const QString &entryFilePath, const QFileInfo &fi, QCryptographicHash &digest) diff --git a/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp b/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp index c8c7070f..c1f9ca37 100644 --- a/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp +++ b/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp @@ -537,7 +537,7 @@ bool BubblewrapContainer::start(const QStringList &arguments, const QMap<QString bwrapCommand += { u"--setenv"_s, u"DBUS_SESSION_BUS_ADDRESS"_s, QString::fromLocal8Bit(dbusSessionBusAddress) }; for (const auto &key : QProcessEnvironment::systemEnvironment().keys()) { - if (key.startsWith(u"LC_"_s) || key == u"LANG"_s) + if (key.startsWith(u"LC_"_s) || key == u"LANG") bwrapCommand += { u"--setenv"_s, key, QProcessEnvironment::systemEnvironment().value(key)}; } diff --git a/src/shared-main-lib/cpustatus.cpp b/src/shared-main-lib/cpustatus.cpp index 273ea0b1..4418f4c3 100644 --- a/src/shared-main-lib/cpustatus.cpp +++ b/src/shared-main-lib/cpustatus.cpp @@ -7,6 +7,8 @@ #include <QThread> +using namespace Qt::StringLiterals; + /*! \qmltype CpuStatus \inqmlmodule QtApplicationManager @@ -108,7 +110,7 @@ void CpuStatus::update() */ QStringList CpuStatus::roleNames() const { - return { qSL("cpuLoad") }; + return { u"cpuLoad"_s }; } #include "moc_cpustatus.cpp" diff --git a/src/shared-main-lib/frametimer.cpp b/src/shared-main-lib/frametimer.cpp index 4a00d051..73544a2c 100644 --- a/src/shared-main-lib/frametimer.cpp +++ b/src/shared-main-lib/frametimer.cpp @@ -10,6 +10,8 @@ #include <QQuickWindow> #include <qqmlinfo.h> +using namespace Qt::StringLiterals; + /*! \qmltype FrameTimer \inqmlmodule QtApplicationManager @@ -203,7 +205,7 @@ void FrameTimer::setWindow(QObject *window) */ QStringList FrameTimer::roleNames() const { - return { qSL("averageFps"), qSL("minimumFps"), qSL("maximumFps"), qSL("jitterFps") }; + return { u"averageFps"_s, u"minimumFps"_s, u"maximumFps"_s, u"jitterFps"_s }; } /*! diff --git a/src/shared-main-lib/gpustatus.cpp b/src/shared-main-lib/gpustatus.cpp index 2436064c..d79117c8 100644 --- a/src/shared-main-lib/gpustatus.cpp +++ b/src/shared-main-lib/gpustatus.cpp @@ -5,6 +5,8 @@ #include "gpustatus.h" +using namespace Qt::StringLiterals; + /*! \qmltype GpuStatus \inqmlmodule QtApplicationManager @@ -125,7 +127,7 @@ void GpuStatus::update() */ QStringList GpuStatus::roleNames() const { - return { qSL("gpuLoad") }; + return { u"gpuLoad"_s }; } diff --git a/src/shared-main-lib/iostatus.cpp b/src/shared-main-lib/iostatus.cpp index a2b77a78..f1efc612 100644 --- a/src/shared-main-lib/iostatus.cpp +++ b/src/shared-main-lib/iostatus.cpp @@ -7,6 +7,8 @@ #include <QFile> +using namespace Qt::StringLiterals; + /*! \qmltype IoStatus \inqmlmodule QtApplicationManager @@ -120,7 +122,7 @@ QVariantMap IoStatus::ioLoad() const */ QStringList IoStatus::roleNames() const { - return { qSL("ioLoad") }; + return { u"ioLoad"_s }; } /*! @@ -142,7 +144,7 @@ void IoStatus::update() void IoStatus::addIoReader(const QString &deviceName) { - if (!QFile::exists(qSL("/dev/") + deviceName)) + if (!QFile::exists(u"/dev/"_s + deviceName)) return; if (m_ioHash.contains(deviceName)) return; diff --git a/src/shared-main-lib/memorystatus.cpp b/src/shared-main-lib/memorystatus.cpp index c1f6d794..2410fbb0 100644 --- a/src/shared-main-lib/memorystatus.cpp +++ b/src/shared-main-lib/memorystatus.cpp @@ -5,6 +5,8 @@ #include "memorystatus.h" +using namespace Qt::StringLiterals; + /*! \qmltype MemoryStatus \inqmlmodule QtApplicationManager @@ -100,7 +102,7 @@ quint64 MemoryStatus::memoryUsed() const */ QStringList MemoryStatus::roleNames() const { - return { qSL("memoryUsed") }; + return { u"memoryUsed"_s }; } /*! diff --git a/src/shared-main-lib/monitormodel.cpp b/src/shared-main-lib/monitormodel.cpp index 86036cc3..c91c5e74 100644 --- a/src/shared-main-lib/monitormodel.cpp +++ b/src/shared-main-lib/monitormodel.cpp @@ -14,6 +14,9 @@ #include <QJSValue> #include <QQmlEngine> +using namespace Qt::StringLiterals; + + /*! \qmltype MonitorModel \inqmlmodule QtApplicationManager @@ -204,14 +207,14 @@ bool MonitorModel::extractRoleNamesFromJsArray(DataSource *dataSource) QJSValue jsDataSource = engine->toScriptValue<QObject*>(dataSource->obj); - if (!jsDataSource.hasProperty(qSL("roleNames"))) + if (!jsDataSource.hasProperty(u"roleNames"_s)) return false; - QJSValue jsRoleNames = jsDataSource.property(qSL("roleNames")); + QJSValue jsRoleNames = jsDataSource.property(u"roleNames"_s); if (!jsRoleNames.isArray()) return false; - int length = jsRoleNames.property(qSL("length")).toInt(); + int length = jsRoleNames.property(u"length"_s).toInt(); for (int i = 0; i < length; i++) addRoleName(jsRoleNames.property(i).toString().toLatin1(), dataSource); @@ -456,7 +459,7 @@ QVariantMap MonitorModel::get(int row) const QVariantMap map; QHash<int, QByteArray> roles = roleNames(); for (auto it = roles.cbegin(); it != roles.cend(); ++it) - map.insert(qL1S(it.value()), data(index(row), it.key())); + map.insert(QString::fromLatin1(it.value()), data(index(row), it.key())); return map; } diff --git a/src/shared-main-lib/notification.cpp b/src/shared-main-lib/notification.cpp index 20ac1329..a1c2d53a 100644 --- a/src/shared-main-lib/notification.cpp +++ b/src/shared-main-lib/notification.cpp @@ -7,6 +7,9 @@ #include "notificationimpl.h" #include "global.h" +using namespace Qt::StringLiterals; + + /*! \qmltype Notification \inqmlmodule QtApplicationManager @@ -522,7 +525,7 @@ QStringList Notification::libnotifyActionList() const { QStringList actionList; if (isAcknowledgeable()) - actionList << qSL("default") << QString(); + actionList << u"default"_s << QString(); for (const QVariant &action : m_actions) { if (action.metaType() == QMetaType::fromType<QString>()) { actionList << action.toString() << QString(); @@ -541,18 +544,18 @@ QStringList Notification::libnotifyActionList() const QVariantMap Notification::libnotifyHints() const { QVariantMap hints; - hints.insert(qSL("action-icons"), showActionsAsIcons()); - hints.insert(qSL("urgency"), int(priority())); + hints.insert(u"action-icons"_s, showActionsAsIcons()); + hints.insert(u"urgency"_s, int(priority())); if (!category().isEmpty()) - hints.insert(qSL("category"), category()); + hints.insert(u"category"_s, category()); if (!image().isEmpty()) - hints.insert(qSL("image-path"), image().toString()); + hints.insert(u"image-path"_s, image().toString()); if (isShowingProgress()) { - hints.insert(qSL("x-pelagicore-show-progress"), true); - hints.insert(qSL("x-pelagicore-progress"), progress()); + hints.insert(u"x-pelagicore-show-progress"_s, true); + hints.insert(u"x-pelagicore-progress"_s, progress()); } if (!extended().isEmpty()) - hints.insert(qSL("x-pelagicore-extended"), extended()); + hints.insert(u"x-pelagicore-extended"_s, extended()); return hints; } @@ -593,7 +596,7 @@ void Notification::close() void Notification::triggerAction(const QString &actionId) { - if (actionId == qL1S("default")) + if (actionId == u"default") emit acknowledged(); else emit actionTriggered(actionId); diff --git a/src/shared-main-lib/qmllogger.cpp b/src/shared-main-lib/qmllogger.cpp index cc2304cf..58c3e1dd 100644 --- a/src/shared-main-lib/qmllogger.cpp +++ b/src/shared-main-lib/qmllogger.cpp @@ -27,7 +27,7 @@ void QmlLogger::warnings(const QList<QQmlError> &list) if (err.object()) func = err.object()->objectName().toLocal8Bit(); QByteArray file; - if (err.url().scheme() == qL1S("file")) + if (err.url().scheme() == u"file") file = err.url().toLocalFile().toLocal8Bit(); else file = err.url().toDisplayString().toLocal8Bit(); diff --git a/src/shared-main-lib/sharedmain.cpp b/src/shared-main-lib/sharedmain.cpp index fae04f8e..1b8cd058 100644 --- a/src/shared-main-lib/sharedmain.cpp +++ b/src/shared-main-lib/sharedmain.cpp @@ -38,15 +38,17 @@ #include "../plugin-interfaces/startupinterface.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM static const QMap<int, QString> &openGLProfileNames() { static const QMap<int, QString> map = { - { QSurfaceFormat::NoProfile, qSL("default") }, - { QSurfaceFormat::CoreProfile, qSL("core") }, - { QSurfaceFormat::CompatibilityProfile, qSL("compatibility") } + { QSurfaceFormat::NoProfile, u"default"_s }, + { QSurfaceFormat::CoreProfile, u"core"_s }, + { QSurfaceFormat::CompatibilityProfile, u"compatibility"_s } }; return map; } @@ -139,15 +141,15 @@ void SharedMain::setupLogging(bool verbose, const QStringList &loggingRules, const QString &messagePattern, const QVariant &useAMConsoleLogger) { static const QStringList verboseRules { - qSL("*=true"), - qSL("qt.*.debug=false"), - qSL("am.wayland.debug=false"), - qSL("qt.qml.overloadresolution.info=false"), - qSL("qt.widgets.painting.info=false"), + u"*=true"_s, + u"qt.*.debug=false"_s, + u"am.wayland.debug=false"_s, + u"qt.qml.overloadresolution.info=false"_s, + u"qt.widgets.painting.info=false"_s, }; const QStringList rules = verbose ? verboseRules - : loggingRules.isEmpty() ? QStringList(qSL("*.debug=false")) + : loggingRules.isEmpty() ? QStringList(u"*.debug=false"_s) : loggingRules; Logging::setFilterRules(rules); Logging::setMessagePattern(messagePattern); @@ -159,9 +161,9 @@ void SharedMain::setupLogging(bool verbose, const QStringList &loggingRules, void SharedMain::setupOpenGL(const QVariantMap &openGLConfiguration) { #if !defined(QT_NO_OPENGL) - QString profileName = openGLConfiguration.value(qSL("desktopProfile")).toString(); - int majorVersion = openGLConfiguration.value(qSL("esMajorVersion"), -1).toInt(); - int minorVersion = openGLConfiguration.value(qSL("esMinorVersion"), -1).toInt(); + QString profileName = openGLConfiguration.value(u"desktopProfile"_s).toString(); + int majorVersion = openGLConfiguration.value(u"esMajorVersion"_s, -1).toInt(); + int minorVersion = openGLConfiguration.value(u"esMinorVersion"_s, -1).toInt(); QOpenGLContext *globalContext = qt_gl_global_share_context(); QSurfaceFormat format = QSurfaceFormat::defaultFormat(); diff --git a/src/tools/appman/appman.cpp b/src/tools/appman/appman.cpp index d33d96ba..06cc3ce6 100644 --- a/src/tools/appman/appman.cpp +++ b/src/tools/appman/appman.cpp @@ -20,6 +20,8 @@ # include "testrunner.h" #endif +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM @@ -36,13 +38,13 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) "Use -- -help to show all available testrunner command line options."; onlyOnePositionalArgument = false; - QCoreApplication::setApplicationName(qSL("Qt Application Manager QML Test Runner")); + QCoreApplication::setApplicationName(u"Qt Application Manager QML Test Runner"_s); #else - QCoreApplication::setApplicationName(qSL("Qt Application Manager")); + QCoreApplication::setApplicationName(u"Qt Application Manager"_s); #endif - QCoreApplication::setOrganizationName(qSL("QtProject")); - QCoreApplication::setOrganizationDomain(qSL("qt-project.org")); - QCoreApplication::setApplicationVersion(qSL(QT_AM_VERSION_STR)); + QCoreApplication::setOrganizationName(u"QtProject"_s); + QCoreApplication::setOrganizationDomain(u"qt-project.org"_s); + QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_AM_VERSION_STR)); try { Main a(argc, argv, Main::InitFlag::ForkSudoServer | Main::InitFlag::InitializeLogging); diff --git a/src/tools/controller/controller.cpp b/src/tools/controller/controller.cpp index ee5dee17..8daa0596 100644 --- a/src/tools/controller/controller.cpp +++ b/src/tools/controller/controller.cpp @@ -31,6 +31,8 @@ #include "interrupthandler.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class DBus : public QObject @@ -55,8 +57,8 @@ public: if (m_manager) return; - auto conn = connectTo(qSL("io.qt.ApplicationManager")); - m_manager = new IoQtApplicationManagerInterface(qSL("io.qt.ApplicationManager"), qSL("/ApplicationManager"), conn, this); + auto conn = connectTo(u"io.qt.ApplicationManager"_s); + m_manager = new IoQtApplicationManagerInterface(u"io.qt.ApplicationManager"_s, u"/ApplicationManager"_s, conn, this); } void connectToPackager() Q_DECL_NOEXCEPT_EXPR(false) @@ -64,8 +66,8 @@ public: if (m_packager) return; - auto conn = connectTo(qSL("io.qt.PackageManager")); - m_packager = new IoQtPackageManagerInterface(qSL("io.qt.ApplicationManager"), qSL("/PackageManager"), conn, this); + auto conn = connectTo(u"io.qt.PackageManager"_s); + m_packager = new IoQtPackageManagerInterface(u"io.qt.ApplicationManager"_s, u"/PackageManager"_s, conn, this); } signals: @@ -76,18 +78,18 @@ private: { QDBusConnection conn(iface); - QFile f(QDir::temp().absoluteFilePath(m_instanceId % QString(qSL("%1.dbus")).arg(iface))); + QFile f(QDir::temp().absoluteFilePath(m_instanceId % QString(u"%1.dbus"_s).arg(iface))); QString dbus; if (f.open(QFile::ReadOnly)) { dbus = QString::fromUtf8(f.readAll()); - if (dbus == qL1S("system")) { + if (dbus == u"system") { conn = QDBusConnection::systemBus(); - dbus = qSL("[system-bus]"); + dbus = u"[system-bus]"_s; } else if (dbus.isEmpty()) { conn = QDBusConnection::sessionBus(); - dbus = qSL("[session-bus]"); + dbus = u"[session-bus]"_s; } else { - conn = QDBusConnection::connectToBus(dbus, qSL("custom")); + conn = QDBusConnection::connectToBus(dbus, u"custom"_s); } } else { throw Exception(Error::IO, "Could not find the D-Bus interface of a running application manager instance.\n(did you start the appman with '--dbus none'?"); @@ -98,7 +100,7 @@ private: .arg(iface, dbus, conn.lastError().message()); } - installDisconnectWatcher(conn, qSL("io.qt.ApplicationManager")); + installDisconnectWatcher(conn, u"io.qt.ApplicationManager"_s); return conn; } @@ -111,7 +113,7 @@ private: auto *watcher = new QDBusServiceWatcher(serviceName, conn, QDBusServiceWatcher::WatchForOwnerChange, this); connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, [this](const QString &, const QString &, const QString &) { - disconnectDetected(qSL("owner changed")); + disconnectDetected(u"owner changed"_s); }); m_connections.append(conn.name()); } @@ -125,7 +127,7 @@ private: connect(m_disconnectTimer, &QTimer::timeout, this, [this]() { for (const auto &name : std::as_const(m_connections)) { if (!QDBusConnection(name).isConnected()) { - disconnectDetected(qSL("bus died")); + disconnectDetected(u"bus died"_s); break; } } @@ -219,7 +221,9 @@ static Command command(QCommandLineParser &clp) for (uint i = 0; i < sizeof(commandTable) / sizeof(commandTable[0]); ++i) { if (cmd == commandTable[i].name) { clp.clearPositionalArguments(); - clp.addPositionalArgument(qL1S(cmd), qL1S(commandTable[i].description), qL1S(cmd)); + clp.addPositionalArgument(QString::fromLatin1(cmd), + QString::fromLatin1(commandTable[i].description), + QString::fromLatin1(cmd)); return commandTable[i].command; } } @@ -283,10 +287,10 @@ private: int main(int argc, char *argv[]) { - QCoreApplication::setApplicationName(qSL("Qt Application Manager Controller")); - QCoreApplication::setOrganizationName(qSL("QtProject")); - QCoreApplication::setOrganizationDomain(qSL("qt-project.org")); - QCoreApplication::setApplicationVersion(qSL(QT_AM_VERSION_STR)); + QCoreApplication::setApplicationName(u"Qt Application Manager Controller"_s); + QCoreApplication::setOrganizationName(u"QtProject"_s); + QCoreApplication::setOrganizationDomain(u"qt-project.org"_s); + QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_AM_VERSION_STR)); ThrowingApplication a(argc, argv); @@ -307,11 +311,11 @@ int main(int argc, char *argv[]) QCommandLineParser clp; - clp.addOption({ { qSL("instance-id") }, qSL("Connect to the named instance."), qSL("instance-id") }); + clp.addOption({ { u"instance-id"_s }, u"Connect to the named instance."_s, u"instance-id"_s }); clp.addHelpOption(); clp.addVersionOption(); - clp.addPositionalArgument(qSL("command"), qSL("The command to execute.")); + clp.addPositionalArgument(u"command"_s, u"The command to execute."_s); // ignore unknown options for now -- the sub-commands may need them later clp.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments); @@ -322,28 +326,28 @@ int main(int argc, char *argv[]) clp.parse(QCoreApplication::arguments()); clp.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsOptions); - dbus.setInstanceId(clp.value(qSL("instance-id"))); + dbus()->setInstanceId(clp.value(u"instance-id"_s)); // REMEMBER to update the completion file util/bash/appman-prompt, if you apply changes below! try { switch (command(clp)) { case NoCommand: - if (clp.isSet(qSL("version"))) + if (clp.isSet(u"version"_s)) clp.showVersion(); - clp.setApplicationDescription(qSL("\n") + QCoreApplication::applicationName() + qL1S(desc)); - if (clp.isSet(qSL("help"))) + clp.setApplicationDescription(u"\n"_s + QCoreApplication::applicationName() + QString::fromLatin1(desc)); + if (clp.isSet(u"help"_s)) clp.showHelp(0); clp.showHelp(1); break; case StartApplication: { - clp.addOption({ { qSL("i"), qSL("attach-stdin") }, qSL("Attach the app's stdin to the controller's stdin") }); - clp.addOption({ { qSL("o"), qSL("attach-stdout") }, qSL("Attach the app's stdout to the controller's stdout") }); - clp.addOption({ { qSL("e"), qSL("attach-stderr") }, qSL("Attach the app's stderr to the controller's stderr") }); - clp.addOption({ { qSL("r"), qSL("restart") }, qSL("Before starting, stop the application if it is already running") }); - clp.addPositionalArgument(qSL("application-id"), qSL("The id of an installed application.")); - clp.addPositionalArgument(qSL("document-url"), qSL("The optional document-url."), qSL("[document-url]")); + clp.addOption({ { u"i"_s, u"attach-stdin"_s }, u"Attach the app's stdin to the controller's stdin"_s }); + clp.addOption({ { u"o"_s, u"attach-stdout"_s }, u"Attach the app's stdout to the controller's stdout"_s }); + clp.addOption({ { u"e"_s, u"attach-stderr"_s }, u"Attach the app's stderr to the controller's stderr"_s }); + clp.addOption({ { u"r"_s, u"restart"_s }, u"Before starting, stop the application if it is already running"_s }); + clp.addPositionalArgument(u"application-id"_s, u"The id of an installed application."_s); + clp.addPositionalArgument(u"document-url"_s, u"The optional document-url."_s, u"[document-url]"_s); clp.process(a); int args = int(clp.positionalArguments().size()); @@ -351,13 +355,13 @@ int main(int argc, char *argv[]) clp.showHelp(1); QMap<QString, int> stdRedirections; - if (clp.isSet(qSL("attach-stdin"))) - stdRedirections[qSL("in")] = 0; - if (clp.isSet(qSL("attach-stdout"))) - stdRedirections[qSL("out")] = 1; - if (clp.isSet(qSL("attach-stderr"))) - stdRedirections[qSL("err")] = 2; - bool restart = clp.isSet(qSL("restart")); + if (clp.isSet(u"attach-stdin"_s)) + stdRedirections[u"in"_s] = 0; + if (clp.isSet(u"attach-stdout"_s)) + stdRedirections[u"out"_s] = 1; + if (clp.isSet(u"attach-stderr"_s)) + stdRedirections[u"err"_s] = 2; + bool restart = clp.isSet(u"restart"_s); a.runLater(std::bind(startOrDebugApplication, QString(), @@ -368,13 +372,13 @@ int main(int argc, char *argv[]) break; } case DebugApplication: { - clp.addOption({ { qSL("i"), qSL("attach-stdin") }, qSL("Attach the app's stdin to the controller's stdin") }); - clp.addOption({ { qSL("o"), qSL("attach-stdout") }, qSL("Attach the app's stdout to the controller's stdout") }); - clp.addOption({ { qSL("e"), qSL("attach-stderr") }, qSL("Attach the app's stderr to the controller's stderr") }); - clp.addOption({ { qSL("r"), qSL("restart") }, qSL("Before starting, stop the application if it is already running") }); - clp.addPositionalArgument(qSL("debug-wrapper"), qSL("The debug-wrapper specification.")); - clp.addPositionalArgument(qSL("application-id"), qSL("The id of an installed application.")); - clp.addPositionalArgument(qSL("document-url"), qSL("The optional document-url."), qSL("[document-url]")); + clp.addOption({ { u"i"_s, u"attach-stdin"_s }, u"Attach the app's stdin to the controller's stdin"_s }); + clp.addOption({ { u"o"_s, u"attach-stdout"_s }, u"Attach the app's stdout to the controller's stdout"_s }); + clp.addOption({ { u"e"_s, u"attach-stderr"_s }, u"Attach the app's stderr to the controller's stderr"_s }); + clp.addOption({ { u"r"_s, u"restart"_s }, u"Before starting, stop the application if it is already running"_s }); + clp.addPositionalArgument(u"debug-wrapper"_s, u"The debug-wrapper specification."_s); + clp.addPositionalArgument(u"application-id"_s, u"The id of an installed application."_s); + clp.addPositionalArgument(u"document-url"_s, u"The optional document-url."_s, u"[document-url]"_s); clp.process(a); int args = int(clp.positionalArguments().size()); @@ -382,13 +386,13 @@ int main(int argc, char *argv[]) clp.showHelp(1); QMap<QString, int> stdRedirections; - if (clp.isSet(qSL("attach-stdin"))) - stdRedirections[qSL("in")] = 0; - if (clp.isSet(qSL("attach-stdout"))) - stdRedirections[qSL("out")] = 1; - if (clp.isSet(qSL("attach-stderr"))) - stdRedirections[qSL("err")] = 2; - bool restart = clp.isSet(qSL("restart")); + if (clp.isSet(u"attach-stdin"_s)) + stdRedirections[u"in"_s] = 0; + if (clp.isSet(u"attach-stdout"_s)) + stdRedirections[u"out"_s] = 1; + if (clp.isSet(u"attach-stderr"_s)) + stdRedirections[u"err"_s] = 2; + bool restart = clp.isSet(u"restart"_s); a.runLater(std::bind(startOrDebugApplication, clp.positionalArguments().at(1), @@ -407,8 +411,8 @@ int main(int argc, char *argv[]) break; case StopApplication: - clp.addOption({ { qSL("f"), qSL("force") }, qSL("Force kill the application.") }); - clp.addPositionalArgument(qSL("application-id"), qSL("The id of an installed application.")); + clp.addOption({ { u"f"_s, u"force"_s }, u"Force kill the application."_s }); + clp.addPositionalArgument(u"application-id"_s, u"The id of an installed application."_s); clp.process(a); if (clp.positionalArguments().size() != 2) @@ -416,7 +420,7 @@ int main(int argc, char *argv[]) a.runLater(std::bind(stopApplication, clp.positionalArguments().at(1), - clp.isSet(qSL("f")))); + clp.isSet(u"f"_s))); break; case ListApplications: @@ -425,8 +429,8 @@ int main(int argc, char *argv[]) break; case ShowApplication: - clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") }); - clp.addPositionalArgument(qSL("application-id"), qSL("The id of an installed application.")); + clp.addOption({ u"json"_s, u"Output in JSON format instead of YAML."_s }); + clp.addPositionalArgument(u"application-id"_s, u"The id of an installed application."_s); clp.process(a); if (clp.positionalArguments().size() != 2) @@ -434,7 +438,7 @@ int main(int argc, char *argv[]) a.runLater(std::bind(showApplication, clp.positionalArguments().at(1), - clp.isSet(qSL("json")))); + clp.isSet(u"json"_s))); break; case ListPackages: @@ -443,8 +447,8 @@ int main(int argc, char *argv[]) break; case ShowPackage: - clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") }); - clp.addPositionalArgument(qSL("package-id"), qSL("The id of an installed package.")); + clp.addOption({ u"json"_s, u"Output in JSON format instead of YAML."_s }); + clp.addPositionalArgument(u"package-id"_s, u"The id of an installed package."_s); clp.process(a); if (clp.positionalArguments().size() != 2) @@ -452,29 +456,29 @@ int main(int argc, char *argv[]) a.runLater(std::bind(showPackage, clp.positionalArguments().at(1), - clp.isSet(qSL("json")))); + clp.isSet(u"json"_s))); break; case InstallPackage: - clp.addOption({ { qSL("l"), qSL("location") }, qSL("Set a custom installation location (deprecated and ignored)."), qSL("installation-location"), qSL("internal-0") }); - clp.addOption({ { qSL("a"), qSL("acknowledge") }, qSL("Automatically acknowledge the installation (unattended mode).") }); - clp.addPositionalArgument(qSL("package"), qSL("The file name of the package; can be - for stdin.")); + clp.addOption({ { u"l"_s, u"location"_s }, u"Set a custom installation location (deprecated and ignored)."_s, u"installation-location"_s, u"internal-0"_s }); + clp.addOption({ { u"a"_s, u"acknowledge"_s }, u"Automatically acknowledge the installation (unattended mode)."_s }); + clp.addPositionalArgument(u"package"_s, u"The file name of the package; can be - for stdin."_s); clp.process(a); if (clp.positionalArguments().size() != 2) clp.showHelp(1); - if (clp.isSet(qSL("l"))) + if (clp.isSet(u"l"_s)) fprintf(stderr, "Ignoring the deprecated -l option.\n"); a.runLater(std::bind(installPackage, clp.positionalArguments().at(1), - clp.isSet(qSL("a")))); + clp.isSet(u"a"_s))); break; case RemovePackage: - clp.addOption({ { qSL("f"), qSL("force") }, qSL("Force removal of package.") }); - clp.addOption({ { qSL("k"), qSL("keep-documents") }, qSL("Keep the document folder of the application.") }); - clp.addPositionalArgument(qSL("package-id"), qSL("The id of an installed package.")); + clp.addOption({ { u"f"_s, u"force"_s }, u"Force removal of package."_s }); + clp.addOption({ { u"k"_s, u"keep-documents"_s }, u"Keep the document folder of the application."_s }); + clp.addPositionalArgument(u"package-id"_s, u"The id of an installed package."_s); clp.process(a); if (clp.positionalArguments().size() != 2) @@ -482,8 +486,8 @@ int main(int argc, char *argv[]) a.runLater(std::bind(removePackage, clp.positionalArguments().at(1), - clp.isSet(qSL("k")), - clp.isSet(qSL("f")))); + clp.isSet(u"k"_s), + clp.isSet(u"f"_s))); break; case ListInstallationTasks: @@ -492,12 +496,12 @@ int main(int argc, char *argv[]) break; case CancelInstallationTask: { - clp.addPositionalArgument(qSL("task-id"), qSL("The id of an active installation task.")); - clp.addOption({ { qSL("a"), qSL("all") }, qSL("Cancel all active installation tasks.") }); + clp.addPositionalArgument(u"task-id"_s, u"The id of an active installation task."_s); + clp.addOption({ { u"a"_s, u"all"_s }, u"Cancel all active installation tasks."_s }); clp.process(a); int args = clp.positionalArguments().size(); - bool all = clp.isSet(qSL("a")); + bool all = clp.isSet(u"a"_s); if (!(((args == 1) && all) || ((args == 2) && !all))) clp.showHelp(1); @@ -512,8 +516,8 @@ int main(int argc, char *argv[]) break; case ShowInstallationLocation: - clp.addPositionalArgument(qSL("installation-location"), qSL("The id of an installation location (deprecated and ignored).")); - clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") }); + clp.addPositionalArgument(u"installation-location"_s, u"The id of an installation location (deprecated and ignored)."_s); + clp.addOption({ u"json"_s, u"Output in JSON format instead of YAML."_s }); clp.process(a); if (clp.positionalArguments().size() > 2) @@ -522,7 +526,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Ignoring the deprecated installation-location.\n"); a.runLater(std::bind(showInstallationLocation, - clp.isSet(qSL("json")))); + clp.isSet(u"json"_s))); break; case ListInstances: @@ -531,16 +535,16 @@ int main(int argc, char *argv[]) break; case InjectIntentRequest: - clp.addPositionalArgument(qSL("intent-id"), qSL("The id of the intent.")); - clp.addPositionalArgument(qSL("parameters"), qSL("The optional parameters for this request."), qSL("[json-parameters]")); - clp.addOption({ qSL("requesting-application-id"), qSL("Fake the requesting application id."), qSL("id"), qSL(":sysui:") }); - clp.addOption({ qSL("application-id"), qSL("Specify the handling application id."), qSL("id") }); - clp.addOption({ qSL("broadcast"), qSL("Create a broadcast request.") }); + clp.addPositionalArgument(u"intent-id"_s, u"The id of the intent."_s); + clp.addPositionalArgument(u"parameters"_s, u"The optional parameters for this request."_s, u"[json-parameters]"_s); + clp.addOption({ u"requesting-application-id"_s, u"Fake the requesting application id."_s, u"id"_s, u":sysui:"_s }); + clp.addOption({ u"application-id"_s, u"Specify the handling application id."_s, u"id"_s }); + clp.addOption({ u"broadcast"_s, u"Create a broadcast request."_s }); clp.process(a); - bool isBroadcast = clp.isSet(qSL("broadcast")); - QString appId = clp.value(qSL("application-id")); - QString requestingAppId = clp.value(qSL("requesting-application-id")); + bool isBroadcast = clp.isSet(u"broadcast"_s); + QString appId = clp.value(u"application-id"_s); + QString requestingAppId = clp.value(u"requesting-application-id"_s); if (!appId.isEmpty() && isBroadcast) throw Exception("You cannot use --application-id and --broadcast at the same time."); @@ -621,7 +625,7 @@ void startOrDebugApplication(const QString &debugWrapper, const QString &appId, throw Exception(Error::IO, "failed to get exit code from application manager: %1").arg(getReply.error().message()); fprintf(stdout, "\n --- application has quit ---\n\n"); auto app = getReply.value(); - qApp->exit(app.value(qSL("lastExitCode"), 1).toInt()); + qApp->exit(app.value(u"lastExitCode"_s, 1).toInt()); } }); } @@ -744,7 +748,7 @@ void installPackage(const QString &package, bool acknowledge) Q_DECL_NOEXCEPT_EX { QString packageFile = package; - if (package == qL1S("-")) { // sent via stdin + if (package == u"-") { // sent via stdin bool success = false; QTemporaryFile *tf = new QTemporaryFile(qApp); @@ -788,7 +792,7 @@ void installPackage(const QString &package, bool acknowledge) Q_DECL_NOEXCEPT_EX qApp, [](const QString &taskId, const QVariantMap &metadata) { if (taskId != installationId) return; - QString packageId = metadata.value(qSL("packageId")).toString(); + QString packageId = metadata.value(u"packageId"_s).toString(); if (packageId.isEmpty()) throw Exception(Error::IO, "could not find a valid package id in the package"); fprintf(stdout, "Acknowledging package installation for '%s'...\n", qPrintable(packageId)); @@ -993,7 +997,7 @@ void showInstallationLocation(bool asJson) Q_DECL_NOEXCEPT_EXPR(false) void listInstances() { QString dir = QDir::temp().absolutePath() % u'/'; - QString suffix = qSL("io.qt.ApplicationManager.dbus"); + QString suffix = u"io.qt.ApplicationManager.dbus"_s; QDirIterator dit(dir, { u'*' % suffix }); while (dit.hasNext()) { @@ -1001,7 +1005,7 @@ void listInstances() name.chop(suffix.length()); name = name.mid(dir.length()); if (name.isEmpty()) { - name = qSL("(no instance id)"); + name = u"(no instance id)"_s; } else { name.chop(1); // remove the '-' separator name = u'"' % name % u'"'; diff --git a/src/tools/launcher-qml/launcher-qml.cpp b/src/tools/launcher-qml/launcher-qml.cpp index f8cb413e..90d7441c 100644 --- a/src/tools/launcher-qml/launcher-qml.cpp +++ b/src/tools/launcher-qml/launcher-qml.cpp @@ -51,6 +51,8 @@ #include "launcher-qml_p.h" #include "applicationmanagerwindow.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM @@ -61,10 +63,10 @@ int main(int argc, char *argv[]) ProcessTitle::adjustArgumentCount(argc); - QCoreApplication::setApplicationName(qSL("Qt Application Manager QML Launcher")); - QCoreApplication::setOrganizationName(qSL("QtProject")); - QCoreApplication::setOrganizationDomain(qSL("qt-project.org")); - QCoreApplication::setApplicationVersion(qSL(QT_AM_VERSION_STR)); + QCoreApplication::setApplicationName(u"Qt Application Manager QML Launcher"_s); + QCoreApplication::setOrganizationName(u"QtProject"_s); + QCoreApplication::setOrganizationDomain(u"qt-project.org"_s); + QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_AM_VERSION_STR)); if (qEnvironmentVariableIntValue("AM_NO_DLT_LOGGING") == 1) Logging::setDltEnabled(false); @@ -89,21 +91,21 @@ int main(int argc, char *argv[]) QCommandLineParser clp; clp.addHelpOption(); - clp.addOption({ qSL("qml-debug"), qSL("Enables QML debugging and profiling.") }); - clp.addOption({ qSL("quicklaunch"), qSL("Starts the launcher in the quicklaunching mode.") }); - clp.addOption({ qSL("directload") , qSL("The info.yaml to start (you can add '@<appid>' to start a specific app within the package, instead of the first one)."), qSL("info.yaml") }); + clp.addOption({ u"qml-debug"_s, u"Enables QML debugging and profiling."_s }); + clp.addOption({ u"quicklaunch"_s, u"Starts the launcher in the quicklaunching mode."_s }); + clp.addOption({ u"directload"_s , u"The info.yaml to start (you can add '@<appid>' to start a specific app within the package, instead of the first one)."_s, u"info.yaml"_s }); clp.process(am); - bool quicklaunched = clp.isSet(qSL("quicklaunch")); - QString directLoadManifest = clp.value(qSL("directload")); + bool quicklaunched = clp.isSet(u"quicklaunch"_s); + QString directLoadManifest = clp.value(u"directload"_s); if (directLoadManifest.isEmpty()) am.loadConfiguration(); - CrashHandler::setCrashActionConfiguration(am.runtimeConfiguration().value(qSL("crashAction")).toMap()); + CrashHandler::setCrashActionConfiguration(am.runtimeConfiguration().value(u"crashAction"_s).toMap()); // the verbose flag has already been factored into the rules: am.setupLogging(false, am.loggingRules(), QString(), am.useAMConsoleLogger()); - am.setupQmlDebugging(clp.isSet(qSL("qml-debug"))); + am.setupQmlDebugging(clp.isSet(u"qml-debug"_s)); am.setupOpenGL(am.openGLConfiguration()); am.setupIconTheme(am.iconThemeSearchPaths(), am.iconThemeName()); am.registerWaylandExtensions(); @@ -114,14 +116,14 @@ int main(int argc, char *argv[]) if (!directLoadManifest.isEmpty()) { QString directLoadAppId; - int appPos = directLoadManifest.indexOf(qSL("@")); + int appPos = directLoadManifest.indexOf(u"@"_s); if (appPos > 0) { directLoadAppId = directLoadManifest.mid(appPos + 1); directLoadManifest.truncate(appPos); } QFileInfo fi(directLoadManifest); - if (!fi.exists() || fi.fileName() != qSL("info.yaml")) + if (!fi.exists() || fi.fileName() != u"info.yaml"_s) throw Exception("--directload needs a valid info.yaml file as parameter"); directLoadManifest = fi.absoluteFilePath(); new Controller(&am, quicklaunched, qMakePair(directLoadManifest, directLoadAppId)); @@ -152,7 +154,7 @@ Controller::Controller(ApplicationMain *am, bool quickLaunched, const QPair<QStr m_configuration = am->runtimeConfiguration(); - const QStringList resources = variantToStringList(m_configuration.value(qSL("resources"))); + const QStringList resources = variantToStringList(m_configuration.value(u"resources"_s)); for (const QString &resource: resources) { const QString path = QFileInfo(resource).isRelative() ? am->baseDir() + resource : resource; @@ -164,7 +166,7 @@ Controller::Controller(ApplicationMain *am, bool quickLaunched, const QPair<QStr } QString absolutePluginPath; - QStringList pluginPaths = variantToStringList(m_configuration.value(qSL("pluginPaths"))); + QStringList pluginPaths = variantToStringList(m_configuration.value(u"pluginPaths"_s)); for (QString &path : pluginPaths) { if (QFileInfo(path).isRelative()) path.prepend(am->baseDir()); @@ -180,7 +182,7 @@ Controller::Controller(ApplicationMain *am, bool quickLaunched, const QPair<QStr } QString absoluteImportPath; - QStringList importPaths = variantToStringList(m_configuration.value(qSL("importPaths"))); + QStringList importPaths = variantToStringList(m_configuration.value(u"importPaths"_s)); for (QString &path : importPaths) { const QFileInfo fi(path); if (fi.isNativePath() && fi.isAbsolute() && absoluteImportPath.isEmpty()) @@ -233,7 +235,7 @@ Controller::Controller(ApplicationMain *am, bool quickLaunched, const QPair<QStr }, Qt::QueuedConnection); } - const QString quicklaunchQml = m_configuration.value((qSL("quicklaunchQml"))).toString(); + const QString quicklaunchQml = m_configuration.value((u"quicklaunchQml"_s)).toString(); if (!quicklaunchQml.isEmpty() && quickLaunched) { QQmlComponent quicklaunchComp(&m_engine, filePathToUrl(quicklaunchQml, am->baseDir())); if (!quicklaunchComp.isError()) { @@ -256,25 +258,25 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile return; m_launched = true; - static QString applicationId = application.value(qSL("id")).toString(); + static QString applicationId = application.value(u"id"_s).toString(); auto *am = ApplicationMain::instance(); am->setApplication(convertFromDBusVariant(application).toMap()); am->setSystemProperties(convertFromDBusVariant(systemProperties).toMap()); if (m_quickLaunched) { - //StartupTimer::instance()->createReport(applicationId + qSL(" [process launch]")); + //StartupTimer::instance()->createReport(applicationId + u" [process launch]"_s); StartupTimer::instance()->reset(); } else { StartupTimer::instance()->checkpoint("starting application"); } //Change the DLT Application description, to easily identify the application on the DLT logs. - const QVariantMap dlt = qdbus_cast<QVariantMap>(application.value(qSL("dlt"))); - QByteArray dltId = dlt.value(qSL("id")).toString().toLocal8Bit(); - QByteArray dltDescription = dlt.value(qSL("description")).toString().toLocal8Bit(); + const QVariantMap dlt = qdbus_cast<QVariantMap>(application.value(u"dlt"_s)); + QByteArray dltId = dlt.value(u"id"_s).toString().toLocal8Bit(); + QByteArray dltDescription = dlt.value(u"description"_s).toString().toLocal8Bit(); if (dltId.isEmpty()) { char uniqueId[5]; - qsnprintf(uniqueId, sizeof(uniqueId), "A%03d", application.value(qSL("uniqueNumber")).toInt()); + qsnprintf(uniqueId, sizeof(uniqueId), "A%03d", application.value(u"uniqueNumber"_s).toInt()); dltId = uniqueId; } if (dltDescription.isEmpty()) @@ -285,7 +287,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile // Dress up the ps output to make it easier to correlate all the launcher processes ProcessTitle::augmentCommand(applicationId.toLocal8Bit().constData()); - QVariantMap runtimeParameters = qdbus_cast<QVariantMap>(application.value(qSL("runtimeParameters"))); + QVariantMap runtimeParameters = qdbus_cast<QVariantMap>(application.value(u"runtimeParameters"_s)); qCDebug(LogQmlRuntime) << "loading" << applicationId << "- main:" << qmlFile << "- document:" << document << "- mimeType:" << mimeType << "- parameters:" << runtimeParameters @@ -300,11 +302,11 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile if (!applicationId.isEmpty()) { // shorten application id to make the debug output more readable - auto sl = applicationId.split(qL1C('.')); + auto sl = applicationId.split(u'.'); applicationId.clear(); for (int i = 0; i < sl.size() - 1; ++i) { applicationId.append(sl.at(i).at(0)); - applicationId.append(qL1C('.')); + applicationId.append(u'.'); } applicationId.append(sl.last()); Logging::setApplicationId(applicationId.toLocal8Bit()); @@ -314,7 +316,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile return; } - QVariant resVar = runtimeParameters.value(qSL("resources")); + QVariant resVar = runtimeParameters.value(u"resources"_s); const QVariantList resources = (resVar.metaType() == QMetaType::fromType<QString>()) ? QVariantList{resVar} : qdbus_cast<QVariantList>(resVar); @@ -337,7 +339,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile } if (m_applicationInterface) { - m_engine.rootContext()->setContextProperty(qSL("ApplicationInterface"), m_applicationInterface); + m_engine.rootContext()->setContextProperty(u"ApplicationInterface"_s, m_applicationInterface); connect(m_applicationInterface, &ApplicationInterface::slowAnimationsChanged, ApplicationMain::instance(), &ApplicationMain::setSlowAnimations); @@ -355,7 +357,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile QCoreApplication::instance()->installEventFilter(this); QStringList systemStartupPluginPaths; - const QDir systemStartupPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + qSL("appman_startup")); + const QDir systemStartupPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + u"appman_startup"_s); for (const auto &pluginName : systemStartupPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { const QString filePath = systemStartupPluginDir.absoluteFilePath(pluginName); if (!QLibrary::isLibrary(filePath)) @@ -363,7 +365,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile systemStartupPluginPaths += filePath; } - QStringList startupPluginFiles = variantToStringList(m_configuration.value(qSL("plugins")).toMap().value(qSL("startup"))); + QStringList startupPluginFiles = variantToStringList(m_configuration.value(u"plugins"_s).toMap().value(u"startup"_s)); QVector<StartupInterface *> startupPlugins; try { startupPlugins = loadPlugins<StartupInterface>("startup", systemStartupPluginPaths + startupPluginFiles); @@ -375,8 +377,8 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile for (StartupInterface *iface : std::as_const(startupPlugins)) iface->initialize(m_applicationInterface ? m_applicationInterface->systemProperties() : QVariantMap()); - bool loadDummyData = runtimeParameters.value(qSL("loadDummyData")).toBool() - || m_configuration.value(qSL("loadDummydata")).toBool(); + bool loadDummyData = runtimeParameters.value(u"loadDummyData"_s).toBool() + || m_configuration.value(u"loadDummydata"_s).toBool(); if (loadDummyData) { qCWarning(LogDeployment) << "Loading dummy data is deprecated and will be removed soon"; @@ -384,7 +386,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile loadQmlDummyDataFiles(&m_engine, QFileInfo(qmlFileStr).path()); } - QVariant pluginPaths = runtimeParameters.value(qSL("pluginPaths")); + QVariant pluginPaths = runtimeParameters.value(u"pluginPaths"_s); const QVariantList ppvl = (pluginPaths.metaType() == QMetaType::fromType<QString>()) ? QVariantList{pluginPaths} : qdbus_cast<QVariantList>(pluginPaths); @@ -398,7 +400,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile } qCDebug(LogQmlRuntime) << "Plugin paths:" << qApp->libraryPaths(); - QVariant imports = runtimeParameters.value(qSL("importPaths")); + QVariant imports = runtimeParameters.value(u"importPaths"_s); const QVariantList ipvl = (imports.metaType() == QMetaType::fromType<QString>()) ? QVariantList{imports} : qdbus_cast<QVariantList>(imports); diff --git a/src/tools/package-server/pshttpinterface.cpp b/src/tools/package-server/pshttpinterface.cpp index a40c9b8a..de99f764 100644 --- a/src/tools/package-server/pshttpinterface.cpp +++ b/src/tools/package-server/pshttpinterface.cpp @@ -42,9 +42,9 @@ void PSHttpInterface::listen() { const auto hostStr = d->cfg->listenUrl.host(); QHostAddress host; - if (hostStr == u"any"_s) + if (hostStr == u"any") host = QHostAddress(QHostAddress::Any); - else if (hostStr == u"localhost"_s) + else if (hostStr == u"localhost") host = QHostAddress(QHostAddress::LocalHost); else host = QHostAddress(hostStr); diff --git a/src/tools/packager/packager.cpp b/src/tools/packager/packager.cpp index 80a3b165..e7747d0e 100644 --- a/src/tools/packager/packager.cpp +++ b/src/tools/packager/packager.cpp @@ -21,6 +21,9 @@ #include <QtAppManPackage/packageutilities.h> #include "packagingjob.h" +using namespace Qt::StringLiterals; + + QT_USE_NAMESPACE_AM enum Command { @@ -55,7 +58,9 @@ static Command command(QCommandLineParser &clp) for (uint i = 0; i < sizeof(commandTable) / sizeof(commandTable[0]); ++i) { if (cmd == commandTable[i].name) { clp.clearPositionalArguments(); - clp.addPositionalArgument(qL1S(cmd), qL1S(commandTable[i].description), qL1S(cmd)); + clp.addPositionalArgument(QString::fromLatin1(cmd), + QString::fromLatin1(commandTable[i].description), + QString::fromLatin1(cmd)); return commandTable[i].command; } } @@ -68,10 +73,10 @@ int main(int argc, char *argv[]) // enable OpenSSL3 to load old certificates Cryptography::enableOpenSsl3LegacyProvider(); - QCoreApplication::setApplicationName(qSL("Qt ApplicationManager Packager")); - QCoreApplication::setOrganizationName(qSL("QtProject")); - QCoreApplication::setOrganizationDomain(qSL("qt-project.org")); - QCoreApplication::setApplicationVersion(qSL(QT_AM_VERSION_STR)); + QCoreApplication::setApplicationName(u"Qt ApplicationManager Packager"_s); + QCoreApplication::setOrganizationName(u"QtProject"_s); + QCoreApplication::setOrganizationDomain(u"qt-project.org"_s); + QCoreApplication::setApplicationVersion(QString::fromLatin1(QT_AM_VERSION_STR)); QCoreApplication a(argc, argv); @@ -91,12 +96,12 @@ int main(int argc, char *argv[]) " appman-packager <command> --help"; QCommandLineParser clp; - clp.setApplicationDescription(qSL("\n") + QCoreApplication::applicationName() + qL1S(desc)); + clp.setApplicationDescription(u"\n"_s + QCoreApplication::applicationName() + QString::fromLatin1(desc)); clp.addHelpOption(); clp.addVersionOption(); - clp.addPositionalArgument(qSL("command"), qSL("The command to execute.")); + clp.addPositionalArgument(u"command"_s, u"The command to execute."_s); // ignore unknown options for now -- the sub-commands may need them later clp.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments); @@ -114,22 +119,22 @@ int main(int argc, char *argv[]) switch (command(clp)) { default: case NoCommand: - if (clp.isSet(qSL("version"))) + if (clp.isSet(u"version"_s)) clp.showVersion(); - if (clp.isSet(qSL("help"))) + if (clp.isSet(u"help"_s)) clp.showHelp(); clp.showHelp(1); break; case CreatePackage: { - clp.addOption({ qSL("verbose"), qSL("Dump the package's meta-data header and footer information to stdout.") }); - clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") }); - clp.addOption({{ qSL("extra-metadata"), qSL("m") }, qSL("Add extra meta-data to the package, supplied on the command line."), qSL("yaml-snippet") }); - clp.addOption({{ qSL("extra-metadata-file"), qSL("M") }, qSL("Add extra meta-data to the package, read from file."), qSL("yaml-file") }); - clp.addOption({{ qSL("extra-signed-metadata"), qSL("s") }, qSL("Add extra, digitally signed, meta-data to the package, supplied on the command line."), qSL("yaml-snippet") }); - clp.addOption({{ qSL("extra-signed-metadata-file"), qSL("S") }, qSL("Add extra, digitally signed, meta-data to the package, read from file."), qSL("yaml-file") }); - clp.addPositionalArgument(qSL("package"), qSL("The file name of the created package.")); - clp.addPositionalArgument(qSL("source-directory"), qSL("The package's content root directory.")); + clp.addOption({ u"verbose"_s, u"Dump the package's meta-data header and footer information to stdout."_s }); + clp.addOption({ u"json"_s, u"Output in JSON format instead of YAML."_s }); + clp.addOption({{ u"extra-metadata"_s, u"m"_s }, u"Add extra meta-data to the package, supplied on the command line."_s, u"yaml-snippet"_s }); + clp.addOption({{ u"extra-metadata-file"_s, u"M"_s }, u"Add extra meta-data to the package, read from file."_s, u"yaml-file"_s }); + clp.addOption({{ u"extra-signed-metadata"_s, u"s"_s }, u"Add extra, digitally signed, meta-data to the package, supplied on the command line."_s, u"yaml-snippet"_s }); + clp.addOption({{ u"extra-signed-metadata-file"_s, u"S"_s }, u"Add extra, digitally signed, meta-data to the package, read from file."_s, u"yaml-file"_s }); + clp.addPositionalArgument(u"package"_s, u"The file name of the created package."_s); + clp.addPositionalArgument(u"source-directory"_s, u"The package's content root directory."_s); clp.process(a); if (clp.positionalArguments().size() != 3) @@ -155,13 +160,13 @@ int main(int argc, char *argv[]) } catch (const Exception &e) { throw Exception(Error::IO, "in --extra-%1metadata%2 %3: %4") .arg(isSigned ? "signed-" : "").arg(md.second.isEmpty() ? "": "-file") - .arg(md.second.isEmpty() ? qSL("option") : md.second) + .arg(md.second.isEmpty() ? u"option"_s : md.second) .arg(e.errorString()); } if (docs.size() < 1) { throw Exception("Could not parse --extra-%1metadata%2 %3: Invalid document format") .arg(isSigned ? "signed-" : "").arg(md.second.isEmpty() ? "": "-file") - .arg(md.second.isEmpty() ? qSL("option") : md.second); + .arg(md.second.isEmpty() ? u"option"_s : md.second); } for (const auto &doc : docs) recursiveMergeVariantMap(result, doc.toMap()); @@ -169,27 +174,27 @@ int main(int argc, char *argv[]) return result; }; - QVariantMap extraMetaDataMap = parseYamlMetada(clp.values(qSL("extra-metadata")), - clp.values(qSL("extra-metadata-file")), + QVariantMap extraMetaDataMap = parseYamlMetada(clp.values(u"extra-metadata"_s), + clp.values(u"extra-metadata-file"_s), false); - QVariantMap extraSignedMetaDataMap = parseYamlMetada(clp.values(qSL("extra-signed-metadata")), - clp.values(qSL("extra-signed-metadata-file")), + QVariantMap extraSignedMetaDataMap = parseYamlMetada(clp.values(u"extra-signed-metadata"_s), + clp.values(u"extra-signed-metadata-file"_s), true); p.reset(PackagingJob::create(clp.positionalArguments().at(1), clp.positionalArguments().at(2), extraMetaDataMap, extraSignedMetaDataMap, - clp.isSet(qSL("json")))); + clp.isSet(u"json"_s))); break; } case DevSignPackage: - clp.addOption({ qSL("verbose"), qSL("Dump the package's meta-data header and footer information to stdout.") }); - clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") }); - clp.addPositionalArgument(qSL("package"), qSL("File name of the unsigned package (input).")); - clp.addPositionalArgument(qSL("signed-package"), qSL("File name of the signed package (output).")); - clp.addPositionalArgument(qSL("certificate"), qSL("PKCS#12 certificate file.")); - clp.addPositionalArgument(qSL("password"), qSL("Password for the PKCS#12 certificate.")); + clp.addOption({ u"verbose"_s, u"Dump the package's meta-data header and footer information to stdout."_s }); + clp.addOption({ u"json"_s, u"Output in JSON format instead of YAML."_s }); + clp.addPositionalArgument(u"package"_s, u"File name of the unsigned package (input)."_s); + clp.addPositionalArgument(u"signed-package"_s, u"File name of the signed package (output)."_s); + clp.addPositionalArgument(u"certificate"_s, u"PKCS#12 certificate file."_s); + clp.addPositionalArgument(u"password"_s, u"Password for the PKCS#12 certificate."_s); clp.process(a); if (clp.positionalArguments().size() != 5) @@ -199,13 +204,13 @@ int main(int argc, char *argv[]) clp.positionalArguments().at(2), clp.positionalArguments().at(3), clp.positionalArguments().at(4), - clp.isSet(qSL("json")))); + clp.isSet(u"json"_s))); break; case DevVerifyPackage: - clp.addOption({ qSL("verbose"), qSL("Print details regarding the verification to stdout.") }); - clp.addPositionalArgument(qSL("package"), qSL("File name of the signed package (input).")); - clp.addPositionalArgument(qSL("certificates"), qSL("The developer's CA certificate file(s)."), qSL("certificates...")); + clp.addOption({ u"verbose"_s, u"Print details regarding the verification to stdout."_s }); + clp.addPositionalArgument(u"package"_s, u"File name of the signed package (input)."_s); + clp.addPositionalArgument(u"certificates"_s, u"The developer's CA certificate file(s)."_s, u"certificates..."_s); clp.process(a); if (clp.positionalArguments().size() < 3) @@ -216,13 +221,13 @@ int main(int argc, char *argv[]) break; case StoreSignPackage: - clp.addOption({ qSL("verbose"), qSL("Dump the package's meta-data header and footer information to stdout.") }); - clp.addOption({ qSL("json"), qSL("Output in JSON format instead of YAML.") }); - clp.addPositionalArgument(qSL("package"), qSL("File name of the unsigned package (input).")); - clp.addPositionalArgument(qSL("signed-package"), qSL("File name of the signed package (output).")); - clp.addPositionalArgument(qSL("certificate"), qSL("PKCS#12 certificate file.")); - clp.addPositionalArgument(qSL("password"), qSL("Password for the PKCS#12 certificate.")); - clp.addPositionalArgument(qSL("hardware-id"), qSL("Unique hardware id to which this package gets bound.")); + clp.addOption({ u"verbose"_s, u"Dump the package's meta-data header and footer information to stdout."_s }); + clp.addOption({ u"json"_s, u"Output in JSON format instead of YAML."_s }); + clp.addPositionalArgument(u"package"_s, u"File name of the unsigned package (input)."_s); + clp.addPositionalArgument(u"signed-package"_s, u"File name of the signed package (output)."_s); + clp.addPositionalArgument(u"certificate"_s, u"PKCS#12 certificate file."_s); + clp.addPositionalArgument(u"password"_s, u"Password for the PKCS#12 certificate."_s); + clp.addPositionalArgument(u"hardware-id"_s, u"Unique hardware id to which this package gets bound."_s); clp.process(a); if (clp.positionalArguments().size() != 6) @@ -233,14 +238,14 @@ int main(int argc, char *argv[]) clp.positionalArguments().at(3), clp.positionalArguments().at(4), clp.positionalArguments().at(5), - clp.isSet(qSL("json")))); + clp.isSet(u"json"_s))); break; case StoreVerifyPackage: - clp.addOption({ qSL("verbose"), qSL("Print details regarding the verification to stdout.") }); - clp.addPositionalArgument(qSL("package"), qSL("File name of the signed package (input).")); - clp.addPositionalArgument(qSL("certificates"), qSL("Store CA certificate file(s)."), qSL("certificates...")); - clp.addPositionalArgument(qSL("hardware-id"), qSL("Unique hardware id to which this package was bound.")); + clp.addOption({ u"verbose"_s, u"Print details regarding the verification to stdout."_s }); + clp.addPositionalArgument(u"package"_s, u"File name of the signed package (input)."_s); + clp.addPositionalArgument(u"certificates"_s, u"Store CA certificate file(s)."_s, u"certificates..."_s); + clp.addPositionalArgument(u"hardware-id"_s, u"Unique hardware id to which this package was bound."_s); clp.process(a); if (clp.positionalArguments().size() < 4) @@ -252,17 +257,17 @@ int main(int argc, char *argv[]) break; case YamlToJson: { - clp.addOption({{ qSL("i"), qSL("document-index") }, qSL("Only output the specified YAML sub-document."), qSL("index") }); - clp.addPositionalArgument(qSL("yaml-file"), qSL("YAML file name, defaults to stdin (input).")); + clp.addOption({{ u"i"_s, u"document-index"_s }, u"Only output the specified YAML sub-document."_s, u"index"_s }); + clp.addPositionalArgument(u"yaml-file"_s, u"YAML file name, defaults to stdin (input)."_s); clp.process(a); if (clp.positionalArguments().size() > 2) clp.showHelp(1); QString yamlName = (clp.positionalArguments().size() == 2) ? clp.positionalArguments().at(1) - : qSL("-"); + : u"-"_s; QFile yaml(yamlName); - if (yamlName == qL1S("-")) { + if (yamlName == u"-") { if (!yaml.open(0, QIODevice::ReadOnly)) throw Exception("Could not open stdin for reading"); } else if (!yaml.open(QIODevice::ReadOnly)) { @@ -271,11 +276,11 @@ int main(int argc, char *argv[]) QVector<QVariant> docs = YamlParser::parseAllDocuments(yaml.readAll()); QJsonDocument json; - if (clp.isSet(qSL("i"))) { + if (clp.isSet(u"i"_s)) { bool isInt; - int index = clp.value(qSL("i")).toInt(&isInt); + int index = clp.value(u"i"_s).toInt(&isInt); if (!isInt || index < 0) { - throw Exception("Invalid document index specified: %1").arg(clp.value(qSL("i"))); + throw Exception("Invalid document index specified: %1").arg(clp.value(u"i"_s)); } else if (index >= docs.size()) { throw Exception("Requested YAML sub document at index %1, but only indices 0 to %2 are available in this document.") .arg(index).arg(docs.size() - 1); @@ -294,7 +299,7 @@ int main(int argc, char *argv[]) return 2; p->execute(); - if (clp.isSet(qSL("verbose")) && !p->output().isEmpty()) + if (clp.isSet(u"verbose"_s) && !p->output().isEmpty()) fprintf(stdout, "%s\n", qPrintable(p->output())); return p->resultCode(); } catch (const Exception &e) { diff --git a/src/tools/packager/packagingjob.cpp b/src/tools/packager/packagingjob.cpp index d53c7366..86b448eb 100644 --- a/src/tools/packager/packagingjob.cpp +++ b/src/tools/packager/packagingjob.cpp @@ -28,6 +28,8 @@ #include "packagingjob.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM // this corresponds to the -b parameter for mkfs.ext2 in sudo.cpp @@ -116,7 +118,7 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) if (m_destinationName.isEmpty()) throw Exception(Error::Package, "no destination package name given"); - QFileInfo(m_destinationName).absoluteDir().mkpath(qSL(".")); + QFileInfo(m_destinationName).absoluteDir().mkpath(u"."_s); QSaveFile destination(m_destinationName); if (!destination.open(QIODevice::WriteOnly | QIODevice::Truncate)) @@ -129,7 +131,7 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) throw Exception(Error::Package, "source %1 is not a directory").arg(m_sourceDir); // check metadata - QString infoName = qSL("info.yaml"); + QString infoName = u"info.yaml"_s; std::unique_ptr<PackageInfo> package(PackageInfo::fromManifest(source.absoluteFilePath(infoName))); // warn the user that old-style manifests are going to be deprecated in the future @@ -139,7 +141,7 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) YamlParser p(f.readAll()); auto header = p.parseHeader(); - if (header.first == qL1S("am-application") && header.second == 1) { + if (header.first == u"am-application" && header.second == 1) { fprintf(stderr, "WARNING: 'info.yaml' is still using the old format (type '%s', version '%d').\n" " This is going to be deprecated in a future release.\n", qPrintable(header.first), header.second); @@ -205,7 +207,7 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) // QDirIterator::filePath() returns absolute paths, although the naming suggests otherwise entryPath = entryPath.mid(canonicalSourcePath.size() + 1); - if (entryInfo.fileName().startsWith(qL1S("--PACKAGE-"))) + if (entryInfo.fileName().startsWith(u"--PACKAGE-")) throw Exception(Error::Package, "file names starting with --PACKAGE- are reserved by the packager (found: %1)").arg(entryPath); estimatedImageSize += (quint64(entryInfo.size()) + Ext2BlockSize - 1) / Ext2BlockSize; @@ -266,22 +268,22 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) // check signatures if (m_mode == DeveloperVerify) { if (report.developerSignature().isEmpty()) { - m_output = qSL("no developer signature"); + m_output = u"no developer signature"_s; m_resultCode = 1; } else { Signature sig(report.digest()); if (!sig.verify(report.developerSignature(), certificates)) { - m_output = qSL("invalid developer signature (") + sig.errorString() + qSL(")"); + m_output = u"invalid developer signature ("_s + sig.errorString() + u")"_s; m_resultCode = 2; } else { - m_output = qSL("valid developer signature"); + m_output = u"valid developer signature"_s; } } break; // done with DeveloperVerify } else if (m_mode == StoreVerify) { if (report.storeSignature().isEmpty()) { - m_output = qSL("no store signature"); + m_output = u"no store signature"_s; m_resultCode = 1; } else { QByteArray sigDigest = report.digest(); @@ -290,10 +292,10 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) Signature sig(sigDigest); if (!sig.verify(report.storeSignature(), certificates)) { - m_output = qSL("invalid store signature (") + sig.errorString() + qSL(")"); + m_output = u"invalid store signature ("_s + sig.errorString() + u")"_s; m_resultCode = 2; } else { - m_output = qSL("valid store signature"); + m_output = u"valid store signature"_s; } } diff --git a/src/tools/testrunner/amtest.cpp b/src/tools/testrunner/amtest.cpp index e4f4da90..52d3912b 100644 --- a/src/tools/testrunner/amtest.cpp +++ b/src/tools/testrunner/amtest.cpp @@ -12,6 +12,8 @@ #include "amtest.h" #include "utilities.h" +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE_AM @@ -41,7 +43,7 @@ QVariant AmTest::buildConfig() const QString AmTest::qtVersion() const { - return QLatin1String(QT_VERSION_STR); + return QString::fromLatin1(QT_VERSION_STR); } static QtMsgType convertMsgType(AmTest::MsgType type) @@ -94,31 +96,31 @@ bool AmTest::dirExists(const QString &dir) QVariantMap AmTest::runProgram(const QStringList &commandLine) { QVariantMap result { - { qSL("stdout"), QString() }, - { qSL("stderr"), QString() }, - { qSL("exitCode"), -1 }, - { qSL("error"), QString() }, + { u"stdout"_s, QString() }, + { u"stderr"_s, QString() }, + { u"exitCode"_s, -1 }, + { u"error"_s, QString() }, }; if (commandLine.isEmpty()) { - result[qSL("error")] = qL1S("no command"); + result[u"error"_s] = u"no command"_s; } else { #if QT_CONFIG(process) QProcess process; process.start(commandLine[0], commandLine.mid(1)); if (!process.waitForStarted(5000 * timeoutFactor())) { - result[qSL("error")] = qL1S("could not start process"); + result[u"error"_s] = u"could not start process"_s; } else { if (!process.waitForFinished(5000 * timeoutFactor())) - result[qSL("error")] = qL1S("process did not exit"); + result[u"error"_s] = u"process did not exit"_s; else - result[qSL("exitCode")] = process.exitCode(); + result[u"exitCode"_s] = process.exitCode(); - result[qSL("stdout")] = QString::fromLocal8Bit(process.readAllStandardOutput()); - result[qSL("stderr")] = QString::fromLocal8Bit(process.readAllStandardError()); + result[u"stdout"_s] = QString::fromLocal8Bit(process.readAllStandardOutput()); + result[u"stderr"_s] = QString::fromLocal8Bit(process.readAllStandardError()); } #else - result[qSL("error")] = qL1S("runProgram is not available in this build"); + result[u"error"_s] = u"runProgram is not available in this build"_s; #endif } return result; diff --git a/src/window-lib/waylandcompositor.cpp b/src/window-lib/waylandcompositor.cpp index ead5ab12..0dc06dc6 100644 --- a/src/window-lib/waylandcompositor.cpp +++ b/src/window-lib/waylandcompositor.cpp @@ -158,7 +158,7 @@ WaylandCompositor::WaylandCompositor(QQuickWindow *window, const QString &waylan create(); // set a sensible default keymap - defaultSeat()->keymap()->setLayout(QLocale::system().name().section(qL1C('_'), 1, 1).toLower()); + defaultSeat()->keymap()->setLayout(QLocale::system().name().section(u'_', 1, 1).toLower()); } WaylandCompositor::~WaylandCompositor() diff --git a/src/window-lib/waylandwindow.cpp b/src/window-lib/waylandwindow.cpp index f0b6e818..77862ce2 100644 --- a/src/window-lib/waylandwindow.cpp +++ b/src/window-lib/waylandwindow.cpp @@ -15,6 +15,9 @@ #include <QWaylandWlShellSurface> +using namespace Qt::StringLiterals; + + QT_BEGIN_NAMESPACE_AM bool WaylandWindow::m_watchdogEnabled = true; @@ -151,9 +154,9 @@ QString WaylandWindow::applicationId() const if (application()) return application()->id(); else if (m_surface && m_surface->client()) - return qSL("[pid: %1]").arg(m_surface->client()->processId()); + return u"[pid: %1]"_s.arg(m_surface->client()->processId()); else - return qSL("[external app]"); + return u"[external app]"_s; } QSize WaylandWindow::size() const diff --git a/src/window-lib/windowitem.cpp b/src/window-lib/windowitem.cpp index d1fef2db..aba78978 100644 --- a/src/window-lib/windowitem.cpp +++ b/src/window-lib/windowitem.cpp @@ -23,6 +23,8 @@ #include <QQmlProperty> #include <QtQuick/private/qquickitem_p.h> +using namespace Qt::StringLiterals; + /*! \qmltype WindowItem \inqmlmodule QtApplicationManager.SystemUI @@ -376,7 +378,7 @@ void WindowItem::InProcessImpl::setupSecondaryView() m_shaderEffectSource->setParent(q); m_shaderEffectSource->setParentItem(q); - QQmlProperty::write(m_shaderEffectSource, QStringLiteral("sourceItem"), + QQmlProperty::write(m_shaderEffectSource, u"sourceItem"_s, QVariant::fromValue(m_inProcessWindow->rootItem())); } } diff --git a/src/window-lib/windowmanager.cpp b/src/window-lib/windowmanager.cpp index 47226d71..28bd3def 100644 --- a/src/window-lib/windowmanager.cpp +++ b/src/window-lib/windowmanager.cpp @@ -37,6 +37,8 @@ #include "qmlinprocapplicationmanagerwindowimpl.h" #include "systemframetimerimpl.h" +using namespace Qt::StringLiterals; + /*! \qmltype WindowManager @@ -271,7 +273,7 @@ bool WindowManager::isRunningOnDesktop() const #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) return true; #else - return qApp->platformName() == qSL("xcb"); + return qApp->platformName() == u"xcb"; #endif } @@ -481,7 +483,7 @@ QVariantMap WindowManager::get(int index) const QVariantMap map; QHash<int, QByteArray> roles = roleNames(); for (auto it = roles.begin(); it != roles.end(); ++it) - map.insert(qL1S(it.value()), data(QAbstractListModel::index(index), it.key())); + map.insert(QString::fromLatin1(it.value()), data(QAbstractListModel::index(index), it.key())); return map; } @@ -919,7 +921,7 @@ bool WindowManager::makeScreenshot(const QString &filename, const QString &selec for (int i = 0; i < filename.size(); ++i) { QChar c = filename.at(i); if (!percent) { - if (c != QLatin1Char('%')) + if (c != u'%') result.append(c); else percent = true; @@ -941,7 +943,7 @@ bool WindowManager::makeScreenshot(const QString &filename, const QString &selec return result; }; - static const QRegularExpression re(qSL("^([a-z.-]+)?(\\[([a-zA-Z0-9_.]+)=([^\\]]*)\\])?(:([0-9]+))?")); + static const QRegularExpression re(u"^([a-z.-]+)?(\\[([a-zA-Z0-9_.]+)=([^\\]]*)\\])?(:([0-9]+))?"_s); auto match = re.match(selector); QString screenId = match.captured(6); QString appId = match.captured(1); @@ -1063,9 +1065,9 @@ QString WindowManagerPrivate::applicationId(Application *app, WindowSurface *win if (app) return app->id(); else if (windowSurface && windowSurface->surface() && windowSurface->surface()->client()) - return qSL("pid: ") + QString::number(windowSurface->surface()->client()->processId()); + return u"pid: "_s + QString::number(windowSurface->surface()->client()->processId()); else - return qSL("<unknown client>"); + return u"<unknown client>"_s; } #endif // QT_CONFIG(am_multi_process) diff --git a/tests/auto/application/tst_application.cpp b/tests/auto/application/tst_application.cpp index 336f743a..299758bb 100644 --- a/tests/auto/application/tst_application.cpp +++ b/tests/auto/application/tst_application.cpp @@ -13,6 +13,8 @@ #include "package.h" #include "abstractruntime.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class TestRuntime : public AbstractRuntime @@ -54,7 +56,7 @@ public: : AbstractRuntimeManager(id, parent) { } - static QString defaultIdentifier() { return qSL("foo"); } + static QString defaultIdentifier() { return u"foo"_s; } bool inProcess() const override { @@ -82,12 +84,12 @@ private slots: // the application no longer holds a reference to it void tst_Application::runtimeDestroyed() { - auto pi = PackageInfo::fromManifest(qL1S(":/info.yaml")); + auto pi = PackageInfo::fromManifest(u":/info.yaml"_s); auto pkg = new Package(pi); auto ai = new ApplicationInfo(pi); auto app = new Application(ai, pkg); - auto runtimeManager = new TestRuntimeManager(qSL("foo"), qApp); + auto runtimeManager = new TestRuntimeManager(u"foo"_s, qApp); auto runtime = runtimeManager->create(nullptr, app); app->setCurrentRuntime(runtime); diff --git a/tests/auto/applicationinfo/tst_applicationinfo.cpp b/tests/auto/applicationinfo/tst_applicationinfo.cpp index 25ab28b1..8c6e7192 100644 --- a/tests/auto/applicationinfo/tst_applicationinfo.cpp +++ b/tests/auto/applicationinfo/tst_applicationinfo.cpp @@ -16,6 +16,9 @@ #include "yamlpackagescanner.h" #include "exception.h" +using namespace Qt::StringLiterals; + + QT_USE_NAMESPACE_AM class tst_ApplicationInfo : public QObject @@ -37,11 +40,11 @@ class TestPackageLoader { public: TestPackageLoader(const char *name) - : m_dataDir(qL1S(":/data")) + : m_dataDir(u":/data"_s) { try { static YamlPackageScanner scanner; - QString path = QString::fromLatin1(name) % qL1S("/info.yaml"); + QString path = QString::fromLatin1(name) % u"/info.yaml"_s; m_pi = scanner.scan(m_dataDir.absoluteFilePath(path)); if (m_pi) { @@ -114,86 +117,86 @@ void tst_ApplicationInfo::full() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("full")); - QCOMPARE(pl.info()->icon(), qL1S("full.png")); - QCOMPARE(pl.info()->version(), qL1S("v1")); - QMap<QString, QString> names { { qL1S("en"), qL1S("pkg.name.en") }, { qL1S("de"), qL1S("pkg.name.de") } }; + QCOMPARE(pl.info()->id(), u"full"_s); + QCOMPARE(pl.info()->icon(), u"full.png"_s); + QCOMPARE(pl.info()->version(), u"v1"_s); + QMap<QString, QString> names { { u"en"_s, u"pkg.name.en"_s }, { u"de"_s, u"pkg.name.de"_s } }; QCOMPARE(pl.info()->names(), names); - QMap<QString, QString> descs { { qL1S("en"), qL1S("pkg.desc.en") }, { qL1S("de"), qL1S("pkg.desc.de") } }; + QMap<QString, QString> descs { { u"en"_s, u"pkg.desc.en"_s }, { u"de"_s, u"pkg.desc.de"_s } }; QCOMPARE(pl.info()->descriptions(), descs); - QStringList cats { qL1S("pkg.cat.1"), qL1S("pkg.cat.2") }; + QStringList cats { u"pkg.cat.1"_s, u"pkg.cat.2"_s }; QCOMPARE(pl.info()->categories(), cats); QCOMPARE(pl.info()->applications().size(), 2); QCOMPARE(pl.info()->intents().size(), 2); const ApplicationInfo *ai = pl.info()->applications().constFirst(); - QCOMPARE(ai->id(), qSL("full.app.1")); - QCOMPARE(ai->icon(), qSL("app1.png")); - QMap<QString, QString> app1names { { qL1S("en"), qL1S("app1.name.en") }, { qL1S("de"), qL1S("app1.name.de") } }; + QCOMPARE(ai->id(), u"full.app.1"_s); + QCOMPARE(ai->icon(), u"app1.png"_s); + QMap<QString, QString> app1names { { u"en"_s, u"app1.name.en"_s }, { u"de"_s, u"app1.name.de"_s } }; QCOMPARE(ai->names(), app1names); - QMap<QString, QString> app1descs { { qL1S("en"), qL1S("app1.desc.en") }, { qL1S("de"), qL1S("app1.desc.de") } }; + QMap<QString, QString> app1descs { { u"en"_s, u"app1.desc.en"_s }, { u"de"_s, u"app1.desc.de"_s } }; QCOMPARE(ai->descriptions(), app1descs); - QStringList app1cats { qL1S("app1.cat.1"), qL1S("app1.cat.2") }; + QStringList app1cats { u"app1.cat.1"_s, u"app1.cat.2"_s }; QCOMPARE(ai->categories(), app1cats); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app1.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app1.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 5); QCOMPARE(ai->supportsApplicationInterface(), true); - QCOMPARE(ai->capabilities(), QStringList { qSL("app1.cap") }); - QVariantMap app1ogl { { qSL("desktopProfile"), qSL("core") }, { qSL("esMajorVersion"), 3 }, { qSL("esMinorVersion"), 2 }}; + QCOMPARE(ai->capabilities(), QStringList { u"app1.cap"_s }); + QVariantMap app1ogl { { u"desktopProfile"_s, u"core"_s }, { u"esMajorVersion"_s, 3 }, { u"esMinorVersion"_s, 2 }}; QCOMPARE(ai->openGLConfiguration(), app1ogl); - QVariantMap app1prop { { qSL("custom.app1.key"), 42 } }; + QVariantMap app1prop { { u"custom.app1.key"_s, 42 } }; QCOMPARE(ai->applicationProperties(), app1prop); - QVariantMap app1dlt { { qSL("id"), qSL("app1.dlt.id") }, { qSL("description"), qSL("app1.dlt.desc") } }; + QVariantMap app1dlt { { u"id"_s, u"app1.dlt.id"_s }, { u"description"_s, u"app1.dlt.desc"_s } }; QCOMPARE(ai->dltConfiguration(), app1dlt); ai = pl.info()->applications().constLast(); - QCOMPARE(ai->id(), qSL("full.app.2")); - QCOMPARE(ai->icon(), qSL("app2.png")); - QMap<QString, QString> app2names { { qL1S("en"), qL1S("app2.name.en") }, { qL1S("de"), qL1S("app2.name.de") } }; + QCOMPARE(ai->id(), u"full.app.2"_s); + QCOMPARE(ai->icon(), u"app2.png"_s); + QMap<QString, QString> app2names { { u"en"_s, u"app2.name.en"_s }, { u"de"_s, u"app2.name.de"_s } }; QCOMPARE(ai->names(), app2names); - QMap<QString, QString> app2descs { { qL1S("en"), qL1S("app2.desc.en") }, { qL1S("de"), qL1S("app2.desc.de") } }; + QMap<QString, QString> app2descs { { u"en"_s, u"app2.desc.en"_s }, { u"de"_s, u"app2.desc.de"_s } }; QCOMPARE(ai->descriptions(), app2descs); - QStringList app2cats { qL1S("app2.cat.1"), qL1S("app2.cat.2") }; + QStringList app2cats { u"app2.cat.1"_s, u"app2.cat.2"_s }; QCOMPARE(ai->categories(), app2cats); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app2.exe")); - QCOMPARE(ai->runtimeName(), qSL("native")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app2.exe"_s); + QCOMPARE(ai->runtimeName(), u"native"_s); QCOMPARE(ai->runtimeParameters().size(), 2); IntentInfo *ii = pl.info()->intents().constFirst(); - QCOMPARE(ii->id(), qSL("full.int.1")); - QCOMPARE(ii->icon(), qSL("int1.png")); - QMap<QString, QString> int1names { { qL1S("en"), qL1S("int1.name.en") }, { qL1S("de"), qL1S("int1.name.de") } }; + QCOMPARE(ii->id(), u"full.int.1"_s); + QCOMPARE(ii->icon(), u"int1.png"_s); + QMap<QString, QString> int1names { { u"en"_s, u"int1.name.en"_s }, { u"de"_s, u"int1.name.de"_s } }; QCOMPARE(ii->names(), int1names); - QMap<QString, QString> int1descs { { qL1S("en"), qL1S("int1.desc.en") }, { qL1S("de"), qL1S("int1.desc.de") } }; + QMap<QString, QString> int1descs { { u"en"_s, u"int1.desc.en"_s }, { u"de"_s, u"int1.desc.de"_s } }; QCOMPARE(ii->descriptions(), int1descs); - QStringList int1cats { qL1S("int1.cat.1"), qL1S("int1.cat.2") }; + QStringList int1cats { u"int1.cat.1"_s, u"int1.cat.2"_s }; QCOMPARE(ii->categories(), int1cats); QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constFirst()->id()); QCOMPARE(ii->visibility(), IntentInfo::Private); - QStringList req1caps { qSL("int1.cap.1"), qSL("int1.cap.2") }; + QStringList req1caps { u"int1.cap.1"_s, u"int1.cap.2"_s }; QCOMPARE(ii->requiredCapabilities(), req1caps); - QVariantMap param1match { { qSL("mimeType"), qSL("^image/.*\\.png$") } }; + QVariantMap param1match { { u"mimeType"_s, u"^image/.*\\.png$"_s } }; QCOMPARE(ii->parameterMatch(), param1match); ii = pl.info()->intents().constLast(); - QCOMPARE(ii->id(), qSL("full.int.2")); - QCOMPARE(ii->icon(), qSL("int2.png")); - QMap<QString, QString> int2names { { qL1S("en"), qL1S("int2.name.en") }, { qL1S("de"), qL1S("int2.name.de") } }; + QCOMPARE(ii->id(), u"full.int.2"_s); + QCOMPARE(ii->icon(), u"int2.png"_s); + QMap<QString, QString> int2names { { u"en"_s, u"int2.name.en"_s }, { u"de"_s, u"int2.name.de"_s } }; QCOMPARE(ii->names(), int2names); - QMap<QString, QString> int2descs { { qL1S("en"), qL1S("int2.desc.en") }, { qL1S("de"), qL1S("int2.desc.de") } }; + QMap<QString, QString> int2descs { { u"en"_s, u"int2.desc.en"_s }, { u"de"_s, u"int2.desc.de"_s } }; QCOMPARE(ii->descriptions(), int2descs); - QStringList int2cats { qL1S("int2.cat.1"), qL1S("int2.cat.2") }; + QStringList int2cats { u"int2.cat.1"_s, u"int2.cat.2"_s }; QCOMPARE(ii->categories(), int2cats); QCOMPARE(ii->handlingApplicationId(), pl.info()->applications().constLast()->id()); QCOMPARE(ii->visibility(), IntentInfo::Public); - QStringList req2caps { qSL("int2.cap.1"), qSL("int2.cap.2") }; + QStringList req2caps { u"int2.cap.1"_s, u"int2.cap.2"_s }; QCOMPARE(ii->requiredCapabilities(), req2caps); - QVariantMap param2match { { qSL("test"), qSL("foo") } }; + QVariantMap param2match { { u"test"_s, u"foo"_s } }; QCOMPARE(ii->parameterMatch(), param2match); // now the QML interface @@ -248,7 +251,7 @@ void tst_ApplicationInfo::minimal() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("minimal")); + QCOMPARE(pl.info()->id(), u"minimal"_s); QCOMPARE(pl.info()->icon(), QString { }); QCOMPARE(pl.info()->version(), QString { }); QMap<QString, QString> emptyMap; @@ -260,13 +263,13 @@ void tst_ApplicationInfo::minimal() const ApplicationInfo *ai = pl.info()->applications().constFirst(); - QCOMPARE(ai->id(), qSL("minimal.app")); + QCOMPARE(ai->id(), u"minimal.app"_s); QCOMPARE(ai->icon(), pl.info()->icon()); QCOMPARE(ai->names(), pl.info()->names()); QCOMPARE(ai->descriptions(), pl.info()->descriptions()); QCOMPARE(ai->categories(), pl.info()->categories()); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("minimal.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"minimal.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 0); } @@ -276,43 +279,43 @@ void tst_ApplicationInfo::inherit() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("inherit")); - QCOMPARE(pl.info()->icon(), qL1S("pkg.png")); + QCOMPARE(pl.info()->id(), u"inherit"_s); + QCOMPARE(pl.info()->icon(), u"pkg.png"_s); QCOMPARE(pl.info()->version(), QString { }); - QMap<QString, QString> names { { qL1S("en"), qL1S("pkg.name.en") }, { qL1S("de"), qL1S("pkg.name.de") } }; + QMap<QString, QString> names { { u"en"_s, u"pkg.name.en"_s }, { u"de"_s, u"pkg.name.de"_s } }; QCOMPARE(pl.info()->names(), names); - QMap<QString, QString> descs { { qL1S("en"), qL1S("pkg.desc.en") }, { qL1S("de"), qL1S("pkg.desc.de") } }; + QMap<QString, QString> descs { { u"en"_s, u"pkg.desc.en"_s }, { u"de"_s, u"pkg.desc.de"_s } }; QCOMPARE(pl.info()->descriptions(), descs); - QStringList cats { qL1S("pkg.cat.1"), qL1S("pkg.cat.2") }; + QStringList cats { u"pkg.cat.1"_s, u"pkg.cat.2"_s }; QCOMPARE(pl.info()->categories(), cats); QCOMPARE(pl.info()->applications().size(), 2); QCOMPARE(pl.info()->intents().size(), 2); const ApplicationInfo *ai = pl.info()->applications().constFirst(); - QCOMPARE(ai->id(), qSL("inherit.app.1")); + QCOMPARE(ai->id(), u"inherit.app.1"_s); QCOMPARE(ai->icon(), pl.info()->icon()); QCOMPARE(ai->names(), pl.info()->names()); QCOMPARE(ai->descriptions(), pl.info()->descriptions()); QCOMPARE(ai->categories(), pl.info()->categories()); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app1.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app1.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 0); ai = pl.info()->applications().constLast(); - QCOMPARE(ai->id(), qSL("inherit.app.2")); + QCOMPARE(ai->id(), u"inherit.app.2"_s); QCOMPARE(ai->icon(), pl.info()->icon()); QCOMPARE(ai->names(), pl.info()->names()); QCOMPARE(ai->descriptions(), pl.info()->descriptions()); QCOMPARE(ai->categories(), pl.info()->categories()); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("app2.exe")); - QCOMPARE(ai->runtimeName(), qSL("native")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"app2.exe"_s); + QCOMPARE(ai->runtimeName(), u"native"_s); QCOMPARE(ai->runtimeParameters().size(), 0); IntentInfo *ii = pl.info()->intents().constFirst(); - QCOMPARE(ii->id(), qSL("inherit.int.1")); + QCOMPARE(ii->id(), u"inherit.int.1"_s); QCOMPARE(ii->icon(), pl.info()->icon()); QCOMPARE(ii->names(), pl.info()->names()); QCOMPARE(ii->descriptions(), pl.info()->descriptions()); @@ -321,7 +324,7 @@ void tst_ApplicationInfo::inherit() ii = pl.info()->intents().constLast(); - QCOMPARE(ii->id(), qSL("inherit.int.2")); + QCOMPARE(ii->id(), u"inherit.int.2"_s); QCOMPARE(ii->icon(), pl.info()->icon()); QCOMPARE(ii->names(), pl.info()->names()); QCOMPARE(ii->descriptions(), pl.info()->descriptions()); @@ -364,12 +367,12 @@ void tst_ApplicationInfo::legacy() QVERIFY2(pl.info(), qPrintable(pl.lastLoadFailure())); QCOMPARE(pl.info()->baseDir(), pl.dataDir().absoluteFilePath(pl.info()->id())); - QCOMPARE(pl.info()->id(), qL1S("legacy")); - QCOMPARE(pl.info()->icon(), qL1S("icon.png")); - QCOMPARE(pl.info()->version(), qL1S("v1")); - QMap<QString, QString> names { { qL1S("en"), qL1S("legacy.en") }, { qL1S("de"), qL1S("legacy.de") } }; + QCOMPARE(pl.info()->id(), u"legacy"_s); + QCOMPARE(pl.info()->icon(), u"icon.png"_s); + QCOMPARE(pl.info()->version(), u"v1"_s); + QMap<QString, QString> names { { u"en"_s, u"legacy.en"_s }, { u"de"_s, u"legacy.de"_s } }; QCOMPARE(pl.info()->names(), names); - QStringList cats { qL1S("bar"), qL1S("foo") }; + QStringList cats { u"bar"_s, u"foo"_s }; QVERIFY(pl.info()->descriptions().isEmpty()); QCOMPARE(pl.info()->categories(), cats); QCOMPARE(pl.info()->applications().size(), 1); @@ -382,14 +385,14 @@ void tst_ApplicationInfo::legacy() QCOMPARE(ai->names(), pl.info()->names()); QVERIFY(ai->descriptions().isEmpty()); QCOMPARE(ai->categories(), pl.info()->categories()); - QStringList mimes { qL1S("text/plain"), qL1S("x-scheme-handler/mailto") }; + QStringList mimes { u"text/plain"_s, u"x-scheme-handler/mailto"_s }; QCOMPARE(ai->supportedMimeTypes(), mimes); - QStringList caps { qL1S("cameraAccess"), qL1S("locationAccess") }; + QStringList caps { u"cameraAccess"_s, u"locationAccess"_s }; QCOMPARE(ai->capabilities(), caps); - QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), qSL("legacy.qml")); - QCOMPARE(ai->runtimeName(), qSL("qml")); + QCOMPARE(QFileInfo(ai->codeFilePath()).fileName(), u"legacy.qml"_s); + QCOMPARE(ai->runtimeName(), u"qml"_s); QCOMPARE(ai->runtimeParameters().size(), 1); - QCOMPARE(ai->runtimeParameters().value(qSL("loadDummyData")).toBool(), true); + QCOMPARE(ai->runtimeParameters().value(u"loadDummyData"_s).toBool(), true); } void tst_ApplicationInfo::validApplicationId_data() diff --git a/tests/auto/applicationinstaller/tst_applicationinstaller.cpp b/tests/auto/applicationinstaller/tst_applicationinstaller.cpp index 0dd8df74..b1016ee2 100644 --- a/tests/auto/applicationinstaller/tst_applicationinstaller.cpp +++ b/tests/auto/applicationinstaller/tst_applicationinstaller.cpp @@ -22,6 +22,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM static bool startedSudoServer = false; @@ -121,8 +123,8 @@ private: { QString base; switch (pathLocation) { - case Internal0: base = qSL("internal"); break; - case Documents0: base = qSL("documents"); break; + case Internal0: base = u"internal"_s; break; + case Documents0: base = u"documents"_s; break; default: break; } @@ -135,10 +137,10 @@ private: else if (base.isEmpty()) base = workDir.absoluteFilePath(sub); else - base = workDir.absoluteFilePath(base + qL1C('/') + sub); + base = workDir.absoluteFilePath(base + u'/' + sub); if (QDir(base).exists()) - return base + qL1C('/'); + return base + u'/'; else return base; } @@ -199,12 +201,12 @@ tst_PackageManager::~tst_PackageManager() void tst_PackageManager::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); bool verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); if (!verbose) - QLoggingCategory::setFilterRules(qSL("am.installer.debug=false")); + QLoggingCategory::setFilterRules(u"am.installer.debug=false"_s); qInfo() << "Verbose mode is" << (verbose ? "on" : "off") << "(change by (un)setting $AM_VERBOSE_TEST)"; spyTimeout *= timeoutFactor(); @@ -218,7 +220,7 @@ void tst_PackageManager::initTestCase() QVERIFY(m_workDir.isValid()); // make sure we have a valid hardware-id - m_hardwareId = qSL("foobar"); + m_hardwareId = u"foobar"_s; for (int i = 0; i < PathLocationCount; ++i) QVERIFY(QDir().mkdir(pathTo(PathLocation(i)))); @@ -245,17 +247,17 @@ void tst_PackageManager::initTestCase() const QVariantMap iloc = m_pm->installationLocation(); QCOMPARE(iloc.size(), 3); - QCOMPARE(iloc.value(qSL("path")).toString(), pathTo(Internal0)); - QVERIFY(iloc.value(qSL("deviceSize")).toLongLong() > 0); - QVERIFY(iloc.value(qSL("deviceFree")).toLongLong() > 0); - QVERIFY(iloc.value(qSL("deviceFree")).toLongLong() < iloc.value(qSL("deviceSize")).toLongLong()); + QCOMPARE(iloc.value(u"path"_s).toString(), pathTo(Internal0)); + QVERIFY(iloc.value(u"deviceSize"_s).toLongLong() > 0); + QVERIFY(iloc.value(u"deviceFree"_s).toLongLong() > 0); + QVERIFY(iloc.value(u"deviceFree"_s).toLongLong() < iloc.value(u"deviceSize"_s).toLongLong()); const QVariantMap dloc = m_pm->documentLocation(); QCOMPARE(dloc.size(), 3); - QCOMPARE(dloc.value(qSL("path")).toString(), pathTo(Documents0)); - QVERIFY(dloc.value(qSL("deviceSize")).toLongLong() > 0); - QVERIFY(dloc.value(qSL("deviceFree")).toLongLong() > 0); - QVERIFY(dloc.value(qSL("deviceFree")).toLongLong() < dloc.value(qSL("deviceSize")).toLongLong()); + QCOMPARE(dloc.value(u"path"_s).toString(), pathTo(Documents0)); + QVERIFY(dloc.value(u"deviceSize"_s).toLongLong() > 0); + QVERIFY(dloc.value(u"deviceFree"_s).toLongLong() > 0); + QVERIFY(dloc.value(u"deviceFree"_s).toLongLong() < dloc.value(u"deviceSize"_s).toLongLong()); m_startedSpy = new QSignalSpy(m_pm, &PackageManager::taskStarted); m_requestingInstallationAcknowledgeSpy = new QSignalSpy(m_pm, &PackageManager::taskRequestingInstallationAcknowledge); @@ -266,9 +268,9 @@ void tst_PackageManager::initTestCase() // crypto stuff - we need to load the root CA and developer CA certificates - QFile devcaFile(qL1S(AM_TESTDATA_DIR "certificates/devca.crt")); - QFile storecaFile(qL1S(AM_TESTDATA_DIR "certificates/store.crt")); - QFile caFile(qL1S(AM_TESTDATA_DIR "certificates/ca.crt")); + QFile devcaFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/devca.crt")); + QFile storecaFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/store.crt")); + QFile caFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/ca.crt")); QVERIFY2(devcaFile.open(QIODevice::ReadOnly), qPrintable(devcaFile.errorString())); QVERIFY2(storecaFile.open(QIODevice::ReadOnly), qPrintable(storecaFile.errorString())); QVERIFY2(caFile.open(QIODevice::ReadOnly), qPrintable(caFile.errorString())); @@ -285,7 +287,7 @@ void tst_PackageManager::initTestCase() // make sure we have a valid runtime available. The important part is // that we have a runtime called "native" - the functionality does not matter. - RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(qSL("native"))); + RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(u"native"_s)); } void tst_PackageManager::cleanupTestCase() @@ -330,16 +332,16 @@ void tst_PackageManager::packageInstallation_data() QVariantMap nomd { }; // no meta-data QVariantMap extramd = QVariantMap { - { qSL("extra"), QVariantMap { - { qSL("array"), QVariantList { 1, 2 } }, - { qSL("foo"), qSL("bar") }, - { qSL("foo2"),qSL("bar2") }, - { qSL("key"), qSL("value") } } }, - { qSL("extraSigned"), QVariantMap { - { qSL("sfoo"), qSL("sbar") }, - { qSL("sfoo2"), qSL("sbar2") }, - { qSL("signed-key"), qSL("signed-value") }, - { qSL("signed-object"), QVariantMap { { qSL("k1"), qSL("v1") }, { qSL("k2"), qSL("v2") } } } + { u"extra"_s, QVariantMap { + { u"array"_s, QVariantList { 1, 2 } }, + { u"foo"_s, u"bar"_s }, + { u"foo2"_s,u"bar2"_s }, + { u"key"_s, u"value"_s } } }, + { u"extraSigned"_s, QVariantMap { + { u"sfoo"_s, u"sbar"_s }, + { u"sfoo2"_s, u"sbar2"_s }, + { u"signed-key"_s, u"signed-value"_s }, + { u"signed-object"_s, QVariantMap { { u"k1"_s, u"v1"_s }, { u"k2"_s, u"v2"_s } } } } } }; @@ -410,8 +412,8 @@ void tst_PackageManager::packageInstallation() QFETCH(QVariantMap, extraMetaData); QFETCH(QString, errorString); - QString installationDir = m_pm->installationLocation().value(qSL("path")).toString(); - QString documentDir = m_pm->documentLocation().value(qSL("path")).toString(); + QString installationDir = m_pm->installationLocation().value(u"path"_s).toString(); + QString documentDir = m_pm->documentLocation().value(u"path"_s).toString(); AllowInstallations allow(storeSigned ? AllowInstallations::RequireStoreSigned : (devSigned ? AllowInstallations::RequireDevSigned @@ -426,7 +428,7 @@ void tst_PackageManager::packageInstallation() // install (or update) the package - QUrl url = QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/") + QUrl url = QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/") + (pass == 1 ? packageName : updatePackageName)); QString taskId = m_pm->startPackageInstallation(url); QVERIFY(!taskId.isEmpty()); @@ -455,24 +457,24 @@ void tst_PackageManager::packageInstallation() //QDirIterator it(m_workDir.path(), QDirIterator::Subdirectories); //while (it.hasNext()) { qDebug() << it.next(); } - QVERIFY(QFile::exists(installationDir + qSL("/com.pelagicore.test/.installation-report.yaml"))); - QVERIFY(QDir(documentDir + qSL("/com.pelagicore.test")).exists()); + QVERIFY(QFile::exists(installationDir + u"/com.pelagicore.test/.installation-report.yaml"_s)); + QVERIFY(QDir(documentDir + u"/com.pelagicore.test"_s).exists()); - QString fileCheckPath = installationDir + qSL("/com.pelagicore.test"); + QString fileCheckPath = installationDir + u"/com.pelagicore.test"_s; // now check the installed files QStringList files = QDir(fileCheckPath).entryList(QDir::AllEntries | QDir::NoDotAndDotDot); #if defined(Q_OS_WIN) // files starting with . are not considered hidden on Windows - files = files.filter(QRegularExpression(qSL("^[^.].*"))); + files = files.filter(QRegularExpression(u"^[^.].*"_s)); #endif files.sort(); - QVERIFY2(files == QStringList({ qSL("icon.png"), qSL("info.yaml"), qSL("test"), QString::fromUtf8("t\xc3\xa4st") }), - qPrintable(files.join(qSL(", ")))); + QVERIFY2(files == QStringList({ u"icon.png"_s, u"info.yaml"_s, u"test"_s, QString::fromUtf8("t\xc3\xa4st") }), + qPrintable(files.join(u", "_s))); - QFile f(fileCheckPath + qSL("/test")); + QFile f(fileCheckPath + u"/test"_s); QVERIFY(f.open(QFile::ReadOnly)); QCOMPARE(f.readAll(), QByteArray(pass == 1 ? "test\n" : "test update\n")); f.close(); @@ -481,28 +483,28 @@ void tst_PackageManager::packageInstallation() QCOMPARE(m_requestingInstallationAcknowledgeSpy->count(), 1); QVariantMap extra = m_requestingInstallationAcknowledgeSpy->first()[2].toMap(); QVariantMap extraSigned = m_requestingInstallationAcknowledgeSpy->first()[3].toMap(); - if (extraMetaData.value(qSL("extra")).toMap() != extra) { + if (extraMetaData.value(u"extra"_s).toMap() != extra) { qDebug() << "Actual: " << extra; - qDebug() << "Expected: " << extraMetaData.value(qSL("extra")).toMap(); + qDebug() << "Expected: " << extraMetaData.value(u"extra"_s).toMap(); QVERIFY(extraMetaData == extra); } - if (extraMetaData.value(qSL("extraSigned")).toMap() != extraSigned) { + if (extraMetaData.value(u"extraSigned"_s).toMap() != extraSigned) { qDebug() << "Actual: " << extraSigned; - qDebug() << "Expected: " << extraMetaData.value(qSL("extraSigned")).toMap(); + qDebug() << "Expected: " << extraMetaData.value(u"extraSigned"_s).toMap(); QVERIFY(extraMetaData == extraSigned); } // check if the meta-data was saved to the installation report correctly - QVERIFY2(m_pm->installedPackageExtraMetaData(qSL("com.pelagicore.test")) == extra, + QVERIFY2(m_pm->installedPackageExtraMetaData(u"com.pelagicore.test"_s) == extra, "Extra meta-data was not correctly saved to installation report"); - QVERIFY2(m_pm->installedPackageExtraSignedMetaData(qSL("com.pelagicore.test")) == extraSigned, + QVERIFY2(m_pm->installedPackageExtraSignedMetaData(u"com.pelagicore.test"_s) == extraSigned, "Extra signed meta-data was not correctly saved to installation report"); } if (pass == lastPass && expectedSuccess) { // remove package again clearSignalSpies(); - taskId = m_pm->removePackage(qSL("com.pelagicore.test"), false); + taskId = m_pm->removePackage(u"com.pelagicore.test"_s, false); QVERIFY(!taskId.isEmpty()); // check signals @@ -514,8 +516,8 @@ void tst_PackageManager::packageInstallation() // check that all files are gone for (PathLocation pl: { Internal0, Documents0 }) { - QStringList entries = QDir(pathTo(pl)).entryList({ qSL("com.pelagicore.test*") }); - QVERIFY2(entries.isEmpty(), qPrintable(pathTo(pl) + qSL(": ") + entries.join(qSL(", ")))); + QStringList entries = QDir(pathTo(pl)).entryList({ u"com.pelagicore.test*"_s }); + QVERIFY2(entries.isEmpty(), qPrintable(pathTo(pl) + u": "_s + entries.join(u", "_s))); } } @@ -558,7 +560,7 @@ void tst_PackageManager::simulateErrorConditions() if (testUpdate) { // the check will run when updating a package, so we need to install it first - taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!taskId.isEmpty()); m_pm->acknowledgePackageInstallation(taskId); QVERIFY(m_finishedSpy->wait(spyTimeout)); @@ -570,7 +572,7 @@ void tst_PackageManager::simulateErrorConditions() for (const auto &f : beforeStart) QVERIFY(f()); - taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); const auto afterStart = functions.values("after-start"); for (const auto &f : afterStart) @@ -588,7 +590,7 @@ void tst_PackageManager::simulateErrorConditions() QVERIFY(f()); if (testUpdate) { - taskId = m_pm->removePackage(qSL("com.pelagicore.test"), false); + taskId = m_pm->removePackage(u"com.pelagicore.test"_s, false); QVERIFY(m_finishedSpy->wait(spyTimeout)); QCOMPARE(m_finishedSpy->first()[0].toString(), taskId); @@ -612,7 +614,7 @@ void tst_PackageManager::cancelPackageInstallation() { QFETCH(bool, expectedResult); - QString taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString taskId = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!taskId.isEmpty()); if (isDataTag("before-started-signal")) { @@ -641,7 +643,7 @@ void tst_PackageManager::cancelPackageInstallation() } else { clearSignalSpies(); - taskId = m_pm->removePackage(qSL("com.pelagicore.test"), false); + taskId = m_pm->removePackage(u"com.pelagicore.test"_s, false); QVERIFY(!taskId.isEmpty()); QVERIFY(m_finishedSpy->wait(spyTimeout)); QCOMPARE(m_finishedSpy->first()[0].toString(), taskId); @@ -651,12 +653,12 @@ void tst_PackageManager::cancelPackageInstallation() void tst_PackageManager::parallelPackageInstallation() { - QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!task1Id.isEmpty()); QVERIFY(m_blockingUntilInstallationAcknowledgeSpy->wait(spyTimeout)); QCOMPARE(m_blockingUntilInstallationAcknowledgeSpy->first()[0].toString(), task1Id); - QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/bigtest-dev-signed.appkg"))); + QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/bigtest-dev-signed.appkg"))); QVERIFY(!task2Id.isEmpty()); m_pm->acknowledgePackageInstallation(task2Id); QVERIFY(m_finishedSpy->wait(spyTimeout)); @@ -672,17 +674,17 @@ void tst_PackageManager::parallelPackageInstallation() void tst_PackageManager::doublePackageInstallation() { - QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString task1Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!task1Id.isEmpty()); QVERIFY(m_blockingUntilInstallationAcknowledgeSpy->wait(spyTimeout)); QCOMPARE(m_blockingUntilInstallationAcknowledgeSpy->first()[0].toString(), task1Id); - QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); + QString task2Id = m_pm->startPackageInstallation(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test-dev-signed.appkg"))); QVERIFY(!task2Id.isEmpty()); m_pm->acknowledgePackageInstallation(task2Id); QVERIFY(m_failedSpy->wait(spyTimeout)); QCOMPARE(m_failedSpy->first()[0].toString(), task2Id); - QCOMPARE(m_failedSpy->first()[2].toString(), qL1S("Cannot install the same package com.pelagicore.test multiple times in parallel")); + QCOMPARE(m_failedSpy->first()[2].toString(), u"Cannot install the same package com.pelagicore.test multiple times in parallel"); clearSignalSpies(); m_pm->cancelTask(task1Id); diff --git a/tests/auto/configuration/tst_configuration.cpp b/tests/auto/configuration/tst_configuration.cpp index 456cf086..f3e6cc15 100644 --- a/tests/auto/configuration/tst_configuration.cpp +++ b/tests/auto/configuration/tst_configuration.cpp @@ -8,6 +8,8 @@ #include <QtAppManCommon/exception.h> #include <QtAppManCommon/global.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Configuration : public QObject @@ -34,7 +36,7 @@ tst_Configuration::tst_Configuration() void tst_Configuration::defaultConfig() { Configuration c; - c.parseWithArguments({ qSL("test"), qSL("--no-cache") }); + c.parseWithArguments({ u"test"_s, u"--no-cache"_s }); QVERIFY(c.noCache()); @@ -43,16 +45,16 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.verbose(), false); QCOMPARE(c.slowAnimations(), false); QCOMPARE(c.noDltLogging(), false); - QCOMPARE(c.singleApp(), qSL("")); + QCOMPARE(c.singleApp(), u""_s); QCOMPARE(c.qmlDebugging(), false); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("")); + QCOMPARE(c.mainQmlFile(), u""_s); QCOMPARE(c.builtinAppsManifestDirs(), {}); - QCOMPARE(c.documentDir(), qSL("")); + QCOMPARE(c.documentDir(), u""_s); - QCOMPARE(c.installationDir(), qSL("")); + QCOMPARE(c.installationDir(), u""_s); QCOMPARE(c.disableInstaller(), false); QCOMPARE(c.disableIntents(), false); QCOMPARE(c.intentTimeoutForDisambiguation(), 10000); @@ -61,7 +63,7 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 20000); QCOMPARE(c.fullscreen(), false); - QCOMPARE(c.windowIcon(), qSL("")); + QCOMPARE(c.windowIcon(), u""_s); QCOMPARE(c.importPaths(), {}); QCOMPARE(c.pluginPaths(), {}); QCOMPARE(c.loadDummyData(), false); @@ -73,13 +75,13 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.forceSingleProcess(), false); QCOMPARE(c.forceMultiProcess(), false); QCOMPARE(c.loggingRules(), {}); - QCOMPARE(c.messagePattern(), qSL("")); + QCOMPARE(c.messagePattern(), u""_s); QCOMPARE(c.useAMConsoleLogger(), QVariant()); - QCOMPARE(c.style(), qSL("")); - QCOMPARE(c.iconThemeName(), qSL("")); + QCOMPARE(c.style(), u""_s); + QCOMPARE(c.iconThemeName(), u""_s); QCOMPARE(c.iconThemeSearchPaths(), {}); - QCOMPARE(c.dltId(), qSL("")); - QCOMPARE(c.dltDescription(), qSL("")); + QCOMPARE(c.dltId(), u""_s); + QCOMPARE(c.dltDescription(), u""_s); QCOMPARE(c.resources(), {}); QCOMPARE(c.openGLConfiguration(), QVariantMap {}); @@ -91,7 +93,7 @@ void tst_Configuration::defaultConfig() QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList {}); QCOMPARE(c.runtimeConfigurations(), QVariantMap {}); - QCOMPARE(c.dbusRegistration("iface1"), qSL("auto")); + QCOMPARE(c.dbusRegistration("iface1"), u"auto"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap {}); @@ -100,7 +102,7 @@ void tst_Configuration::defaultConfig() QString defaultWaylandSocketName = #if defined(Q_OS_LINUX) - qSL("qtam-wayland-"); + u"qtam-wayland-"_s; #else QString(); #endif @@ -118,8 +120,8 @@ void tst_Configuration::defaultConfig() void tst_Configuration::simpleConfig() { - Configuration c({ qSL(":/data/config1.yaml") }, qSL(":/build-config.yaml")); - c.parseWithArguments({ qSL("test"), qSL("--no-cache") }); + Configuration c({ u":/data/config1.yaml"_s }, u":/build-config.yaml"_s); + c.parseWithArguments({ u"test"_s, u"--no-cache"_s }); QVERIFY(c.noCache()); @@ -128,16 +130,16 @@ void tst_Configuration::simpleConfig() QCOMPARE(c.verbose(), false); QCOMPARE(c.slowAnimations(), false); QCOMPARE(c.noDltLogging(), false); - QCOMPARE(c.singleApp(), qSL("")); + QCOMPARE(c.singleApp(), u""_s); QCOMPARE(c.qmlDebugging(), false); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("main.qml")); + QCOMPARE(c.mainQmlFile(), u"main.qml"_s); - QCOMPARE(c.builtinAppsManifestDirs(), { qSL("builtin-dir") }); - QCOMPARE(c.documentDir(), qSL("doc-dir")); + QCOMPARE(c.builtinAppsManifestDirs(), { u"builtin-dir"_s }); + QCOMPARE(c.documentDir(), u"doc-dir"_s); - QCOMPARE(c.installationDir(), qSL("installation-dir")); + QCOMPARE(c.installationDir(), u"installation-dir"_s); QCOMPARE(c.disableInstaller(), true); QCOMPARE(c.disableIntents(), true); QCOMPARE(c.intentTimeoutForDisambiguation(), 1); @@ -146,9 +148,9 @@ void tst_Configuration::simpleConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 4); QCOMPARE(c.fullscreen(), true); - QCOMPARE(c.windowIcon(), qSL("icon.png")); - QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(qSL("ip1")), pwd.absoluteFilePath(qSL("ip2")) })); - QCOMPARE(c.pluginPaths(), QStringList({ qSL("pp1"), qSL("pp2") })); + QCOMPARE(c.windowIcon(), u"icon.png"_s); + QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(u"ip1"_s), pwd.absoluteFilePath(u"ip2"_s) })); + QCOMPARE(c.pluginPaths(), QStringList({ u"pp1"_s, u"pp2"_s })); QCOMPARE(c.loadDummyData(), true); QCOMPARE(c.noSecurity(), true); QCOMPARE(c.developmentMode(), true); @@ -157,101 +159,101 @@ void tst_Configuration::simpleConfig() QCOMPARE(c.allowUnknownUiClients(), true); QCOMPARE(c.forceSingleProcess(), true); QCOMPARE(c.forceMultiProcess(), true); - QCOMPARE(c.loggingRules(), QStringList({ qSL("lr1"), qSL("lr2") })); - QCOMPARE(c.messagePattern(), qSL("msgPattern")); + QCOMPARE(c.loggingRules(), QStringList({ u"lr1"_s, u"lr2"_s })); + QCOMPARE(c.messagePattern(), u"msgPattern"_s); QCOMPARE(c.useAMConsoleLogger(), QVariant(true)); - QCOMPARE(c.style(), qSL("mystyle")); - QCOMPARE(c.iconThemeName(), qSL("mytheme")); - QCOMPARE(c.iconThemeSearchPaths(), QStringList({ qSL("itsp1"), qSL("itsp2") })); - QCOMPARE(c.dltId(), qSL("dltid")); - QCOMPARE(c.dltDescription(), qSL("dltdesc")); - QCOMPARE(c.dltLongMessageBehavior(), qSL("split")); - QCOMPARE(c.resources(), QStringList({ qSL("r1"), qSL("r2") })); + QCOMPARE(c.style(), u"mystyle"_s); + QCOMPARE(c.iconThemeName(), u"mytheme"_s); + QCOMPARE(c.iconThemeSearchPaths(), QStringList({ u"itsp1"_s, u"itsp2"_s })); + QCOMPARE(c.dltId(), u"dltid"_s); + QCOMPARE(c.dltDescription(), u"dltdesc"_s); + QCOMPARE(c.dltLongMessageBehavior(), u"split"_s); + QCOMPARE(c.resources(), QStringList({ u"r1"_s, u"r2"_s })); QCOMPARE(c.openGLConfiguration(), QVariantMap ({ - { qSL("desktopProfile"), qSL("compatibility") }, - { qSL("esMajorVersion"), 5 }, - { qSL("esMinorVersion"), 15 } + { u"desktopProfile"_s, u"compatibility"_s }, + { u"esMajorVersion"_s, 5 }, + { u"esMinorVersion"_s, 15 } })); QCOMPARE(c.installationLocations(), {}); QList<QPair<QString, QString>> containerSelectionConfiguration { - { qSL("*"), qSL("selectionFunction") } + { u"*"_s, u"selectionFunction"_s } }; QCOMPARE(c.containerSelectionConfiguration(), containerSelectionConfiguration); QCOMPARE(c.containerConfigurations(), QVariantMap ({ - { qSL("c-test"), QVariantMap { - { qSL("c-parameter"), qSL("c-value") } + { u"c-test"_s, QVariantMap { + { u"c-parameter"_s, u"c-value"_s } } } })); QCOMPARE(c.runtimeConfigurations(), QVariantMap ({ - { qSL("r-test"), QVariantMap { - { qSL("r-parameter"), qSL("r-value") } + { u"r-test"_s, QVariantMap { + { u"r-parameter"_s, u"r-value"_s } } } })); - QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList(qSL("a"))); + QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList(u"a"_s)); - QCOMPARE(c.dbusRegistration("iface1"), qSL("foobus")); + QCOMPARE(c.dbusRegistration("iface1"), u"foobus"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap ({ - { qSL("public"), QVariantMap { - { qSL("public-prop"), qSL("public-value") } + { u"public"_s, QVariantMap { + { u"public-prop"_s, u"public-value"_s } } }, - { qSL("protected"), QVariantMap { - { qSL("protected-prop"), qSL("protected-value") } + { u"protected"_s, QVariantMap { + { u"protected-prop"_s, u"protected-value"_s } } }, - { qSL("private"), QVariantMap { - { qSL("private-prop"), qSL("private-value") } + { u"private"_s, QVariantMap { + { u"private-prop"_s, u"private-value"_s } } } })); QCOMPARE(c.quickLaunchIdleLoad(), qreal(0.5)); - QHash<std::pair<QString, QString>, int> rpc { { { qSL("*"), qSL("*")}, 5 } }; + QHash<std::pair<QString, QString>, int> rpc { { { u"*"_s, u"*"_s}, 5 } }; QCOMPARE(c.quickLaunchRuntimesPerContainer(), rpc); QCOMPARE(c.quickLaunchFailedStartLimit(), 42); QCOMPARE(c.quickLaunchFailedStartLimitIntervalSec(), 43); - QCOMPARE(c.waylandSocketName(), qSL("my-wlsock-42")); + QCOMPARE(c.waylandSocketName(), u"my-wlsock-42"_s); QCOMPARE(c.waylandExtraSockets(), QVariantList ({ QVariantMap { - { qSL("path"), qSL("path-es1") }, - { qSL("permissions"), 0440 }, - { qSL("userId"), 1 }, - { qSL("groupId"), 2 } + { u"path"_s, u"path-es1"_s }, + { u"permissions"_s, 0440 }, + { u"userId"_s, 1 }, + { u"groupId"_s, 2 } }, QVariantMap { - { qSL("path"), qSL("path-es2") }, - { qSL("permissions"), 0222 }, - { qSL("userId"), 3 }, - { qSL("groupId"), 4 } + { u"path"_s, u"path-es2"_s }, + { u"permissions"_s, 0222 }, + { u"userId"_s, 3 }, + { u"groupId"_s, 4 } } })); QCOMPARE(c.managerCrashAction(), QVariantMap ({ - { qSL("printBacktrace"), true }, - { qSL("printQmlStack"), true }, - { qSL("waitForGdbAttach"), true }, - { qSL("dumpCore"), true } + { u"printBacktrace"_s, true }, + { u"printQmlStack"_s, true }, + { u"waitForGdbAttach"_s, true }, + { u"dumpCore"_s, true } })); - QCOMPARE(c.caCertificates(), QStringList({ qSL("cert1"), qSL("cert2") })); + QCOMPARE(c.caCertificates(), QStringList({ u"cert1"_s, u"cert2"_s })); - QCOMPARE(c.pluginFilePaths("startup"), QStringList({ qSL("s1"), qSL("s2") })); - QCOMPARE(c.pluginFilePaths("container"), QStringList({ qSL("c1"), qSL("c2") })); + QCOMPARE(c.pluginFilePaths("startup"), QStringList({ u"s1"_s, u"s2"_s })); + QCOMPARE(c.pluginFilePaths("container"), QStringList({ u"c1"_s, u"c2"_s })); } void tst_Configuration::mergedConfig() { - Configuration c({ qSL(":/data/") }, qSL(":/build-config.yaml")); - c.parseWithArguments({ qSL("test"), qSL("--no-cache") }); + Configuration c({ u":/data/"_s }, u":/build-config.yaml"_s); + c.parseWithArguments({ u"test"_s, u"--no-cache"_s }); QVERIFY(c.noCache()); @@ -260,16 +262,16 @@ void tst_Configuration::mergedConfig() QCOMPARE(c.verbose(), false); QCOMPARE(c.slowAnimations(), false); QCOMPARE(c.noDltLogging(), false); - QCOMPARE(c.singleApp(), qSL("")); + QCOMPARE(c.singleApp(), u""_s); QCOMPARE(c.qmlDebugging(), false); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("main2.qml")); + QCOMPARE(c.mainQmlFile(), u"main2.qml"_s); - QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ qSL("builtin-dir"), qSL("builtin-dir2") })); - QCOMPARE(c.documentDir(), qSL("doc-dir2")); + QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ u"builtin-dir"_s, u"builtin-dir2"_s })); + QCOMPARE(c.documentDir(), u"doc-dir2"_s); - QCOMPARE(c.installationDir(), qSL("installation-dir2")); + QCOMPARE(c.installationDir(), u"installation-dir2"_s); QCOMPARE(c.disableInstaller(), true); QCOMPARE(c.disableIntents(), true); QCOMPARE(c.intentTimeoutForDisambiguation(), 5); @@ -278,12 +280,12 @@ void tst_Configuration::mergedConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 8); QCOMPARE(c.fullscreen(), true); - QCOMPARE(c.windowIcon(), qSL("icon2.png")); + QCOMPARE(c.windowIcon(), u"icon2.png"_s); QCOMPARE(c.importPaths(), QStringList - ({ pwd.absoluteFilePath(qSL("ip1")), - pwd.absoluteFilePath(qSL("ip2")), - pwd.absoluteFilePath(qSL("ip3")) })); - QCOMPARE(c.pluginPaths(), QStringList({ qSL("pp1"), qSL("pp2"), qSL("pp3") })); + ({ pwd.absoluteFilePath(u"ip1"_s), + pwd.absoluteFilePath(u"ip2"_s), + pwd.absoluteFilePath(u"ip3"_s) })); + QCOMPARE(c.pluginPaths(), QStringList({ u"pp1"_s, u"pp2"_s, u"pp3"_s })); QCOMPARE(c.loadDummyData(), true); QCOMPARE(c.noSecurity(), true); QCOMPARE(c.developmentMode(), true); @@ -292,117 +294,117 @@ void tst_Configuration::mergedConfig() QCOMPARE(c.allowUnknownUiClients(), true); QCOMPARE(c.forceSingleProcess(), true); QCOMPARE(c.forceMultiProcess(), true); - QCOMPARE(c.loggingRules(), QStringList({ qSL("lr1"), qSL("lr2"), qSL("lr3") })); - QCOMPARE(c.messagePattern(), qSL("msgPattern2")); + QCOMPARE(c.loggingRules(), QStringList({ u"lr1"_s, u"lr2"_s, u"lr3"_s })); + QCOMPARE(c.messagePattern(), u"msgPattern2"_s); QCOMPARE(c.useAMConsoleLogger(), QVariant()); - QCOMPARE(c.style(), qSL("mystyle2")); - QCOMPARE(c.iconThemeName(), qSL("mytheme2")); - QCOMPARE(c.iconThemeSearchPaths(), QStringList({ qSL("itsp1"), qSL("itsp2"), qSL("itsp3") })); - QCOMPARE(c.dltId(), qSL("dltid2")); - QCOMPARE(c.dltDescription(), qSL("dltdesc2")); - QCOMPARE(c.dltLongMessageBehavior(), qSL("truncate")); - QCOMPARE(c.resources(), QStringList({ qSL("r1"), qSL("r2"), qSL("r3") })); + QCOMPARE(c.style(), u"mystyle2"_s); + QCOMPARE(c.iconThemeName(), u"mytheme2"_s); + QCOMPARE(c.iconThemeSearchPaths(), QStringList({ u"itsp1"_s, u"itsp2"_s, u"itsp3"_s })); + QCOMPARE(c.dltId(), u"dltid2"_s); + QCOMPARE(c.dltDescription(), u"dltdesc2"_s); + QCOMPARE(c.dltLongMessageBehavior(), u"truncate"_s); + QCOMPARE(c.resources(), QStringList({ u"r1"_s, u"r2"_s, u"r3"_s })); QCOMPARE(c.openGLConfiguration(), QVariantMap ({ - { qSL("desktopProfile"), qSL("classic") }, - { qSL("esMajorVersion"), 1 }, - { qSL("esMinorVersion"), 0 }, + { u"desktopProfile"_s, u"classic"_s }, + { u"esMajorVersion"_s, 1 }, + { u"esMinorVersion"_s, 0 }, })); QCOMPARE(c.installationLocations(), {}); QList<QPair<QString, QString>> containerSelectionConfiguration { - { qSL("*"), qSL("selectionFunction") }, - { qSL("2"), qSL("second") } + { u"*"_s, u"selectionFunction"_s }, + { u"2"_s, u"second"_s } }; QCOMPARE(c.containerSelectionConfiguration(), containerSelectionConfiguration); QCOMPARE(c.containerConfigurations(), QVariantMap ({ - { qSL("c-test"), QVariantMap { - { qSL("c-parameter"), qSL("xc-value") }, + { u"c-test"_s, QVariantMap { + { u"c-parameter"_s, u"xc-value"_s }, } }, - { qSL("c-test2"), QVariantMap { - { qSL("c-parameter2"), qSL("c-value2") }, + { u"c-test2"_s, QVariantMap { + { u"c-parameter2"_s, u"c-value2"_s }, } } })); QCOMPARE(c.runtimeConfigurations(), QVariantMap ({ - { qSL("r-test"), QVariantMap { - { qSL("r-parameter"), qSL("xr-value") }, + { u"r-test"_s, QVariantMap { + { u"r-parameter"_s, u"xr-value"_s }, } }, - { qSL("r-test2"), QVariantMap { - { qSL("r-parameter2"), qSL("r-value2") }, + { u"r-test2"_s, QVariantMap { + { u"r-parameter2"_s, u"r-value2"_s }, } } })); - QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList({ qSL("a"), qSL("b"), qSL("c") })); + QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList({ u"a"_s, u"b"_s, u"c"_s })); - QCOMPARE(c.dbusRegistration("iface1"), qSL("foobus1")); - QCOMPARE(c.dbusRegistration("iface2"), qSL("foobus2")); + QCOMPARE(c.dbusRegistration("iface1"), u"foobus1"_s); + QCOMPARE(c.dbusRegistration("iface2"), u"foobus2"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap ({ - { qSL("public"), QVariantMap { - { qSL("public-prop"), qSL("xpublic-value") }, - { qSL("public-prop2"), qSL("public-value2") } + { u"public"_s, QVariantMap { + { u"public-prop"_s, u"xpublic-value"_s }, + { u"public-prop2"_s, u"public-value2"_s } } }, - { qSL("protected"), QVariantMap { - { qSL("protected-prop"), qSL("xprotected-value") }, - { qSL("protected-prop2"), qSL("protected-value2") } + { u"protected"_s, QVariantMap { + { u"protected-prop"_s, u"xprotected-value"_s }, + { u"protected-prop2"_s, u"protected-value2"_s } } }, - { qSL("private"), QVariantMap { - { qSL("private-prop"), qSL("xprivate-value") }, - { qSL("private-prop2"), qSL("private-value2") } + { u"private"_s, QVariantMap { + { u"private-prop"_s, u"xprivate-value"_s }, + { u"private-prop2"_s, u"private-value2"_s } } } })); QCOMPARE(c.quickLaunchIdleLoad(), qreal(0.2)); QHash<std::pair<QString, QString>, int> rpc = { - { { qSL("*"), qSL("*") }, 5 }, - { { qSL("c-foo"), qSL("r-foo") }, 1 }, - { { qSL("c-foo"), qSL("r-bar") }, 2 }, - { { qSL("c-bar"), qSL("*") }, 4 }, + { { u"*"_s, u"*"_s }, 5 }, + { { u"c-foo"_s, u"r-foo"_s }, 1 }, + { { u"c-foo"_s, u"r-bar"_s }, 2 }, + { { u"c-bar"_s, u"*"_s }, 4 }, }; QCOMPARE(c.quickLaunchRuntimesPerContainer(), rpc); QCOMPARE(c.quickLaunchFailedStartLimit(), 44); QCOMPARE(c.quickLaunchFailedStartLimitIntervalSec(), 45); - QCOMPARE(c.waylandSocketName(), qSL("other-wlsock-0")); + QCOMPARE(c.waylandSocketName(), u"other-wlsock-0"_s); QCOMPARE(c.waylandExtraSockets(), QVariantList ({ QVariantMap { - { qSL("path"), qSL("path-es1") }, - { qSL("permissions"), 0440 }, - { qSL("userId"), 1 }, - { qSL("groupId"), 2 } + { u"path"_s, u"path-es1"_s }, + { u"permissions"_s, 0440 }, + { u"userId"_s, 1 }, + { u"groupId"_s, 2 } }, QVariantMap { - { qSL("path"), qSL("path-es2") }, - { qSL("permissions"), 0222 }, - { qSL("userId"), 3 }, - { qSL("groupId"), 4 } + { u"path"_s, u"path-es2"_s }, + { u"permissions"_s, 0222 }, + { u"userId"_s, 3 }, + { u"groupId"_s, 4 } }, QVariantMap { - { qSL("path"), qSL("path-es3") }, + { u"path"_s, u"path-es3"_s }, } })); QCOMPARE(c.managerCrashAction(), QVariantMap ({ - { qSL("printBacktrace"), true }, - { qSL("printQmlStack"), true }, - { qSL("waitForGdbAttach"), true }, - { qSL("dumpCore"), true } + { u"printBacktrace"_s, true }, + { u"printQmlStack"_s, true }, + { u"waitForGdbAttach"_s, true }, + { u"dumpCore"_s, true } })); - QCOMPARE(c.caCertificates(), QStringList({ qSL("cert1"), qSL("cert2"), qSL("cert3") })); + QCOMPARE(c.caCertificates(), QStringList({ u"cert1"_s, u"cert2"_s, u"cert3"_s })); - QCOMPARE(c.pluginFilePaths("container"), QStringList({ qSL("c1"), qSL("c2"), qSL("c3"), qSL("c4") })); - QCOMPARE(c.pluginFilePaths("startup"), QStringList({ qSL("s1"), qSL("s2"), qSL("s3") })); + QCOMPARE(c.pluginFilePaths("container"), QStringList({ u"c1"_s, u"c2"_s, u"c3"_s, u"c4"_s })); + QCOMPARE(c.pluginFilePaths("startup"), QStringList({ u"s1"_s, u"s2"_s, u"s3"_s })); } void tst_Configuration::commandLineConfig() @@ -449,16 +451,16 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.verbose(), true); QCOMPARE(c.slowAnimations(), true); QCOMPARE(c.noDltLogging(), true); - QCOMPARE(c.singleApp(), qSL("appname")); + QCOMPARE(c.singleApp(), u"appname"_s); QCOMPARE(c.qmlDebugging(), true); // values from config file - QCOMPARE(c.mainQmlFile(), qSL("main-cl.qml")); + QCOMPARE(c.mainQmlFile(), u"main-cl.qml"_s); - QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ qSL("builtin-dir-cl1"), qSL("builtin-dir-cl2") })); - QCOMPARE(c.documentDir(), qSL("document-dir-cl")); + QCOMPARE(c.builtinAppsManifestDirs(), QStringList({ u"builtin-dir-cl1"_s, u"builtin-dir-cl2"_s })); + QCOMPARE(c.documentDir(), u"document-dir-cl"_s); - QCOMPARE(c.installationDir(), qSL("installation-dir-cl")); + QCOMPARE(c.installationDir(), u"installation-dir-cl"_s); QCOMPARE(c.disableInstaller(), true); QCOMPARE(c.disableIntents(), true); QCOMPARE(c.intentTimeoutForDisambiguation(), 10000); @@ -467,9 +469,9 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.intentTimeoutForReplyFromSystem(), 20000); QCOMPARE(c.fullscreen(), false); - QCOMPARE(c.windowIcon(), qSL("")); - QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(qSL("ip-cl1")), - pwd.absoluteFilePath(qSL("ip-cl2")) })); + QCOMPARE(c.windowIcon(), u""_s); + QCOMPARE(c.importPaths(), QStringList({ pwd.absoluteFilePath(u"ip-cl1"_s), + pwd.absoluteFilePath(u"ip-cl2"_s) })); QCOMPARE(c.pluginPaths(), {}); QCOMPARE(c.loadDummyData(), true); QCOMPARE(c.noSecurity(), true); @@ -477,14 +479,14 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.noUiWatchdog(), true); QCOMPARE(c.forceSingleProcess(), true); QCOMPARE(c.forceMultiProcess(), true); - QCOMPARE(c.loggingRules(), QStringList({ qSL("cl-lr1"), qSL("cl-lr2") })); - QCOMPARE(c.messagePattern(), qSL("")); + QCOMPARE(c.loggingRules(), QStringList({ u"cl-lr1"_s, u"cl-lr2"_s })); + QCOMPARE(c.messagePattern(), u""_s); QCOMPARE(c.useAMConsoleLogger(), QVariant()); - QCOMPARE(c.style(), qSL("")); - QCOMPARE(c.iconThemeName(), qSL("")); + QCOMPARE(c.style(), u""_s); + QCOMPARE(c.iconThemeName(), u""_s); QCOMPARE(c.iconThemeSearchPaths(), {}); - QCOMPARE(c.dltId(), qSL("")); - QCOMPARE(c.dltDescription(), qSL("")); + QCOMPARE(c.dltId(), u""_s); + QCOMPARE(c.dltDescription(), u""_s); QCOMPARE(c.resources(), {}); QCOMPARE(c.openGLConfiguration(), QVariantMap {}); @@ -496,14 +498,14 @@ void tst_Configuration::commandLineConfig() QCOMPARE(c.runtimeConfigurations(), QVariantMap{}); QCOMPARE(c.runtimeAdditionalLaunchers(), QStringList{}); - QCOMPARE(c.dbusRegistration("iface1"), qSL("system")); + QCOMPARE(c.dbusRegistration("iface1"), u"system"_s); QCOMPARE(c.rawSystemProperties(), QVariantMap {}); QCOMPARE(c.quickLaunchIdleLoad(), qreal(0)); QVERIFY(c.quickLaunchRuntimesPerContainer().isEmpty()); - QCOMPARE(c.waylandSocketName(), qSL("wlsock-1")); + QCOMPARE(c.waylandSocketName(), u"wlsock-1"_s); QCOMPARE(c.waylandExtraSockets(), {}); QCOMPARE(c.managerCrashAction(), QVariantMap {}); diff --git a/tests/auto/controller-tool/tst_controller-tool.cpp b/tests/auto/controller-tool/tst_controller-tool.cpp index 76c99d9f..0698fddb 100644 --- a/tests/auto/controller-tool/tst_controller-tool.cpp +++ b/tests/auto/controller-tool/tst_controller-tool.cpp @@ -22,6 +22,8 @@ #include "qtyaml.h" #include <QtAppManMain/configuration.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM using namespace QtYaml; @@ -93,7 +95,7 @@ public: m_ctrl.reset(new QProcess); m_spy.reset(new QSignalSpy(m_ctrl.get(), &QProcess::finished)); m_ctrl->setProgram(s_command); - QStringList args = { qSL("--instance-id"), qSL("controller-test-id") }; + QStringList args = { u"--instance-id"_s, u"controller-test-id"_s }; args.append(m_arguments); m_ctrl->setArguments(args); m_ctrl->start(); @@ -151,7 +153,7 @@ QString ControllerTool::s_command; tst_ControllerTool::tst_ControllerTool() : m_spyTimeout(5000 * timeoutFactor()) - , m_tmpDir(qSL("/tmp/am-test-controller-tool")) + , m_tmpDir(u"/tmp/am-test-controller-tool"_s) { } void tst_ControllerTool::initTestCase() @@ -160,7 +162,7 @@ void tst_ControllerTool::initTestCase() QSKIP("This test is only supported on Linux"); #endif - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); auto verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); @@ -176,10 +178,10 @@ void tst_ControllerTool::initTestCase() QStringList possibleLocations; possibleLocations.append(QLibraryInfo::path(QLibraryInfo::BinariesPath)); - possibleLocations.append(QCoreApplication::applicationDirPath() + qSL("/../../../bin")); + possibleLocations.append(QCoreApplication::applicationDirPath() + u"/../../../bin"_s); QString controllerPath; - const QString controllerName = qSL("/appman-controller"); + const QString controllerName = u"/appman-controller"_s; for (const QString &possibleLocation : possibleLocations) { QFileInfo fi(possibleLocation + controllerName); @@ -208,7 +210,7 @@ void tst_ControllerTool::initTestCase() if (m_tmpDir.exists()) m_tmpDir.removeRecursively(); - QVERIFY(m_tmpDir.mkpath(qSL("."))); + QVERIFY(m_tmpDir.mkpath(u"."_s)); } void tst_ControllerTool::cleanupTestCase() @@ -242,44 +244,44 @@ void tst_ControllerTool::usage() void tst_ControllerTool::instances() { - ControllerTool ctrl({ qSL("list-instances") }); + ControllerTool ctrl({ u"list-instances"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("\"controller-test-id\"") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"\"controller-test-id\""_s })); } void tst_ControllerTool::applications() { { - ControllerTool ctrl({ qSL("list-applications") }); + ControllerTool ctrl({ u"list-applications"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("green1"), qSL("green2") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"green1"_s, u"green2"_s })); } { - ControllerTool ctrl({ qSL("show-application"), qSL("green1") }); + ControllerTool ctrl({ u"show-application"_s, u"green1"_s }); QVERIFY2(ctrl.call(), ctrl.failure); const auto docs = YamlParser::parseAllDocuments(ctrl.stdOut); QCOMPARE(docs.size(), 1); const auto vm = docs[0].toMap(); QVariantMap expected({ - { qSL("applicationId"), qSL("green1") }, - { qSL("capabilities"), QVariantList { } }, - { qSL("categories"), QVariantList { } }, - { qSL("codeFilePath"), QFINDTESTDATA("builtin-apps/hello-world.green/main.qml") }, - { qSL("icon"), QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, - { qSL("isBlocked"), false }, - { qSL("isRemovable"), false }, - { qSL("isRunning"), false }, - { qSL("isShuttingDown"), false }, - { qSL("isStartingUp"), false }, - { qSL("isUpdating"), false }, - { qSL("lastExitCode"), 0 }, - { qSL("lastExitStatus"), 0 }, - { qSL("name"), qSL("Hello Green") }, - { qSL("runtimeName"), qSL("qml") }, - { qSL("runtimeParameters"), QVariantMap { } }, - { qSL("updateProgress"), 0 }, - { qSL("version"), qSL("1.2.3") }, + { u"applicationId"_s, u"green1"_s }, + { u"capabilities"_s, QVariantList { } }, + { u"categories"_s, QVariantList { } }, + { u"codeFilePath"_s, QFINDTESTDATA("builtin-apps/hello-world.green/main.qml") }, + { u"icon"_s, QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, + { u"isBlocked"_s, false }, + { u"isRemovable"_s, false }, + { u"isRunning"_s, false }, + { u"isShuttingDown"_s, false }, + { u"isStartingUp"_s, false }, + { u"isUpdating"_s, false }, + { u"lastExitCode"_s, 0 }, + { u"lastExitStatus"_s, 0 }, + { u"name"_s, u"Hello Green"_s }, + { u"runtimeName"_s, u"qml"_s }, + { u"runtimeParameters"_s, QVariantMap { } }, + { u"updateProgress"_s, 0 }, + { u"version"_s, u"1.2.3"_s }, }); QCOMPARE(vm, expected); } @@ -288,27 +290,27 @@ void tst_ControllerTool::applications() void tst_ControllerTool::packages() { { - ControllerTool ctrl({ qSL("list-packages") }); + ControllerTool ctrl({ u"list-packages"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("hello-world.green") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"hello-world.green"_s })); } { - ControllerTool ctrl({ qSL("show-package"), qSL("hello-world.green") }); + ControllerTool ctrl({ u"show-package"_s, u"hello-world.green"_s }); QVERIFY2(ctrl.call(), ctrl.failure); const auto docs = YamlParser::parseAllDocuments(ctrl.stdOut); QCOMPARE(docs.size(), 1); const auto vm = docs[0].toMap(); QVariantMap expected({ - { qSL("description"), qSL("Green description") }, - { qSL("icon"), QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, - { qSL("isBlocked"), false }, - { qSL("isRemovable"), false }, - { qSL("isUpdating"), false }, - { qSL("name"), qSL("Hello Green") }, - { qSL("packageId"), qSL("hello-world.green") }, - { qSL("updateProgress"), 0 }, - { qSL("version"), qSL("1.2.3") }, + { u"description"_s, u"Green description"_s }, + { u"icon"_s, QUrl::fromLocalFile(QFINDTESTDATA("builtin-apps/hello-world.green/icon.png")).toString() }, + { u"isBlocked"_s, false }, + { u"isRemovable"_s, false }, + { u"isUpdating"_s, false }, + { u"name"_s, u"Hello Green"_s }, + { u"packageId"_s, u"hello-world.green"_s }, + { u"updateProgress"_s, 0 }, + { u"version"_s, u"1.2.3"_s }, }); QCOMPARE(vm, expected); } @@ -317,45 +319,45 @@ void tst_ControllerTool::packages() void tst_ControllerTool::installationLocations() { { - ControllerTool ctrl({ qSL("list-installation-locations") }); + ControllerTool ctrl({ u"list-installation-locations"_s }); QVERIFY2(ctrl.call(), ctrl.failure); - QCOMPARE(ctrl.stdOutList, QStringList({ qSL("internal-0") })); + QCOMPARE(ctrl.stdOutList, QStringList({ u"internal-0"_s })); } { - ControllerTool ctrl({ qSL("show-installation-location"), qSL("internal-0") }); + ControllerTool ctrl({ u"show-installation-location"_s, u"internal-0"_s }); QVERIFY2(ctrl.call(), ctrl.failure); const auto docs = YamlParser::parseAllDocuments(ctrl.stdOut); QCOMPARE(docs.size(), 1); const auto vm = docs[0].toMap(); - QCOMPARE(vm.value(qSL("path")), qSL("/tmp/am-test-controller-tool/apps")); - QVERIFY(vm.value(qSL("deviceSize")).toULongLong() > 0); - QVERIFY(vm.value(qSL("deviceFree")).toULongLong() > 0); + QCOMPARE(vm.value(u"path"_s), u"/tmp/am-test-controller-tool/apps"_s); + QVERIFY(vm.value(u"deviceSize"_s).toULongLong() > 0); + QVERIFY(vm.value(u"deviceFree"_s).toULongLong() > 0); } } void tst_ControllerTool::installCancel() { - ControllerTool install({ qSL("install-package"), - qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); + ControllerTool install({ u"install-package"_s, + QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); QVERIFY2(install.start(), install.failure); - QTRY_VERIFY(PackageManager::instance()->isPackageInstallationActive(qSL("hello-world.red"))); + QTRY_VERIFY(PackageManager::instance()->isPackageInstallationActive(u"hello-world.red"_s)); QString taskId; { - ControllerTool ctrl({ qSL("list-installation-tasks") }); + ControllerTool ctrl({ u"list-installation-tasks"_s }); QVERIFY2(ctrl.call(), ctrl.failure); QCOMPARE(ctrl.stdOutList.size(), 1); taskId = ctrl.stdOutList.at(0); QVERIFY(!QUuid::fromString(taskId).isNull()); } { - ControllerTool ctrl({ qSL("cancel-installation-task"), taskId }); + ControllerTool ctrl({ u"cancel-installation-task"_s, taskId }); QVERIFY2(ctrl.call(), ctrl.failure); } { - ControllerTool ctrl({ qSL("list-installation-tasks") }); + ControllerTool ctrl({ u"list-installation-tasks"_s }); QVERIFY2(ctrl.call(), ctrl.failure); QCOMPARE(ctrl.stdOutList.size(), 0); } @@ -368,40 +370,40 @@ void tst_ControllerTool::installCancel() void tst_ControllerTool::installRemove() { { - ControllerTool ctrl({ qSL("install-package"), qSL("-a"), - qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); + ControllerTool ctrl({ u"install-package"_s, u"-a"_s, + QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg") }); QVERIFY2(ctrl.call(), ctrl.failure); } { - ControllerTool ctrl({ qSL("remove-package"), qSL("hello-world.red") }); + ControllerTool ctrl({ u"remove-package"_s, u"hello-world.red"_s }); QVERIFY2(ctrl.call(), ctrl.failure); } } void tst_ControllerTool::startStop() { - const auto app = ApplicationManager::instance()->application(qSL("green1")); + const auto app = ApplicationManager::instance()->application(u"green1"_s); QVERIFY(app); { - ControllerTool ctrl({ qSL("start-application"), app->id() }); + ControllerTool ctrl({ u"start-application"_s, app->id() }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::Running); { - ControllerTool ctrl({ qSL("stop-application"), app->id() }); + ControllerTool ctrl({ u"stop-application"_s, app->id() }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::NotRunning); { // debug-application does not work in single-process mode bool sp = ApplicationManager::instance()->isSingleProcess(); - ControllerTool ctrl(sp ? QStringList { qSL("start-application"), app->id() } - : QStringList { qSL("debug-application"), qSL("FOO=BAR"), app->id() }); + ControllerTool ctrl(sp ? QStringList { u"start-application"_s, app->id() } + : QStringList { u"debug-application"_s, u"FOO=BAR"_s, app->id() }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::Running); { - ControllerTool ctrl({ qSL("stop-all-applications") }); + ControllerTool ctrl({ u"stop-all-applications"_s }); QVERIFY2(ctrl.call(), ctrl.failure); } QTRY_VERIFY(app->runState() == Am::NotRunning); @@ -412,15 +414,15 @@ void tst_ControllerTool::injectIntent() auto oldDevMode = PackageManager::instance()->developmentMode(); PackageManager::instance()->setDevelopmentMode(true); - ControllerTool ctrl({ qSL("inject-intent-request"), qSL("--requesting-application-id"), - qSL(":sysui:"), qSL("--application-id"), qSL(":sysui:"), qSL("inject-intent"), qSL("{ }"), }); + ControllerTool ctrl({ u"inject-intent-request"_s, u"--requesting-application-id"_s, + u":sysui:"_s, u"--application-id"_s, u":sysui:"_s, u"inject-intent"_s, u"{ }"_s, }); QVERIFY2(ctrl.call(), ctrl.failure); const auto json = QJsonDocument::fromJson(ctrl.stdOut); const auto vm = json.toVariant().toMap(); QVariantMap expected({ - { qSL("status"), qSL("ok") }, + { u"status"_s, u"ok"_s }, }); QCOMPARE(vm, expected); diff --git a/tests/auto/error-checking.h b/tests/auto/error-checking.h index 0e207b88..edae213e 100644 --- a/tests/auto/error-checking.h +++ b/tests/auto/error-checking.h @@ -9,7 +9,7 @@ // sadly this has to be a define for QVERIFY2() to work #define QT_AM_CHECK_ERRORSTRING(_actual_errstr, _expected_errstr) do { \ - if (_expected_errstr.startsWith(QLatin1String("~"))) { \ + if (_expected_errstr.startsWith(u"~")) { \ QRegularExpression re(_expected_errstr.mid(1)); \ QVERIFY2(re.match(_actual_errstr).hasMatch(), \ QByteArray("\n Got : ") + _actual_errstr.toLocal8Bit() + \ diff --git a/tests/auto/installationreport/tst_installationreport.cpp b/tests/auto/installationreport/tst_installationreport.cpp index 62f4c613..adf3403b 100644 --- a/tests/auto/installationreport/tst_installationreport.cpp +++ b/tests/auto/installationreport/tst_installationreport.cpp @@ -10,6 +10,8 @@ #include "exception.h" #include "installationreport.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_InstallationReport : public QObject @@ -28,9 +30,9 @@ tst_InstallationReport::tst_InstallationReport() void tst_InstallationReport::test() { - QStringList files { qSL("test"), qSL("more/test"), qSL("another/test/file") }; + QStringList files { u"test"_s, u"more/test"_s, u"another/test/file"_s }; - InstallationReport ir(qSL("com.pelagicore.test")); + InstallationReport ir(u"com.pelagicore.test"_s); QVERIFY(!ir.isValid()); ir.addFile(files.first()); QVERIFY(!ir.isValid()); @@ -43,7 +45,7 @@ void tst_InstallationReport::test() ir.setStoreSignature("$$store-sig$$"); QVERIFY(ir.isValid()); - QCOMPARE(ir.packageId(), qSL("com.pelagicore.test")); + QCOMPARE(ir.packageId(), u"com.pelagicore.test"_s); QCOMPARE(ir.files(), files); QCOMPARE(ir.diskSpaceUsed(), 42ULL); QCOMPARE(ir.digest().constData(), "##digest##"); @@ -64,7 +66,7 @@ void tst_InstallationReport::test() buffer.seek(0); QVERIFY(ir2.isValid()); - QCOMPARE(ir2.packageId(), qSL("com.pelagicore.test")); + QCOMPARE(ir2.packageId(), u"com.pelagicore.test"_s); QCOMPARE(ir2.files(), files); QCOMPARE(ir2.diskSpaceUsed(), 42ULL); QCOMPARE(ir2.digest().constData(), "##digest##"); diff --git a/tests/auto/main/tst_main.cpp b/tests/auto/main/tst_main.cpp index d1336ff7..be285c90 100644 --- a/tests/auto/main/tst_main.cpp +++ b/tests/auto/main/tst_main.cpp @@ -19,6 +19,8 @@ #include "utilities.h" #include <QtAppManMain/configuration.h> +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM @@ -66,7 +68,7 @@ tst_Main::~tst_Main() void tst_Main::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); m_verbose = qEnvironmentVariableIsSet("AM_VERBOSE_TEST"); @@ -92,12 +94,12 @@ void tst_Main::copyRecursively(const QString &sourcePath, const QString &destPat void tst_Main::cleanUpInstallationDir() { { - QDir testTmpDir(qSL("/tmp/am-test-main")); + QDir testTmpDir(u"/tmp/am-test-main"_s); if (testTmpDir.exists()) testTmpDir.removeRecursively(); } - QDir tmpDir(qSL("/tmp")); - tmpDir.mkdir(qSL("am-test-main")); + QDir tmpDir(u"/tmp"_s); + tmpDir.mkdir(u"am-test-main"_s); } void tst_Main::init() @@ -199,29 +201,29 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() QCOMPARE(intents->count(), 2); auto app1 = appMan->application(0); - QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Red")); - QCOMPARE(app1->id(), qSL("red1")); + QCOMPARE(app1->names().value(u"en"_s), u"Hello Red"_s); + QCOMPARE(app1->id(), u"red1"_s); auto app2 = appMan->application(1); - QCOMPARE(app2->names().value(qSL("en")), qSL("Hello Red")); - QCOMPARE(app2->id(), qSL("red2")); + QCOMPARE(app2->names().value(u"en"_s), u"Hello Red"_s); + QCOMPARE(app2->id(), u"red2"_s); - auto intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1")); + auto intent1 = intents->applicationIntent(u"red.intent1"_s, u"red1"_s); QVERIFY(intent1); - QCOMPARE(intent1->intentId(), qSL("red.intent1")); - QCOMPARE(intent1->applicationId(), qSL("red1")); - QCOMPARE(intent1->packageId(), qSL("hello-world.red")); - QVERIFY(intent1->categories().contains(qSL("one"))); - QVERIFY(intent1->categories().contains(qSL("launcher"))); + QCOMPARE(intent1->intentId(), u"red.intent1"_s); + QCOMPARE(intent1->applicationId(), u"red1"_s); + QCOMPARE(intent1->packageId(), u"hello-world.red"_s); + QVERIFY(intent1->categories().contains(u"one"_s)); + QVERIFY(intent1->categories().contains(u"launcher"_s)); - auto intent2 = intents->applicationIntent(qSL("red.intent2"), qSL("red2")); + auto intent2 = intents->applicationIntent(u"red.intent2"_s, u"red2"_s); QVERIFY(intent2); - QCOMPARE(intent2->intentId(), qSL("red.intent2")); - QCOMPARE(intent2->applicationId(), qSL("red2")); - QCOMPARE(intent2->packageId(), qSL("hello-world.red")); - QVERIFY(intent2->categories().contains(qSL("two"))); - QVERIFY(intent2->categories().contains(qSL("launcher"))); + QCOMPARE(intent2->intentId(), u"red.intent2"_s); + QCOMPARE(intent2->applicationId(), u"red2"_s); + QCOMPARE(intent2->packageId(), u"hello-world.red"_s); + QVERIFY(intent2->categories().contains(u"two"_s)); + QVERIFY(intent2->categories().contains(u"launcher"_s)); - installPackage(qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); + installPackage(QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); QCOMPARE(appMan->count(), 1); QCOMPARE(intents->count(), 0); @@ -231,11 +233,11 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() app1 = appMan->application(0); // but with different contents - QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Updated Red")); - intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1")); + QCOMPARE(app1->names().value(u"en"_s), u"Hello Updated Red"_s); + intent1 = intents->applicationIntent(u"red.intent1"_s, u"red1"_s); QVERIFY(!intent1); - removePackage(qSL("hello-world.red")); + removePackage(u"hello-world.red"_s); // After removal of the updated version all data in Application should be as before the // installation took place. @@ -243,13 +245,13 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() QCOMPARE(intents->count(), 2); app1 = appMan->application(0); - QCOMPARE(app1->names().value(qSL("en")), qSL("Hello Red")); - intent1 = intents->applicationIntent(qSL("red.intent1"), qSL("red1")); + QCOMPARE(app1->names().value(u"en"_s), u"Hello Red"_s); + intent1 = intents->applicationIntent(u"red.intent1"_s, u"red1"_s); QVERIFY(intent1); - QCOMPARE(intent1->intentId(), qSL("red.intent1")); - intent2 = intents->applicationIntent(qSL("red.intent2"), qSL("red2")); + QCOMPARE(intent1->intentId(), u"red.intent1"_s); + intent2 = intents->applicationIntent(u"red.intent2"_s, u"red2"_s); QVERIFY(intent2); - QCOMPARE(intent2->intentId(), qSL("red.intent2")); + QCOMPARE(intent2->intentId(), u"red.intent2"_s); } /* @@ -263,7 +265,7 @@ void tst_Main::installAndRemoveUpdateForBuiltIn() */ void tst_Main::updateForBuiltInAlreadyInstalled() { - copyRecursively(QFINDTESTDATA("dir-with-update-already-installed"), qSL("/tmp/am-test-main")); + copyRecursively(QFINDTESTDATA("dir-with-update-already-installed"), u"/tmp/am-test-main"_s); initMain(); @@ -271,7 +273,7 @@ void tst_Main::updateForBuiltInAlreadyInstalled() QCOMPARE(appMan->count(), 1); auto app = appMan->application(0); - QCOMPARE(app->names().value(qSL("en")), qSL("Hello Updated Red")); + QCOMPARE(app->names().value(u"en"_s), u"Hello Updated Red"_s); } /* @@ -283,7 +285,7 @@ void tst_Main::updateForBuiltInAlreadyInstalled() void tst_Main::loadDatabaseWithUpdatedBuiltInApp() { initMain(); - installPackage(qL1S(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); + installPackage(QString::fromLatin1(AM_TESTDATA_DIR "packages/hello-world.red.appkg")); destroyMain(); initMain(); @@ -292,7 +294,7 @@ void tst_Main::loadDatabaseWithUpdatedBuiltInApp() QCOMPARE(appMan->count(), 1); auto app = appMan->application(0); - QCOMPARE(app->names().value(qSL("en")), qSL("Hello Updated Red")); + QCOMPARE(app->names().value(u"en"_s), u"Hello Updated Red"_s); } void tst_Main::mainQmlFile_data() @@ -351,7 +353,7 @@ void tst_Main::startupTimer() initMain(); - StartupTimer::instance()->createReport(qSL("TEST")); + StartupTimer::instance()->createReport(u"TEST"_s); QFile f(fn); QVERIFY(f.open(QIODevice::ReadOnly)); diff --git a/tests/auto/packagecreator/tst_packagecreator.cpp b/tests/auto/packagecreator/tst_packagecreator.cpp index bc748ee0..fe9459fa 100644 --- a/tests/auto/packagecreator/tst_packagecreator.cpp +++ b/tests/auto/packagecreator/tst_packagecreator.cpp @@ -13,6 +13,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM static int processTimeout = 3000; @@ -40,7 +42,7 @@ private: }; tst_PackageCreator::tst_PackageCreator() - : m_baseDir(qSL(AM_TESTDATA_DIR)) + : m_baseDir(QString::fromLatin1(AM_TESTDATA_DIR)) { } void tst_PackageCreator::initTestCase() @@ -49,14 +51,14 @@ void tst_PackageCreator::initTestCase() // check if tar command is available at all QProcess tar; - tar.start(qSL("tar"), { qSL("--version") }); + tar.start(u"tar"_s, { u"--version"_s }); m_tarAvailable = tar.waitForStarted(processTimeout) && tar.waitForFinished(processTimeout) && (tar.exitStatus() == QProcess::NormalExit); m_isCygwin = tar.readAllStandardOutput().contains("Cygwin"); - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); } @@ -66,8 +68,8 @@ void tst_PackageCreator::createAndVerify_data() QTest::addColumn<bool>("expectedSuccess"); QTest::addColumn<QString>("errorString"); - QTest::newRow("basic") << QStringList { qSL("testfile") } << true << ""; - QTest::newRow("no-such-file") << QStringList { qSL("tastfile") } << false << "~file not found: .*"; + QTest::newRow("basic") << QStringList { u"testfile"_s } << true << ""; + QTest::newRow("no-such-file") << QStringList { u"tastfile"_s } << false << "~file not found: .*"; } void tst_PackageCreator::createAndVerify() @@ -79,7 +81,7 @@ void tst_PackageCreator::createAndVerify() QTemporaryFile output; QVERIFY(output.open()); - InstallationReport report(qSL("com.pelagicore.test")); + InstallationReport report(u"com.pelagicore.test"_s); report.addFiles(files); PackageCreator creator(m_baseDir, &output, report); @@ -102,7 +104,7 @@ void tst_PackageCreator::createAndVerify() QSKIP("No tar command found in PATH - skipping the verification part of the test!"); QProcess tar; - tar.start(qSL("tar"), { qSL("-tzf"), escapeFilename(output.fileName()) }); + tar.start(u"tar"_s, { u"-tzf"_s, escapeFilename(output.fileName()) }); QVERIFY2(tar.waitForStarted(processTimeout) && tar.waitForFinished(processTimeout) && (tar.exitStatus() == QProcess::NormalExit) && @@ -110,12 +112,12 @@ void tst_PackageCreator::createAndVerify() QStringList expectedContents = files; expectedContents.sort(); - expectedContents.prepend(qSL("--PACKAGE-HEADER--")); - expectedContents.append(qSL("--PACKAGE-FOOTER--")); + expectedContents.prepend(u"--PACKAGE-HEADER--"_s); + expectedContents.append(u"--PACKAGE-FOOTER--"_s); - QStringList actualContents = QString::fromLocal8Bit(tar.readAllStandardOutput()).split(qL1C('\n'), Qt::SkipEmptyParts); + QStringList actualContents = QString::fromLocal8Bit(tar.readAllStandardOutput()).split(u'\n', Qt::SkipEmptyParts); #if defined(Q_OS_WIN) - actualContents.replaceInStrings(qSL("\r"), QString()); + actualContents.replaceInStrings(u"\r"_s, QString()); #endif QCOMPARE(actualContents, expectedContents); @@ -126,7 +128,7 @@ void tst_PackageCreator::createAndVerify() QVERIFY2(src.open(QFile::ReadOnly), qPrintable(src.errorString())); QByteArray data = src.readAll(); - tar.start(qSL("tar"), { qSL("-xzOf"), escapeFilename(output.fileName()), file }); + tar.start(u"tar"_s, { u"-xzOf"_s, escapeFilename(output.fileName()), file }); QVERIFY2(tar.waitForStarted(processTimeout) && tar.waitForFinished(processTimeout) && (tar.exitStatus() == QProcess::NormalExit) && @@ -142,7 +144,7 @@ QString tst_PackageCreator::escapeFilename(const QString &name) return name; } else { QString s = QFileInfo(name).absoluteFilePath(); - QString t = qSL("/cygdrive/"); + QString t = u"/cygdrive/"_s; t.append(s.at(0)); return t + s.mid(2); } diff --git a/tests/auto/packageextractor/tst_packageextractor.cpp b/tests/auto/packageextractor/tst_packageextractor.cpp index 43d1fd75..e9f21b90 100644 --- a/tests/auto/packageextractor/tst_packageextractor.cpp +++ b/tests/auto/packageextractor/tst_packageextractor.cpp @@ -24,6 +24,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_PackageExtractor : public QObject @@ -56,7 +58,7 @@ tst_PackageExtractor::tst_PackageExtractor() void tst_PackageExtractor::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); } @@ -87,31 +89,31 @@ void tst_PackageExtractor::extractAndVerify_data() QTest::newRow("normal") << "packages/test.appkg" << true << "" << QStringList { - qSL("info.yaml"), - qSL("icon.png"), - qSL("test"), + u"info.yaml"_s, + u"icon.png"_s, + u"test"_s, m_taest } << QMap<QString, QByteArray> { - { qSL("test"), "test\n" }, + { u"test"_s, "test\n" }, { m_taest, "test with umlaut\n" } } << noSizes; QTest::newRow("big") << "packages/bigtest.appkg" << true << "" << QStringList { - qSL("info.yaml"), - qSL("icon.png"), - qSL("test"), + u"info.yaml"_s, + u"icon.png"_s, + u"test"_s, m_taest, - qSL("bigtest") } + u"bigtest"_s } << QMap<QString, QByteArray> { - { qSL("test"), "test\n" }, + { u"test"_s, "test\n" }, { m_taest, "test with umlaut\n" } } << QMap<QString, qint64> { // { "info.yaml", 213 }, // this is different on Windows: \n vs. \r\n - { qSL("icon.png"), 1157 }, - { qSL("bigtest"), 5*1024*1024 }, - { qSL("test"), 5 }, + { u"icon.png"_s, 1157 }, + { u"bigtest"_s, 5*1024*1024 }, + { u"test"_s, 5 }, { m_taest, 17 } }; QTest::newRow("invalid-url") << "packages/no-such-file.appkg" @@ -141,7 +143,7 @@ void tst_PackageExtractor::extractAndVerify() QFETCH(ByteArrayMap, content); QFETCH(IntMap, sizes); - PackageExtractor extractor(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR) + path), m_extractDir->path()); + PackageExtractor extractor(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR) + path), m_extractDir->path()); bool result = extractor.extract(); if (expectedSuccess) { @@ -179,7 +181,7 @@ void tst_PackageExtractor::extractAndVerify() QVERIFY(checkEntries.removeOne(entry)); } - QVERIFY2(checkEntries.isEmpty(), qPrintable(checkEntries.join(qL1C(' ')))); + QVERIFY2(checkEntries.isEmpty(), qPrintable(checkEntries.join(u' '))); QStringList reportEntries = extractor.installationReport().files(); reportEntries.sort(); @@ -190,7 +192,7 @@ void tst_PackageExtractor::extractAndVerify() void tst_PackageExtractor::cancelExtraction() { { - PackageExtractor extractor(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); + PackageExtractor extractor(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); extractor.cancel(); QVERIFY(!extractor.extract()); QVERIFY(extractor.wasCanceled()); @@ -198,7 +200,7 @@ void tst_PackageExtractor::cancelExtraction() QVERIFY(extractor.hasFailed()); } { - PackageExtractor extractor(QUrl::fromLocalFile(qL1S(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); + PackageExtractor extractor(QUrl::fromLocalFile(QString::fromLatin1(AM_TESTDATA_DIR "packages/test.appkg")), m_extractDir->path()); connect(&extractor, &PackageExtractor::progress, this, [&extractor](qreal p) { if (p >= 0.1) extractor.cancel(); @@ -216,7 +218,7 @@ public: FifoSource(const QString &file) : m_file(file) { - m_fifoPath = QDir::temp().absoluteFilePath(qSL("autotext-package-extractor-%1.fifo")) + m_fifoPath = QDir::temp().absoluteFilePath(u"autotext-package-extractor-%1.fifo"_s) .arg(QCoreApplication::applicationPid()) .toLocal8Bit(); #ifdef Q_OS_UNIX @@ -267,7 +269,7 @@ void tst_PackageExtractor::extractFromFifo() QSKIP("No FIFO support on this platform"); #endif - FifoSource fifo(qL1S(AM_TESTDATA_DIR "packages/test.appkg")); + FifoSource fifo(QString::fromLatin1(AM_TESTDATA_DIR "packages/test.appkg")); fifo.start(); PackageExtractor extractor(QUrl::fromLocalFile(fifo.path()), m_extractDir->path()); diff --git a/tests/auto/packager-tool/tst_packager-tool.cpp b/tests/auto/packager-tool/tst_packager-tool.cpp index e8083e5d..8758c10b 100644 --- a/tests/auto/packager-tool/tst_packager-tool.cpp +++ b/tests/auto/packager-tool/tst_packager-tool.cpp @@ -20,6 +20,8 @@ #include "../error-checking.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM static int spyTimeout = 5000; // shorthand for specifying QSignalSpy timeouts @@ -40,7 +42,7 @@ private Q_SLOTS: private: QString pathTo(const char *file) { - return QDir(m_workDir.path()).absoluteFilePath(QLatin1String(file)); + return QDir(m_workDir.path()).absoluteFilePath(QString::fromLatin1(file)); } bool createInfoYaml(QTemporaryDir &tmp, const QString &changeField = QString(), const QVariant &toValue = QVariant()); @@ -63,7 +65,7 @@ private: void tst_PackagerTool::initTestCase() { - if (!QDir(qL1S(AM_TESTDATA_DIR "/packages")).exists()) + if (!QDir(QString::fromLatin1(AM_TESTDATA_DIR "/packages")).exists()) QSKIP("No test packages available in the data/ directory"); spyTimeout *= timeoutFactor(); @@ -72,7 +74,7 @@ void tst_PackagerTool::initTestCase() QVERIFY(QDir::root().mkpath(pathTo("internal-0"))); QVERIFY(QDir::root().mkpath(pathTo("documents-0"))); - m_hardwareId = qSL("foobar"); + m_hardwareId = u"foobar"_s; PackageDatabase *pdb = new PackageDatabase({}, pathTo("internal-0")); try { @@ -89,8 +91,8 @@ void tst_PackagerTool::initTestCase() // crypto stuff - we need to load the root CA and developer CA certificates - QFile devcaFile(qL1S(AM_TESTDATA_DIR "certificates/devca.crt")); - QFile caFile(qL1S(AM_TESTDATA_DIR "certificates/ca.crt")); + QFile devcaFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/devca.crt")); + QFile caFile(QString::fromLatin1(AM_TESTDATA_DIR "certificates/ca.crt")); QVERIFY2(devcaFile.open(QIODevice::ReadOnly), qPrintable(devcaFile.errorString())); QVERIFY2(caFile.open(QIODevice::ReadOnly), qPrintable(devcaFile.errorString())); @@ -102,12 +104,12 @@ void tst_PackagerTool::initTestCase() m_caFiles << devcaFile.fileName() << caFile.fileName(); - m_devPassword = qSL("password"); - m_devCertificate = qL1S(AM_TESTDATA_DIR "certificates/dev1.p12"); - m_storePassword = qSL("password"); - m_storeCertificate = qL1S(AM_TESTDATA_DIR "certificates/store.p12"); + m_devPassword = u"password"_s; + m_devCertificate = QString::fromLatin1(AM_TESTDATA_DIR "certificates/dev1.p12"); + m_storePassword = u"password"_s; + m_storeCertificate = QString::fromLatin1(AM_TESTDATA_DIR "certificates/store.p12"); - RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(qSL("qml"))); + RuntimeFactory::instance()->registerRuntime(new QmlInProcRuntimeManager(u"qml"_s)); } void tst_PackagerTool::cleanup() @@ -145,32 +147,32 @@ void tst_PackagerTool::test() // no valid destination QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), pathTo("test.appkg")), errorString)); - QVERIFY2(errorString.contains(qL1S("is not a directory")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"is not a directory"), qPrintable(errorString)); // no valid info.yaml QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("Cannot open for reading")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"Cannot open for reading"), qPrintable(errorString)); // add an info.yaml file createInfoYaml(tmp); // no icon QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("missing the file referenced by the 'icon' field")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"missing the file referenced by the 'icon' field"), qPrintable(errorString)); // add an icon createIconPng(tmp); // no valid code QVERIFY(!packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("missing the file referenced by the 'code' field")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"missing the file referenced by the 'code' field"), qPrintable(errorString)); // add a code file createCode(tmp); // invalid destination QVERIFY(!packagerCheck(PackagingJob::create(tmp.path(), tmp.path()), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create package file")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"could not create package file"), qPrintable(errorString)); // now everything is correct - try again QVERIFY2(packagerCheck(PackagingJob::create(pathTo("test.appkg"), tmp.path()), errorString), qPrintable(errorString)); @@ -181,7 +183,7 @@ void tst_PackagerTool::test() pathTo("test.dev-signed.appkg"), m_devCertificate, m_devPassword), errorString)); - QVERIFY2(errorString.contains(qL1S("does not exist")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"does not exist"), qPrintable(errorString)); // invalid destination package QVERIFY(!packagerCheck(PackagingJob::developerSign( @@ -189,7 +191,7 @@ void tst_PackagerTool::test() pathTo("."), m_devCertificate, m_devPassword), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create package file")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"could not create package file"), qPrintable(errorString)); // invalid dev key @@ -197,17 +199,17 @@ void tst_PackagerTool::test() pathTo("test.appkg"), pathTo("test.dev-signed.appkg"), m_devCertificate, - qSL("wrong-password")), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create signature")), qPrintable(errorString)); + u"wrong-password"_s), errorString)); + QVERIFY2(errorString.contains(u"could not create signature"), qPrintable(errorString)); // invalid store key QVERIFY(!packagerCheck(PackagingJob::storeSign( pathTo("test.appkg"), pathTo("test.store-signed.appkg"), m_storeCertificate, - qSL("wrong-password"), + u"wrong-password"_s, m_hardwareId), errorString)); - QVERIFY2(errorString.contains(qL1S("could not create signature")), qPrintable(errorString)); + QVERIFY2(errorString.contains(u"could not create signature"), qPrintable(errorString)); // sign QVERIFY2(packagerCheck(PackagingJob::developerSign( @@ -238,9 +240,9 @@ void tst_PackagerTool::test() installPackage(pathTo("test.dev-signed.appkg")); QDir checkDir(pathTo("internal-0")); - QVERIFY(checkDir.cd(qSL("com.pelagicore.test"))); + QVERIFY(checkDir.cd(u"com.pelagicore.test"_s)); - for (const QString &file : { qSL("info.yaml"), qSL("icon.png"), qSL("test.qml") }) { + for (const QString &file : { u"info.yaml"_s, u"icon.png"_s, u"test.qml"_s }) { QVERIFY(checkDir.exists(file)); QFile src(QDir(tmp.path()).absoluteFilePath(file)); QVERIFY(src.open(QFile::ReadOnly)); @@ -289,9 +291,9 @@ void tst_PackagerTool::iconFileName() QTemporaryDir tmp; QString errorString; - createInfoYaml(tmp, qSL("icon"), qSL("foo.bar")); + createInfoYaml(tmp, u"icon"_s, u"foo.bar"_s); createCode(tmp); - createDummyFile(tmp, qSL("foo.bar"), "this-is-a-dummy-icon-file"); + createDummyFile(tmp, u"foo.bar"_s, "this-is-a-dummy-icon-file"); QVERIFY2(packagerCheck(PackagingJob::create(pathTo("test-foobar-icon.appkg"), tmp.path()), errorString), qPrintable(errorString)); @@ -303,9 +305,9 @@ void tst_PackagerTool::iconFileName() m_pm->setAllowInstallationOfUnsignedPackages(false); QDir checkDir(pathTo("internal-0")); - QVERIFY(checkDir.cd(qSL("com.pelagicore.test"))); + QVERIFY(checkDir.cd(u"com.pelagicore.test"_s)); - for (const QString &file : { qSL("info.yaml"), qSL("foo.bar"), qSL("test.qml") }) { + for (const QString &file : { u"info.yaml"_s, u"foo.bar"_s, u"test.qml"_s }) { QVERIFY(checkDir.exists(file)); QFile src(QDir(tmp.path()).absoluteFilePath(file)); QVERIFY(src.open(QFile::ReadOnly)); @@ -343,19 +345,19 @@ bool tst_PackagerTool::createInfoYaml(QTemporaryDir &tmp, const QString &changeF yaml = QtYaml::yamlFromVariantDocuments({ docs.at(0), map }); } - QFile infoYaml(QDir(tmp.path()).absoluteFilePath(qSL("info.yaml"))); + QFile infoYaml(QDir(tmp.path()).absoluteFilePath(u"info.yaml"_s)); return infoYaml.open(QFile::WriteOnly) && infoYaml.write(yaml) == yaml.size(); } bool tst_PackagerTool::createIconPng(QTemporaryDir &tmp) { - QFile iconPng(QDir(tmp.path()).absoluteFilePath(qSL("icon.png"))); + QFile iconPng(QDir(tmp.path()).absoluteFilePath(u"icon.png"_s)); return iconPng.open(QFile::WriteOnly) && iconPng.write("\x89PNG") == 4; } bool tst_PackagerTool::createCode(QTemporaryDir &tmp) { - QFile code(QDir(tmp.path()).absoluteFilePath(qSL("test.qml"))); + QFile code(QDir(tmp.path()).absoluteFilePath(u"test.qml"_s)); return code.open(QFile::WriteOnly) && code.write("// test") == 7LL; } diff --git a/tests/auto/runtime/tst_runtime.cpp b/tests/auto/runtime/tst_runtime.cpp index d3591f64..d86e9865 100644 --- a/tests/auto/runtime/tst_runtime.cpp +++ b/tests/auto/runtime/tst_runtime.cpp @@ -14,6 +14,8 @@ #include "runtimefactory.h" #include "exception.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Runtime : public QObject @@ -68,7 +70,7 @@ public: : AbstractRuntimeManager(id, parent) { } - static QString defaultIdentifier() { return qSL("foo"); } + static QString defaultIdentifier() { return u"foo"_s; } bool inProcess() const override { @@ -93,8 +95,8 @@ void tst_Runtime::factory() QVERIFY(rf.get() == RuntimeFactory::instance()); QVERIFY(rf->runtimeIds().isEmpty()); - QVERIFY(rf->registerRuntime(new TestRuntimeManager(qSL("foo"), qApp))); - QVERIFY(rf->runtimeIds() == QStringList() << qSL("foo")); + QVERIFY(rf->registerRuntime(new TestRuntimeManager(u"foo"_s, qApp))); + QVERIFY(rf->runtimeIds() == QStringList() << u"foo"_s); QVERIFY(!rf->create(nullptr, nullptr)); diff --git a/tests/auto/signature/tst_signature.cpp b/tests/auto/signature/tst_signature.cpp index 67ccc867..babfd3a4 100644 --- a/tests/auto/signature/tst_signature.cpp +++ b/tests/auto/signature/tst_signature.cpp @@ -10,6 +10,8 @@ #include "signature.h" #include "cryptography.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Signature : public QObject @@ -43,17 +45,17 @@ tst_Signature::tst_Signature() void tst_Signature::initTestCase() { - QFile s(qSL(":/signing.p12")); + QFile s(u":/signing.p12"_s); QVERIFY(s.open(QIODevice::ReadOnly)); m_signingP12 = s.readAll(); QVERIFY(!m_signingP12.isEmpty()); - QFile snk(qSL(":/signing-no-key.p12")); + QFile snk(u":/signing-no-key.p12"_s); QVERIFY(snk.open(QIODevice::ReadOnly)); m_signingNoKeyP12 = snk.readAll(); QVERIFY(!m_signingNoKeyP12.isEmpty()); - QFile v(qSL(":/verifying.crt")); + QFile v(u":/verifying.crt"_s); QVERIFY(v.open(QIODevice::ReadOnly)); m_verifyingPEM << v.readAll(); QVERIFY(!m_verifyingPEM.first().isEmpty()); @@ -80,35 +82,35 @@ void tst_Signature::check() QVERIFY(!s2.verify(signature, m_verifyingPEM)); QVERIFY(s.create(m_signingP12, m_signingPassword + "not").isEmpty()); - QVERIFY2(s.errorString().contains(qSL("not parse")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not parse"_s), qPrintable(s.errorString())); QVERIFY(s.create(QByteArray(), m_signingPassword).isEmpty()); - QVERIFY2(s.errorString().contains(qSL("not read")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not read"_s), qPrintable(s.errorString())); Signature s3(QByteArray(4096, 'x')); QVERIFY(!s3.create(m_signingP12, m_signingPassword).isEmpty()); QVERIFY(!s.verify(signature, QList<QByteArray>())); - QVERIFY2(s.errorString().contains(qSL("Failed to verify")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"Failed to verify"_s), qPrintable(s.errorString())); QVERIFY(!s.verify(signature, QList<QByteArray>() << m_signingP12)); - QVERIFY2(s.errorString().contains(qSL("not load")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not load"_s), qPrintable(s.errorString())); QVERIFY(!s.verify(hash, QList<QByteArray>() << m_signingP12)); - QVERIFY2(s.errorString().contains(qSL("not read")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"not read"_s), qPrintable(s.errorString())); Signature s4 { QByteArray() }; QVERIFY(s4.create(m_signingP12, m_signingPassword).isEmpty()); QVERIFY(s.create(m_signingNoKeyP12, m_signingPassword).isEmpty()); - QVERIFY2(s.errorString().contains(qSL("private key")), qPrintable(s.errorString())); + QVERIFY2(s.errorString().contains(u"private key"_s), qPrintable(s.errorString())); } void tst_Signature::crossPlatform() { QByteArray hash = "hello\nworld!"; - QFile fileOpenSsl(qSL(":/signature-openssl.p7")); - QFile fileWinCrypt(qSL(":/signature-wincrypt.p7")); - QFile fileSecurityFramework(qSL(":/signature-securityframework.p7")); + QFile fileOpenSsl(u":/signature-openssl.p7"_s); + QFile fileWinCrypt(u":/signature-wincrypt.p7"_s); + QFile fileSecurityFramework(u":/signature-securityframework.p7"_s); if (qEnvironmentVariableIsSet("AM_CREATE_SIGNATURE_FILE")) { QFile *nativeFile = nullptr; @@ -120,7 +122,7 @@ void tst_Signature::crossPlatform() nativeFile = &fileOpenSsl; #endif QVERIFY(nativeFile); - QFile f(qL1S(AM_TESTSOURCE_DIR "/../signature") + nativeFile->fileName().mid(1)); + QFile f(QString::fromLatin1(AM_TESTSOURCE_DIR "/../signature") + nativeFile->fileName().mid(1)); QVERIFY2(f.open(QFile::WriteOnly | QFile::Truncate), qPrintable(f.errorString())); Signature s(hash); diff --git a/tests/auto/systemreader/tst_systemreader.cpp b/tests/auto/systemreader/tst_systemreader.cpp index 2657c11d..7b56c55f 100644 --- a/tests/auto/systemreader/tst_systemreader.cpp +++ b/tests/auto/systemreader/tst_systemreader.cpp @@ -8,6 +8,8 @@ #include "systemreader.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_SystemReader : public QObject @@ -25,7 +27,7 @@ private slots: tst_SystemReader::tst_SystemReader() { - g_systemRootDir = qL1S(":/root"); + g_systemRootDir = u":/root"_s; } void tst_SystemReader::cgroupProcessInfo() @@ -36,14 +38,14 @@ void tst_SystemReader::cgroupProcessInfo() void tst_SystemReader::memoryReaderReadUsedValue() { - MemoryReader memoryReader(qSL("/system.slice/run-u5853.scope")); + MemoryReader memoryReader(u"/system.slice/run-u5853.scope"_s); quint64 value = memoryReader.readUsedValue(); QCOMPARE(value, Q_UINT64_C(66809856)); } void tst_SystemReader::memoryReaderGroupLimit() { - MemoryReader memoryReader(qSL("/system.slice/run-u5853.scope")); + MemoryReader memoryReader(u"/system.slice/run-u5853.scope"_s); quint64 value = memoryReader.groupLimit(); QCOMPARE(value, Q_UINT64_C(524288000)); } diff --git a/tests/auto/yaml/tst_yaml.cpp b/tests/auto/yaml/tst_yaml.cpp index 2c87c7c3..ae5e2cdb 100644 --- a/tests/auto/yaml/tst_yaml.cpp +++ b/tests/auto/yaml/tst_yaml.cpp @@ -12,6 +12,8 @@ #include "exception.h" #include "global.h" +using namespace Qt::StringLiterals; + QT_USE_NAMESPACE_AM class tst_Yaml : public QObject @@ -53,24 +55,24 @@ void tst_Yaml::parser() { "null-literal", vnull }, { "null-tilde", vnull }, { "null-empty", vnull }, - { "string-unquoted", QVariant::fromValue<QString>(qSL("unquoted")) }, - { "string-singlequoted", QVariant::fromValue<QString>(qSL("singlequoted")) }, - { "string-doublequoted", QVariant::fromValue<QString>(qSL("doublequoted")) }, + { "string-unquoted", QVariant::fromValue<QString>(u"unquoted"_s) }, + { "string-singlequoted", QVariant::fromValue<QString>(u"singlequoted"_s) }, + { "string-doublequoted", QVariant::fromValue<QString>(u"doublequoted"_s) }, { "list-int", QVariantList { 1, 2, 3 } }, - { "list-mixed", QVariantList { 1, qSL("two"), QVariantList { true, vnull } } }, - { "map1", QVariantMap { { qSL("a"), 1 }, { qSL("b"), qSL("two") }, - { qSL("c"), QVariantList { 1, 2, 3 } } } } + { "list-mixed", QVariantList { 1, u"two"_s, QVariantList { true, vnull } } }, + { "map1", QVariantMap { { u"a"_s, 1 }, { u"b"_s, u"two"_s }, + { u"c"_s, QVariantList { 1, 2, 3 } } } } }; try { - QFile f(qSL(":/data/test.yaml")); + QFile f(u":/data/test.yaml"_s); QVERIFY2(f.open(QFile::ReadOnly), qPrintable(f.errorString())); QByteArray ba = f.readAll(); QVERIFY(!ba.isEmpty()); YamlParser p(ba); auto header = p.parseHeader(); - QCOMPARE(header.first, qSL("testfile")); + QCOMPARE(header.first, u"testfile"_s); QCOMPARE(header.second, 42); QVERIFY(p.nextDocument()); @@ -114,20 +116,20 @@ void tst_Yaml::parser() QVERIFY(p->isScalar()); QVariant v = p->parseScalar(); QCOMPARE(v.metaType(), QMetaType::fromType<QString>()); - QCOMPARE(v.toString(), qSL("ext string")); + QCOMPARE(v.toString(), u"ext string"_s); } } }; p->parseFields(extFields); }); fields.emplace_back("stringlist-string", true, YamlParser::Scalar | YamlParser::List, [](YamlParser *p) { - QCOMPARE(p->parseStringOrStringList(), QStringList { qSL("string") }); + QCOMPARE(p->parseStringOrStringList(), QStringList { u"string"_s }); }); fields.emplace_back("stringlist-list1", true, YamlParser::Scalar | YamlParser::List, [](YamlParser *p) { - QCOMPARE(p->parseStringOrStringList(), QStringList { qSL("string") }); + QCOMPARE(p->parseStringOrStringList(), QStringList { u"string"_s }); }); fields.emplace_back("stringlist-list2", true, YamlParser::Scalar | YamlParser::List, [](YamlParser *p) { - QCOMPARE(p->parseStringOrStringList(), QStringList({ qSL("string1"), qSL("string2") })); + QCOMPARE(p->parseStringOrStringList(), QStringList({ u"string1"_s, u"string2"_s })); }); fields.emplace_back("list-of-maps", true, YamlParser::List, [](YamlParser *p) { @@ -159,48 +161,48 @@ void tst_Yaml::parser() static const QVariant vnull = QVariant::fromValue(nullptr); static const QVariantMap testHeaderDoc = { - { qSL("formatVersion"), 42 }, { qSL("formatType"), qSL("testfile") } + { u"formatVersion"_s, 42 }, { u"formatType"_s, u"testfile"_s } }; static const QVariantMap testMainDoc = { - { qSL("dec"), 10 }, - { qSL("hex"), 16 }, - { qSL("bin"), 2 }, - { qSL("oct"), 8 }, - { qSL("float1"), 10.1 }, - { qSL("float2"), .1 }, - { qSL("float3"), .1 }, - { qSL("number-separators"), 1234567 }, - { qSL("bool-true"), true }, - { qSL("bool-yes"), true }, - { qSL("bool-false"), false }, - { qSL("bool-no"), false }, - { qSL("null-literal"), vnull }, - { qSL("null-tilde"), vnull }, - { qSL("null-empty"), vnull }, - { qSL("string-unquoted"), qSL("unquoted") }, - { qSL("string-singlequoted"), qSL("singlequoted") }, - { qSL("string-doublequoted"), qSL("doublequoted") }, - { qSL("list-int"), QVariantList { 1, 2, 3 } }, - { qSL("list-mixed"), QVariantList { 1, qSL("two"), QVariantList { true, vnull } } }, - { qSL("map1"), QVariantMap { { qSL("a"), 1 }, { qSL("b"), qSL("two") }, - { qSL("c"), QVariantList { 1, 2, 3 } } } }, - - - { qSL("extended"), QVariantMap { { qSL("ext-string"), qSL("ext string") } } }, - - { qSL("stringlist-string"), qSL("string") }, - { qSL("stringlist-list1"), QVariantList { qSL("string") } }, - { qSL("stringlist-list2"), QVariantList { qSL("string1"), qSL("string2") } }, - - { qSL("list-of-maps"), QVariantList { QVariantMap { { qSL("index"), 1 }, { qSL("name"), qSL("1") } }, - QVariantMap { { qSL("index"), 2 }, { qSL("name"), qSL("2") } } } } + { u"dec"_s, 10 }, + { u"hex"_s, 16 }, + { u"bin"_s, 2 }, + { u"oct"_s, 8 }, + { u"float1"_s, 10.1 }, + { u"float2"_s, .1 }, + { u"float3"_s, .1 }, + { u"number-separators"_s, 1234567 }, + { u"bool-true"_s, true }, + { u"bool-yes"_s, true }, + { u"bool-false"_s, false }, + { u"bool-no"_s, false }, + { u"null-literal"_s, vnull }, + { u"null-tilde"_s, vnull }, + { u"null-empty"_s, vnull }, + { u"string-unquoted"_s, u"unquoted"_s }, + { u"string-singlequoted"_s, u"singlequoted"_s }, + { u"string-doublequoted"_s, u"doublequoted"_s }, + { u"list-int"_s, QVariantList { 1, 2, 3 } }, + { u"list-mixed"_s, QVariantList { 1, u"two"_s, QVariantList { true, vnull } } }, + { u"map1"_s, QVariantMap { { u"a"_s, 1 }, { u"b"_s, u"two"_s }, + { u"c"_s, QVariantList { 1, 2, 3 } } } }, + + + { u"extended"_s, QVariantMap { { u"ext-string"_s, u"ext string"_s } } }, + + { u"stringlist-string"_s, u"string"_s }, + { u"stringlist-list1"_s, QVariantList { u"string"_s } }, + { u"stringlist-list2"_s, QVariantList { u"string1"_s, u"string2"_s } }, + + { u"list-of-maps"_s, QVariantList { QVariantMap { { u"index"_s, 1 }, { u"name"_s, u"1"_s } }, + QVariantMap { { u"index"_s, 2 }, { u"name"_s, u"2"_s } } } } }; void tst_Yaml::documentParser() { try { - QFile f(qSL(":/data/test.yaml")); + QFile f(u":/data/test.yaml"_s); QVERIFY2(f.open(QFile::ReadOnly), qPrintable(f.errorString())); QByteArray ba = f.readAll(); QVERIFY(!ba.isEmpty()); @@ -253,7 +255,7 @@ public: void merge(CacheTest *ct1, const CacheTest *ct2) { ct1->name = ct2->name; - ct1->file = ct1->file + qSL(",") + ct2->file; + ct1->file = ct1->file + u","_s + ct2->file; ct1->value.append(ct2->value); } void preProcessSourceContent(QByteArray &sourceContent, const QString &fileName) @@ -264,11 +266,11 @@ public: void tst_Yaml::cache() { - QStringList files = { qSL(":/data/cache1.yaml"), qSL(":/data/cache2.yaml") }; + QStringList files = { u":/data/cache1.yaml"_s, u":/data/cache2.yaml"_s }; for (int step = 0; step < 2; ++step) { try { - ConfigCache<CacheTest> cache(files, qSL("cache-test"), { 'C','T','S','T' }, 1, + ConfigCache<CacheTest> cache(files, u"cache-test"_s, { 'C','T','S','T' }, 1, step == 0 ? AbstractConfigCache::ClearCache : AbstractConfigCache::None); cache.parse(); @@ -276,12 +278,12 @@ void tst_Yaml::cache() QVERIFY(cache.parseWroteToCache() == (step == 0)); CacheTest *ct1 = cache.takeResult(0); QVERIFY(ct1); - QCOMPARE(ct1->name, qSL("cache1")); - QCOMPARE(ct1->file, qSL(":/data/cache1.yaml")); + QCOMPARE(ct1->name, u"cache1"_s); + QCOMPARE(ct1->file, u":/data/cache1.yaml"_s); CacheTest *ct2 = cache.takeResult(1); QVERIFY(ct2); - QCOMPARE(ct2->name, qSL("cache2")); - QCOMPARE(ct2->file, qSL(":/data/cache2.yaml")); + QCOMPARE(ct2->name, u"cache2"_s); + QCOMPARE(ct2->file, u":/data/cache2.yaml"_s); delete ct1; delete ct2; @@ -290,41 +292,41 @@ void tst_Yaml::cache() } } - ConfigCache<CacheTest> wrongVersion(files, qSL("cache-test"), { 'C','T','S','T' }, 2, + ConfigCache<CacheTest> wrongVersion(files, u"cache-test"_s, { 'C','T','S','T' }, 2, AbstractConfigCache::None); QTest::ignoreMessage(QtWarningMsg, "Failed to read cache: failed to parse cache header"); wrongVersion.parse(); QVERIFY(!wrongVersion.parseReadFromCache()); - ConfigCache<CacheTest> wrongType(files, qSL("cache-test"), { 'X','T','S','T' }, 1, + ConfigCache<CacheTest> wrongType(files, u"cache-test"_s, { 'X','T','S','T' }, 1, AbstractConfigCache::None); QTest::ignoreMessage(QtWarningMsg, "Failed to read cache: failed to parse cache header"); wrongType.parse(); QVERIFY(!wrongType.parseReadFromCache()); - ConfigCache<CacheTest> duplicateCache({ qSL(":/cache1.yaml"), qSL(":/cache1.yaml") }, - qSL("cache-test"), { 'D','T','S','T' }, 1, + ConfigCache<CacheTest> duplicateCache({ u":/cache1.yaml"_s, u":/cache1.yaml"_s }, + u"cache-test"_s, { 'D','T','S','T' }, 1, AbstractConfigCache::None); try { duplicateCache.parse(); QVERIFY(false); } catch (const Exception &e) { - QVERIFY(e.errorString().contains(qSL("duplicate"))); + QVERIFY(e.errorString().contains(u"duplicate"_s)); } } void tst_Yaml::mergedCache() { // we need cache2 modifieable, so we copy it to a temp file - QTemporaryFile cache2File(qSL("cache2")); + QTemporaryFile cache2File(u"cache2"_s); QVERIFY(cache2File.open()); - QFile cache2Resource(qSL(":/data/cache2.yaml")); + QFile cache2Resource(u":/data/cache2.yaml"_s); QVERIFY(cache2Resource.open(QIODevice::ReadOnly)); QVERIFY(cache2File.write(cache2Resource.readAll()) > 0); QVERIFY(cache2File.flush()); const QString cache2FileName = QFileInfo(cache2File).absoluteFilePath(); - QStringList files = { qSL(":/data/cache1.yaml"), cache2FileName }; + QStringList files = { u":/data/cache1.yaml"_s, cache2FileName }; for (int step = 0; step < 4; ++step) { AbstractConfigCache::Options options = AbstractConfigCache::MergedResult; @@ -334,14 +336,14 @@ void tst_Yaml::mergedCache() std::reverse(files.begin(), files.end()); try { - ConfigCache<CacheTest> cache(files, qSL("cache-test"), { 'M','T','S','T' }, 1, options); + ConfigCache<CacheTest> cache(files, u"cache-test"_s, { 'M','T','S','T' }, 1, options); cache.parse(); QVERIFY(cache.parseReadFromCache() == (step % 2 == 1)); QVERIFY(cache.parseWroteToCache() == (step % 2 == 0)); CacheTest *ct = cache.takeMergedResult(); QVERIFY(ct); QCOMPARE(ct->name, QFileInfo(files.last()).baseName()); - QCOMPARE(ct->file, files.join(qSL(","))); + QCOMPARE(ct->file, files.join(u","_s)); delete ct; } catch (const Exception &e) { @@ -361,13 +363,13 @@ void tst_Yaml::mergedCache() QCOMPARE(cache2File.write(ba2), ba2.size()); QVERIFY(cache2File.flush()); - ConfigCache<CacheTest> brokenCache(files, qSL("cache-test"), { 'M','T','S','T' }, 1, + ConfigCache<CacheTest> brokenCache(files, u"cache-test"_s, { 'M','T','S','T' }, 1, AbstractConfigCache::MergedResult); QTest::ignoreMessage(QtWarningMsg, "Failed to read Cache: cached file checksums do not match"); brokenCache.parse(); QVERIFY(brokenCache.parseReadFromCache()); CacheTest *ct = brokenCache.takeMergedResult(); - QCOMPARE(ct->value, qSL("foobar")); + QCOMPARE(ct->value, u"foobar"_s); delete ct; } @@ -405,7 +407,7 @@ private: void tst_Yaml::parallel() { - QFile f(qSL(":/data/test.yaml")); + QFile f(u":/data/test.yaml"_s); QVERIFY2(f.open(QFile::ReadOnly), qPrintable(f.errorString())); QByteArray ba = f.readAll(); QVERIFY(!ba.isEmpty()); |