Utility class for plugins to access their configuration space in KLFConfig. More...
#include <klfconfig.h>
Public Member Functions | |
KLFPluginConfigAccess () | |
KLFPluginConfigAccess (KLFConfig *configObject, const QString &pluginName) | |
KLFPluginConfigAccess (const KLFPluginConfigAccess &other) | |
virtual | ~KLFPluginConfigAccess () |
virtual QString | homeConfigDir () const |
virtual QString | globalShareDir () const |
virtual QString | tempDir () const |
virtual QString | homeConfigPluginDataDir (bool createIfNeeded=true) const |
virtual QVariant | readValue (const QString &key) const |
read a value in the config More... | |
virtual QVariant | makeDefaultValue (const QString &key, const QVariant &defaultValue) |
write the value if inexistant in config More... | |
virtual void | writeValue (const QString &key, const QVariant &value) |
write a value to settings More... | |
Utility class for plugins to access their configuration space in KLFConfig.
KLatexFormula stores its configuration via KLFConfig and the global klfconfig
object. That structure relies on the config structure being known in advance and the named fields to appear publicly in the KLFConfig class. This scheme is obviously NOT possible for plugins, so a different approach is taken.
Plugins are given a pointer to a KLFPluginConfigAccess
object, which is an interface to access a special part of KLFConfig that stores plugin-related configuration in the form of QVariantMaps. (themselves written in an INI-based config file inside the plugin's local directory, at ~/.klatexformula/plugindata/<plugin>/<plugin>.conf
)
KLFConfig transparently takes care of reading the config for plugins at the beginning when launching KLatexFormula and storing the plugin configurations in their respective locations when quitting.
Plugins can read values they have set in earlier sessions with readValue(). Default values can be defined with makeDefaultValue().
Plugins can write changed settings with writeValue().
Definition at line 61 of file klfconfig.h.
KLFPluginConfigAccess::KLFPluginConfigAccess | ( | ) |
Definition at line 724 of file klfconfig.cpp.
KLFPluginConfigAccess::KLFPluginConfigAccess | ( | KLFConfig * | configObject, |
const QString & | pluginName | ||
) |
Definition at line 741 of file klfconfig.cpp.
References KLFConfig::homeConfigDir, and klfDbg.
KLFPluginConfigAccess::KLFPluginConfigAccess | ( | const KLFPluginConfigAccess & | other | ) |
Definition at line 729 of file klfconfig.cpp.
References KLFConfig::homeConfigDir, and klfDbg.
|
virtual |
Definition at line 737 of file klfconfig.cpp.
|
virtual |
Returns the directory (not necessarily existing) in which installed data that is shared among different users is stored. eg. system-wide installations of plugins/extensions can be placed in: share-dir/rccresources/*.rcc
.
Definition at line 764 of file klfconfig.cpp.
References KLFConfig::globalShareDir.
|
virtual |
Returns the root directory in which KLatexFormula stores its stuff, usually ~/.klatexformula
.
Definition at line 754 of file klfconfig.cpp.
References KLFConfig::homeConfigDir, and klfDbg.
|
virtual |
Returns a path to a directory in which plugins can manage their data as they want.
If the createIfNeeded
argument is TRUE, then the directory is garanteed to exist, and an empty string is returned if, for whatever reason, the directory can't be created.
If the createIfNeeded
argument is FALSE, then the directory path is returned regardless of whether the directory exists or not.
Note that a file named pluginName.conf
is created to store the plugin's settings in that directory (the settings are stored automatically).
Definition at line 784 of file klfconfig.cpp.
References KLFConfig::homeConfigDirPluginData, klfDbg, and klfEnsureDir().
|
virtual |
write the value if inexistant in config
equivalent to
defaultValue
if no existing value was found, or the existing value if one already exists. A null QVariant is returned upon error. Definition at line 814 of file klfconfig.cpp.
References QMap::contains(), KLFConfig::pluginConfig, and KLFConfig::Plugins.
read a value in the config
Returns the value of the entry with key key
. If no such entry exists, it is not created and an invalid QVariant() is returned.
Definition at line 801 of file klfconfig.cpp.
References QMap::contains(), KLFConfig::pluginConfig, and KLFConfig::Plugins.
|
virtual |
Returns a directory in which we can read/write temporary files, eg. "/tmp".
This is actually the value of klfconfig.BackendSettings.tempDir
Definition at line 774 of file klfconfig.cpp.
References KLFConfig::BackendSettings, and KLFConfig::tempDir.
write a value to settings
Saves the value of a setting, referenced by key
, to the given value
.
If key
hasn't been previously set, creates an entry for key
with the given value
.
Definition at line 827 of file klfconfig.cpp.
References KLFConfig::pluginConfig, and KLFConfig::Plugins.