Settings manager.
More...
#include <SettingManager.h>
Inherits QObject, ReadWriteLockable, and Dependency.
|
QString | fileName () const |
| Returns the filename where the config file will be written. More...
|
|
void | remove (const QString &key) |
| Remove a configuration key. More...
|
|
QStringList | allKeys () const |
| Lists all keys in the configuration. More...
|
|
bool | contains (const QString &key) const |
| Returns whether a key is part of the configuration. More...
|
|
void | setValue (const QString &key, const QVariant &value) |
| Set a setting to a value. More...
|
|
QVariant | value (const QString &key, const QVariant &defaultValue=QVariant()) const |
| Returns the value of a setting. More...
|
|
void | clearAllSettings () |
| Clear all the settings. More...
|
|
Settings manager.
This class is the main implementation of the settings system, and the container of the current configuration.
Most users should either use the Setting::Handle or the Settings classes instead, both of which talk to the single global instance of this class.
The class is thread-safe, and delegates config writing to a separate thread. It is safe to change settings as often as it might be needed.
◆ allKeys()
QStringList Setting::Manager::allKeys |
( |
| ) |
const |
Lists all keys in the configuration.
- Returns
- QStringList List of keys
◆ clearAllSettings()
void Setting::Manager::clearAllSettings |
( |
| ) |
|
Clear all the settings.
Removes the entire configuration, resetting everything to "factory default"
◆ contains()
bool Setting::Manager::contains |
( |
const QString & |
key | ) |
const |
Returns whether a key is part of the configuration.
- Parameters
-
- Returns
- true Key is in the configuration
-
false Key isn't in the configuration
◆ fileName()
QString Setting::Manager::fileName |
( |
| ) |
const |
Returns the filename where the config file will be written.
- Returns
- QString Path to the config file
◆ forceSave()
void Setting::Manager::forceSave |
( |
| ) |
|
|
protected |
Force saving the config to disk.
Normally unnecessary to use. Asynchronous.
◆ keyRemoved
void Setting::Manager::keyRemoved |
( |
const QString |
key | ) |
|
|
signal |
A setting was removed.
- Parameters
-
◆ remove()
void Setting::Manager::remove |
( |
const QString & |
key | ) |
|
Remove a configuration key.
- Parameters
-
◆ setValue()
void Setting::Manager::setValue |
( |
const QString & |
key, |
|
|
const QVariant & |
value |
|
) |
| |
Set a setting to a value.
- Parameters
-
key | Setting to set |
value | Value |
◆ terminateThread()
void Setting::Manager::terminateThread |
( |
| ) |
|
|
protected |
Write config to disk and terminate the writer thread.
This is part of the shutdown process.
◆ terminationRequested
void Setting::Manager::terminationRequested |
( |
| ) |
|
|
signal |
The termination of the settings system was requested.
This happens on shutdown. All pending changes should be serialized to disk.
◆ value()
QVariant Setting::Manager::value |
( |
const QString & |
key, |
|
|
const QVariant & |
defaultValue = QVariant() |
|
) |
| const |
Returns the value of a setting.
- Parameters
-
key | Setting to look for |
defaultValue | Default value to return, if the setting has no value |
- Returns
- QVariant Current value of the setting, of defaultValue.
◆ valueChanged
void Setting::Manager::valueChanged |
( |
const QString |
key, |
|
|
QVariant |
value |
|
) |
| |
|
signal |
The value of a setting was changed.
- Parameters
-
key | Setting key |
value | New value |
◆ THREAD_TERMINATION_TIMEOUT
const int Setting::Manager::THREAD_TERMINATION_TIMEOUT = 2000 |
|
protected |
How long to wait for writer thread termination.
We probably want a timeout here since we don't want to block shutdown indefinitely in case of any weirdness.
The documentation for this class was generated from the following files: