Overte C++ Documentation
Setting::Manager Class Reference

Settings manager. More...

#include <SettingManager.h>

Inherits QObject, ReadWriteLockable, and Dependency.

Signals

void valueChanged (const QString key, QVariant value)
 The value of a setting was changed. More...
 
void keyRemoved (const QString key)
 A setting was removed. More...
 
void syncRequested ()
 A request to synchronize the settings to permanent storage was made.
 
void clearAllSettingsRequested ()
 A request to clear all the settings was made.
 
void terminationRequested ()
 The termination of the settings system was requested. More...
 

Public Member Functions

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...
 

Protected Member Functions

void forceSave ()
 Force saving the config to disk. More...
 
void terminateThread ()
 Write config to disk and terminate the writer thread. More...
 

Protected Attributes

const int THREAD_TERMINATION_TIMEOUT = 2000
 How long to wait for writer thread termination. More...
 

Detailed Description

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.

Member Function Documentation

◆ 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
keyKey to look for
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
keySetting key

◆ remove()

void Setting::Manager::remove ( const QString &  key)

Remove a configuration key.

Parameters
keyKey to remove

◆ setValue()

void Setting::Manager::setValue ( const QString &  key,
const QVariant &  value 
)

Set a setting to a value.

Parameters
keySetting to set
valueValue

◆ 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
keySetting to look for
defaultValueDefault 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
keySetting key
valueNew value

Member Data Documentation

◆ 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: