mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 07:03:08 +00:00
envmanager: Use config overlay for applications-blacklistrc
Use a config overlay for applications-blacklistrc, so that new options that we add are updated in installs. This brings it inline with all of the other config files we manage, and so I also remove unused functionality that we used in the past to "save" and restore config files.
This commit is contained in:
parent
40dac12ade
commit
09715da168
3 changed files with 6 additions and 40 deletions
|
|
@ -13,7 +13,7 @@
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
|
|
||||||
// .config/applications-blacklistrc
|
// .config/plasma-mobile/applications-blacklistrc
|
||||||
// NOTE: we only write these entries if they are not already defined in the config
|
// NOTE: we only write these entries if they are not already defined in the config
|
||||||
const QMap<QString, QMap<QString, QVariant>> APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS = {
|
const QMap<QString, QMap<QString, QVariant>> APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS = {
|
||||||
{"Applications",
|
{"Applications",
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ const QString SAVED_CONFIG_GROUP = u"SavedConfig"_s;
|
||||||
const QString MOBILE_KWINRC_FILE = u"plasma-mobile/kwinrc"_s;
|
const QString MOBILE_KWINRC_FILE = u"plasma-mobile/kwinrc"_s;
|
||||||
const QString MOBILE_KSMSERVERRC_FILE = u"plasma-mobile/ksmserverrc"_s;
|
const QString MOBILE_KSMSERVERRC_FILE = u"plasma-mobile/ksmserverrc"_s;
|
||||||
const QString MOBILE_KDEGLOBALS_FILE = u"plasma-mobile/kdeglobals"_s;
|
const QString MOBILE_KDEGLOBALS_FILE = u"plasma-mobile/kdeglobals"_s;
|
||||||
|
const QString MOBILE_APPLICATIONS_BLACKLIST_FILE = u"plasma-mobile/applications-blacklistrc"_s;
|
||||||
|
|
||||||
Settings::Settings(QObject *parent)
|
Settings::Settings(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(u"phone"_s)}
|
, m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(u"phone"_s)}
|
||||||
, m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)}
|
, m_mobileConfig{KSharedConfig::openConfig(CONFIG_FILE, KConfig::SimpleConfig)}
|
||||||
, m_appBlacklistConfig{KSharedConfig::openConfig(u"applications-blacklistrc"_s, KConfig::SimpleConfig)}
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +41,6 @@ void Settings::applyConfiguration()
|
||||||
{
|
{
|
||||||
if (!m_isMobilePlatform) {
|
if (!m_isMobilePlatform) {
|
||||||
qCDebug(LOGGING_CATEGORY) << "Configuration will not be applied, as the session is not Plasma Mobile.";
|
qCDebug(LOGGING_CATEGORY) << "Configuration will not be applied, as the session is not Plasma Mobile.";
|
||||||
qCDebug(LOGGING_CATEGORY) << "Restoring any previously saved configuration...";
|
|
||||||
loadSavedConfiguration();
|
loadSavedConfiguration();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -58,10 +57,6 @@ void Settings::loadSavedConfiguration()
|
||||||
originalKwinrcConfig->sync();
|
originalKwinrcConfig->sync();
|
||||||
reloadKWinConfig();
|
reloadKWinConfig();
|
||||||
|
|
||||||
// applications-blacklistrc
|
|
||||||
loadKeys(u"applications-blacklistrc"_s, m_appBlacklistConfig, APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS);
|
|
||||||
m_appBlacklistConfig->sync();
|
|
||||||
|
|
||||||
// kdeglobals (legacy, we only write in the plasma-mobile/kdeglobals file now)
|
// kdeglobals (legacy, we only write in the plasma-mobile/kdeglobals file now)
|
||||||
auto originalKdeglobalsConfig = KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig);
|
auto originalKdeglobalsConfig = KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig);
|
||||||
loadKeys(u"kdeglobals"_s, originalKdeglobalsConfig, KDEGLOBALS_SETTINGS);
|
loadKeys(u"kdeglobals"_s, originalKdeglobalsConfig, KDEGLOBALS_SETTINGS);
|
||||||
|
|
@ -89,11 +84,10 @@ void Settings::applyMobileConfiguration()
|
||||||
|
|
||||||
// applications-blacklistrc
|
// applications-blacklistrc
|
||||||
{
|
{
|
||||||
writeKeysAndSave(u"applications-blacklistrc"_s,
|
// We don't set these options as immutable
|
||||||
m_appBlacklistConfig,
|
auto appBlacklistConfig = KSharedConfig::openConfig(MOBILE_APPLICATIONS_BLACKLIST_FILE, KConfig::SimpleConfig);
|
||||||
APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS,
|
writeKeys(MOBILE_APPLICATIONS_BLACKLIST_FILE, appBlacklistConfig, APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS);
|
||||||
true); // only write entries if they are not already defined in the config
|
appBlacklistConfig->sync();
|
||||||
m_appBlacklistConfig->sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// kdeglobals
|
// kdeglobals
|
||||||
|
|
@ -136,28 +130,6 @@ void Settings::writeKeys(const QString &fileName, KSharedConfig::Ptr &config, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::writeKeysAndSave(const QString &fileName,
|
|
||||||
KSharedConfig::Ptr &config,
|
|
||||||
const QMap<QString, QMap<QString, QVariant>> &settings,
|
|
||||||
bool overwriteOnlyIfEmpty)
|
|
||||||
{
|
|
||||||
const auto groupNames = settings.keys();
|
|
||||||
for (const auto &groupName : groupNames) {
|
|
||||||
auto group = KConfigGroup{config, groupName};
|
|
||||||
|
|
||||||
const auto keys = settings[groupName].keys();
|
|
||||||
for (const auto &key : keys) {
|
|
||||||
if (!group.hasKey(key) || !overwriteOnlyIfEmpty) {
|
|
||||||
// save key
|
|
||||||
saveConfigSetting(fileName, groupName, key, group.readEntry(key));
|
|
||||||
|
|
||||||
// overwrite with mobile setting
|
|
||||||
group.writeEntry(key, settings[groupName][key], KConfigGroup::Notify);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings)
|
void Settings::loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings)
|
||||||
{
|
{
|
||||||
const auto groupNames = settings.keys();
|
const auto groupNames = settings.keys();
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ private:
|
||||||
|
|
||||||
void writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
void writeKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
||||||
|
|
||||||
void
|
|
||||||
writeKeysAndSave(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings, bool overwriteOnlyIfEmpty);
|
|
||||||
void loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
void loadKeys(const QString &fileName, KSharedConfig::Ptr &config, const QMap<QString, QMap<QString, QVariant>> &settings);
|
||||||
void saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value);
|
void saveConfigSetting(const QString &fileName, const QString &group, const QString &key, const QVariant value);
|
||||||
const QString loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write = true);
|
const QString loadSavedConfigSetting(KSharedConfig::Ptr &config, const QString &fileName, const QString &group, const QString &key, bool write = true);
|
||||||
|
|
@ -43,10 +41,6 @@ private:
|
||||||
bool m_isMobilePlatform;
|
bool m_isMobilePlatform;
|
||||||
|
|
||||||
KSharedConfig::Ptr m_mobileConfig;
|
KSharedConfig::Ptr m_mobileConfig;
|
||||||
KSharedConfig::Ptr m_kwinrcConfig; // (~/.config/plasma-mobile/kwinrc)
|
|
||||||
KSharedConfig::Ptr m_appBlacklistConfig;
|
|
||||||
KSharedConfig::Ptr m_kdeglobalsConfig; // (~/.config/plasma-mobile/kdeglobals)
|
|
||||||
KSharedConfig::Ptr m_ksmServerConfig; // (~/.config/plamsma-mobile/ksmserverrc)
|
|
||||||
|
|
||||||
// For legacy upgrade purposes
|
// For legacy upgrade purposes
|
||||||
KSharedConfig::Ptr m_originalKdeglobalsConfig; // (~/.config/kdeglobals)
|
KSharedConfig::Ptr m_originalKdeglobalsConfig; // (~/.config/kdeglobals)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue