mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 06:13:09 +00:00
Use new Qt6 QStringLiteral operator
Shorter than typing QStringLiteral all the time
This commit is contained in:
parent
b070f6e3f7
commit
d161292426
2 changed files with 23 additions and 21 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -13,16 +13,18 @@
|
|||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue