QSettingsDialog
1.0.0
A Qt library to easily create a settings dialog for user configurable settings
|
A loader to load data from QSettings. More...
#include <qsettingssettingsloader.h>
Public Member Functions | |
QSettingsSettingsLoader (const QString &key) | |
Creates a loader for a key in the default QSettings. | |
QSettingsSettingsLoader (QSettings *settings, const QString &key, bool ownSettings=false) | |
Creates a loader for a key in given QSettings. More... | |
~QSettingsSettingsLoader () | |
Destructor. | |
bool | load (QVariant outParam data, bool outParam userEdited) override |
Will be called if settings need to be loaded form this loader. More... | |
bool | save (const QVariant &data) override |
Will be called to save settings from the dialog to this loader. More... | |
bool | reset () override |
Will be called to reset the data this loader manages. More... | |
Public Member Functions inherited from QSimpleSettingsLoader | |
bool | isAsync () const final |
Specifies, whether this loader is async or not. | |
Public Member Functions inherited from QSettingsLoader | |
virtual | ~QSettingsLoader () |
Virtual destructor. | |
QSimpleSettingsLoader * | simple () |
Casts this instance to a QSimpleSettingsLoader. Will assert if the conversion fails. | |
QAsyncSettingsLoader * | async () |
Casts this instance to a QAsyncSettingsLoader. Will assert if the conversion fails. | |
Static Public Member Functions | |
static QHash< QString, QSettingsSettingsLoader * > | createLoaders (QSettings *settings, const QString &rootKey=QString(), bool recursive=false) |
Creates a list of loaders for a group in the settings. More... | |
A loader to load data from QSettings.
With this loader type, any value from QSettings can be used in the dialog
QSettingsSettingsLoader::QSettingsSettingsLoader | ( | QSettings * | settings, |
const QString & | key, | ||
bool | ownSettings = false |
||
) |
Creates a loader for a key in given QSettings.
settings | The settings object to be used |
key | The key within the settings to load/write to |
ownSettings | If true , the loader will delete the settings when it's destroyed. If false , thats not the case |
If you set the settings to be owned, the desturction of the loader will destroy them too. If not, the loader will not do anything. However, if you pass not owned settings, you have to make shure the object will not be destroyed until the loader was destroyed. Otherwise, your application will most likely crash.
|
static |
Creates a list of loaders for a group in the settings.
settings | The settings object to be used |
rootKey | The group key to scan |
recursive | Specifies, whether searching should be performed recusive or not |
This function will scan the given key group of the settings and create loaders for all child entries in that group. If recursive is false
, only the direct child entries will be used. If it is true
, this function will recusivly scan all subgroups and create entries for all of them.
The resulting map contains all entries with their keys as key. Each key will include the key that was passed to this function. The settings state will not be changed, and none of the returned loaders will have ownership of the settings.
|
overridevirtual |
Will be called if settings need to be loaded form this loader.
data | [outParam] A reference to the QVariant object to load the data into. (Defaults to QVariant::Invalid ) |
userEdited | [outParam] A reference to a bool to specify whether the value comes from the user or is the default. (Defaults to false ) |
true
, if loading was successful, false
if notThis method will be called from the engine to load settings for the display dialog. The loaded value should be written into data
. You can use the userEdited parameter to activate/deactivate the entry. If loading was successful return true
. If not return false
and an error will be shown to the user and the entry that uses this loader will be diabled.
Implements QSimpleSettingsLoader.
|
overridevirtual |
Will be called to reset the data this loader manages.
true
, if resetting was successful, false
if notIf resetting was successful return true
. If not return false
and an error will be shown to the user and the entry that uses this loader will be diabled.
Implements QSimpleSettingsLoader.
|
overridevirtual |
Will be called to save settings from the dialog to this loader.
data | The data to be saved. |
true
, if saving was successful, false
if notIf saving was successful return true
. If not return false
and an error will be shown to the user and the entry that uses this loader will be diabled.
Implements QSimpleSettingsLoader.