From d161292426007744e773d3c8870f9f2f3eb958bd Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Wed, 17 Jan 2024 01:07:31 +0100 Subject: [PATCH] Use new Qt6 QStringLiteral operator Shorter than typing QStringLiteral all the time --- envmanager/main.cpp | 10 ++++++---- envmanager/settings.cpp | 34 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/envmanager/main.cpp b/envmanager/main.cpp index 56eb0a19..951cd158 100644 --- a/envmanager/main.cpp +++ b/envmanager/main.cpp @@ -14,10 +14,12 @@ #include "settings.h" #include "version.h" +using namespace Qt::Literals::StringLiterals; + QCommandLineParser *createParser() { QCommandLineParser *parser = new QCommandLineParser; - parser->addOption(QCommandLineOption(QStringLiteral("apply-settings"), "Applies the correct system settings for the current environment.")); + parser->addOption(QCommandLineOption(u"apply-settings"_s, u"Applies the correct system settings for the current environment."_s)); parser->addVersionOption(); parser->addHelpOption(); return parser; @@ -33,12 +35,12 @@ int main(int argc, char *argv[]) // start wizard KLocalizedString::setApplicationDomain("plasma-mobile-envmanager"); - QCoreApplication::setApplicationName(QStringLiteral("plasma-mobile-envmanager")); + QCoreApplication::setApplicationName(u"plasma-mobile-envmanager"_s); QCoreApplication::setApplicationVersion(QStringLiteral(PLASMA_MOBILE_VERSION_STRING)); - QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); + QCoreApplication::setOrganizationDomain(u"kde.org"_s); // apply configuration - if (parser->isSet(QStringLiteral("apply-settings"))) { + if (parser->isSet(u"apply-settings"_s)) { Settings::self().applyConfiguration(); } else { parser->showHelp(); diff --git a/envmanager/settings.cpp b/envmanager/settings.cpp index 42330917..0e4aecb2 100644 --- a/envmanager/settings.cpp +++ b/envmanager/settings.cpp @@ -13,16 +13,18 @@ #include #include -const QString CONFIG_FILE = QStringLiteral("plasmamobilerc"); -const QString SAVED_CONFIG_GROUP = QStringLiteral("SavedConfig"); +using namespace Qt::Literals::StringLiterals; + +const QString CONFIG_FILE = u"plasmamobilerc"_s; +const QString SAVED_CONFIG_GROUP = u"SavedConfig"_s; Settings::Settings(QObject *parent) : QObject{parent} - , m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(QStringLiteral("phone"))} + , m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(u"phone"_s)} , m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)} - , m_kwinrcConfig{KSharedConfig::openConfig(QStringLiteral("kwinrc"), KConfig::SimpleConfig)} - , m_appBlacklistConfig{KSharedConfig::openConfig(QStringLiteral("applications-blacklistrc"), KConfig::SimpleConfig)} - , m_kdeglobalsConfig{KSharedConfig::openConfig(QStringLiteral("kdeglobals"), KConfig::SimpleConfig)} + , m_kwinrcConfig{KSharedConfig::openConfig(u"kwinrc"_s, KConfig::SimpleConfig)} + , m_appBlacklistConfig{KSharedConfig::openConfig(u"applications-blacklistrc"_s, KConfig::SimpleConfig)} + , m_kdeglobalsConfig{KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig)} , m_configWatcher{KConfigWatcher::create(m_mobileConfig)} { } @@ -49,17 +51,17 @@ void Settings::applyConfiguration() void Settings::loadSavedConfiguration() { // kwinrc - loadKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, getKwinrcSettings(m_mobileConfig)); + loadKeys(u"kwinrc"_s, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig)); m_kwinrcConfig->sync(); reloadKWinConfig(); // applications-blacklistrc - loadKeys(QStringLiteral("applications-blacklistrc"), m_appBlacklistConfig, APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS); + loadKeys(u"applications-blacklistrc"_s, m_appBlacklistConfig, APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS); m_appBlacklistConfig->sync(); // kdeglobals - loadKeys(QStringLiteral("kdeglobals"), m_kdeglobalsConfig, KDEGLOBALS_DEFAULT_SETTINGS); - loadKeys(QStringLiteral("kdeglobals"), m_kdeglobalsConfig, KDEGLOBALS_SETTINGS); + loadKeys(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_DEFAULT_SETTINGS); + loadKeys(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_SETTINGS); m_kdeglobalsConfig->sync(); // save our changes @@ -69,23 +71,21 @@ void Settings::loadSavedConfiguration() void Settings::applyMobileConfiguration() { // kwinrc - writeKeys(QStringLiteral("kwinrc"), m_kwinrcConfig, getKwinrcSettings(m_mobileConfig), false); + writeKeys(u"kwinrc"_s, m_kwinrcConfig, getKwinrcSettings(m_mobileConfig), false); m_kwinrcConfig->sync(); reloadKWinConfig(); // applications-blacklistrc - writeKeys(QStringLiteral("applications-blacklistrc"), + writeKeys(u"applications-blacklistrc"_s, m_appBlacklistConfig, APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS, true); // only write entries if they are not already defined in the config m_appBlacklistConfig->sync(); // kdeglobals - writeKeys(QStringLiteral("kdeglobals"), - m_kdeglobalsConfig, - KDEGLOBALS_DEFAULT_SETTINGS, + writeKeys(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_DEFAULT_SETTINGS, true); // only write entries if they are not already defined in the config - writeKeys(QStringLiteral("kdeglobals"), m_kdeglobalsConfig, KDEGLOBALS_SETTINGS, false); + writeKeys(u"kdeglobals"_s, m_kdeglobalsConfig, KDEGLOBALS_SETTINGS, false); m_kdeglobalsConfig->sync(); // save our changes @@ -166,6 +166,6 @@ const QString Settings::loadSavedConfigSetting(KSharedConfig::Ptr &config, const void Settings::reloadKWinConfig() { - QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")); + QDBusMessage message = QDBusMessage::createSignal(u"/KWin"_s, u"org.kde.KWin"_s, u"reloadConfig"_s); QDBusConnection::sessionBus().send(message); }