mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +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 <KSharedConfig>
|
||||
|
||||
// .config/applications-blacklistrc
|
||||
// .config/plasma-mobile/applications-blacklistrc
|
||||
// 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 = {
|
||||
{"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_KSMSERVERRC_FILE = u"plasma-mobile/ksmserverrc"_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)
|
||||
: QObject{parent}
|
||||
, m_isMobilePlatform{KRuntimePlatform::runtimePlatform().contains(u"phone"_s)}
|
||||
, 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) {
|
||||
qCDebug(LOGGING_CATEGORY) << "Configuration will not be applied, as the session is not Plasma Mobile.";
|
||||
qCDebug(LOGGING_CATEGORY) << "Restoring any previously saved configuration...";
|
||||
loadSavedConfiguration();
|
||||
return;
|
||||
}
|
||||
|
|
@ -58,10 +57,6 @@ void Settings::loadSavedConfiguration()
|
|||
originalKwinrcConfig->sync();
|
||||
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)
|
||||
auto originalKdeglobalsConfig = KSharedConfig::openConfig(u"kdeglobals"_s, KConfig::SimpleConfig);
|
||||
loadKeys(u"kdeglobals"_s, originalKdeglobalsConfig, KDEGLOBALS_SETTINGS);
|
||||
|
|
@ -89,11 +84,10 @@ void Settings::applyMobileConfiguration()
|
|||
|
||||
// applications-blacklistrc
|
||||
{
|
||||
writeKeysAndSave(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();
|
||||
// We don't set these options as immutable
|
||||
auto appBlacklistConfig = KSharedConfig::openConfig(MOBILE_APPLICATIONS_BLACKLIST_FILE, KConfig::SimpleConfig);
|
||||
writeKeys(MOBILE_APPLICATIONS_BLACKLIST_FILE, appBlacklistConfig, APPLICATIONS_BLACKLIST_DEFAULT_SETTINGS);
|
||||
appBlacklistConfig->sync();
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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
|
||||
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 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);
|
||||
|
|
@ -43,10 +41,6 @@ private:
|
|||
bool m_isMobilePlatform;
|
||||
|
||||
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
|
||||
KSharedConfig::Ptr m_originalKdeglobalsConfig; // (~/.config/kdeglobals)
|
||||
|
|
|
|||
Loading…
Reference in a new issue