|
mkRPG
|
The Options class provides session-independant options and preferences. More...
#include <options.h>
Public Member Functions | |
| template<class T > | |
| T | load (QString group, QString opt) |
| template<class T > | |
| void | save (QString group, QString opt, T val) |
| template<class T > | |
| void | setDefault (QString group, QString opt, T val) |
| bool | isAdjustable (QString group, QString opt, bool adjust=true) |
| void | setAdjustable (QString group, QString opt, bool adjust) |
| void | reinitialise (QString group="") |
Static Public Member Functions | |
| static Options & | options () |
The Options class provides session-independant options and preferences.
## Features
The Options class aims at storing global options, that are available at any place in the entire application. The preferences are permanantly stored and remain bewteen the separate sessions and windows.
Two sorts of options exist :
The sort of option can be set with the setAdjustable function.
## Design
The Options class is designed following the __Singleton design pattern__. The constructor is thus private, and the only Options instance is created at the first call of options.
QSetting is used internaly, see Qt's documentation for details about the storing mechanisms.
## Reading and writting existing options
To read or write options, the Options instance must be retreived, using the options function, then the load and save functions can be called.
## Adding options
To add a new option, it is only needed to add a default hard coded value, uisng the Default and DefaultF macros in the Options constructor.
It is strongly advice to use macro to define new options group (see WIN, for an example).
| bool Options::isAdjustable | ( | QString | group, |
| QString | opt, | ||
| bool | adjust = true |
||
| ) |
Returns ```true``` if the option defined by its group and name is adjustable, ```false``` elsewhere.
| T Options::load | ( | QString | group, |
| QString | opt | ||
| ) | [inline] |
Reads an option defined by its group and name.
| Options & Options::options | ( | ) | [static] |
Returns the unique Options instance.
| void Options::reinitialise | ( | QString | group = "" | ) |
Clear all options from the group. If ```group == ""```, all entries are deleted.
| void Options::save | ( | QString | group, |
| QString | opt, | ||
| T | val | ||
| ) | [inline] |
Writes the new value of the options defined by its group and name, if the option is adjustable. See Options for details about options types.
| void Options::setAdjustable | ( | QString | group, |
| QString | opt, | ||
| bool | adjust | ||
| ) |
Sets if the option defined by its group and name is adjustable.
| void Options::setDefault | ( | QString | group, |
| QString | opt, | ||
| T | val | ||
| ) | [inline] |
1.7.6.1