KConfig
9 #include "ksharedconfig.h"
10 #include "kconfig_p.h"
11 #include "kconfigbackend_p.h"
12 #include "kconfiggroup.h"
13 #include <QCoreApplication>
15 #include <QThreadStorage>
17 void _k_globalMainConfigSync();
21 class GlobalSharedConfig
25 : wasTestModeEnabled(false)
32 qAddPostRoutine(&_k_globalMainConfigSync);
42 bool wasTestModeEnabled;
47 T *perThreadGlobalStatic()
49 if (!s_storage.hasLocalData()) {
50 s_storage.setLocalData(
new T);
52 return s_storage.localData();
56 static GlobalSharedConfig *globalSharedConfig()
58 return perThreadGlobalStatic<GlobalSharedConfig>();
61 void _k_globalMainConfigSync()
72 GlobalSharedConfig *global = globalSharedConfig();
78 if (!global->wasTestModeEnabled && QStandardPaths::isTestModeEnabled()) {
79 global->wasTestModeEnabled =
true;
80 global->configList.clear();
81 global->mainConfig =
nullptr;
84 for (
auto *cfg : std::as_const(global->configList)) {
85 if (cfg->name() == fileName && cfg->d_ptr->openFlags == flags && cfg->locationType() == resType
95 global->mainConfig = ptr;
98 static bool userWarned =
false;
99 if (isMainThread && !userWarned) {
101 const bool isReadOnly = qEnvironmentVariableIsEmpty(
"KDE_HOME_READONLY");
103 if (ptr->group(
"General").readEntry(QStringLiteral(
"warn_unwritable_config"),
true)) {
104 ptr->isConfigWritable(
true);
127 :
KConfig(fileName, flags, resType)
129 globalSharedConfig()->configList.append(
this);
132 KSharedConfig::~KSharedConfig()
134 if (s_storage.hasLocalData()) {
135 globalSharedConfig()->configList.removeAll(
this);
bool testFlag(Enum flag) const const
The central class of the KDE configuration data system.
QThread * thread() const const
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
Creates a KSharedConfig object to manipulate a configuration file.
@ FullConfig
Fully-fledged config, including globals and cascading to system settings.
bool isEmpty() const const
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
Creates a KSharedConfig object to manipulate a configuration file suitable for storing state informat...
QThread * currentThread()
const char * constData() const const
static QString mainConfigName()
Get the name of application config file.
@ SimpleConfig
Just a single config file.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Dec 2 2023 04:11:08 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.