QuasarAppLib
QuasarAppUtils::Settings Class Reference

The Settings class This is wraper of the QSettings object. More...

#include <settings.h>

Inheritance diagram for QuasarAppUtils::Settings:
Inheritance graph
Collaboration diagram for QuasarAppUtils::Settings:
Collaboration graph

Public Member Functions

 Settings ()
 
const QSet< QString > & boolOptions () const
 boolOptions returns current map with keys that has a bool type.
 
void setBoolOptions (const QSet< QString > &newBoolOptions)
 setBoolOptions This method sets new map of the boolean options.
 
- Public Member Functions inherited from QuasarAppUtils::ISettings
 ~ISettings () override
 
Q_INVOKABLE QVariant getValue (const QString &key, const QVariant &def={})
 getValue This method return the value of the settings.
 
Q_INVOKABLE QString getStrValue (const QString &key, const QString &def={})
 getStrValue some as getValue but convert result object to QString type.
 
Q_INVOKABLE void resetToDefault ()
 resetToDefault This method reset all settings to default values.
 
void sync ()
 sync This method save all setings data on a hard disk;
 
void forceReloadCache ()
 forceReloadCache This method force reload settings data from disk.
 
SettingsSaveMode getMode () const
 getMode This method return the current mode of the settings.
 
void setMode (const SettingsSaveMode &mode)
 setMode This method sets a new value of the settings mode.
 
- Public Member Functions inherited from QuasarAppUtils::Service< ISettings >
 Service ()
 

Static Public Member Functions

static bool initService ()
 initService This method initialize default object of the QuasarAppUtils::Settings type.
 
- Static Public Member Functions inherited from QuasarAppUtils::ISettings
static ISettingsinstance ()
 instance This method returns pointer to current settings object.
 
static bool initService (std::unique_ptr< ISettings > obj)
 initService This method initialize the global settings object.
 
- Static Public Member Functions inherited from QuasarAppUtils::Service< ISettings >
static std::unique_ptr< ISettings > & initService ()
 initService This method initialize the Base object as a service.
 
static bool initService (std::unique_ptr< ISettings > obj)
 initService This is overrided static method of initialization cross libraryes object.
 
static ISettingsinstance ()
 instance This method return pointerer to current service object.
 
static ISettingsautoInstance ()
 autoInstance This method return pointerer to current service object and if it is not inited try to initialize it use default constructor.
 
static void deinitService ()
 deinitService This is distructor method for the service.
 

Protected Member Functions

void syncImplementation () override
 syncImplementation This method should save all configuration data to the hard drive;
 
QVariant getValueImplementation (const QString &key, const QVariant &def) override
 getValueImplementation This method will return the value of the settings.
 
void setValueImplementation (const QString key, const QVariant &value) override
 setValueImplementation This slot will set a new value for the key parameter.
 
bool ignoreToRest (const QString &) const override
 ignoreToRest This method should be returns true if the key setting is not be reset on the resetToDefault method.
 
QHash< QString, QVariantdefaultSettings () override
 
virtual bool isBool (const QString &key) const
 isBool This method should be return true if the key's type is bool. This is needed because QVariant will be converted alvays to true value in a qml code.
 
void setGroup (const QString &)
 
- Protected Member Functions inherited from QuasarAppUtils::ISettings
 ISettings (SettingsSaveMode mode=SettingsSaveMode::Auto)
 
void clearCache ()
 clearCache This method clear all data from cache.
 
QHash< QString, QVariant > & settingsMap ()
 settingsMap This method returns initialized settings map. Settings map contains pairs with settings key and default value.
 

Additional Inherited Members

- Public Slots inherited from QuasarAppUtils::ISettings
void setValue (const QString &key, const QVariant &value)
 setValue This slot sets new value for a key setting
 
void setStrValue (const QString &key, const QString &value)
 setStrValue This is some as setValue but working with the QString type.
 
- Signals inherited from QuasarAppUtils::ISettings
void valueChanged (QString key, QVariant value)
 valueChanged This signal when value of the key settings changed
 
void valueStrChanged (QString key, QString value)
 valueStrChanged some as valueChanged(QString key, QVariant value) but value has ben converted to the QString type.
 

Detailed Description

The Settings class This is wraper of the QSettings object.

Example of initialisation :

auto settingsInstance = QuasarAppUtils::Setting::initService();
// on any another site you can use the instance method for get settings instance object.
auto settingsInstance = QuasarAppUtils::Setting::instance();
// and you can destroy setting object if they are not needed anymore
QuasarAppUtils::Setting::deinitService();
void gen(int size, QByteArray &result)

Or you can use the Settings::autoInstance method.

auto settingsInstance = QuasarAppUtils::Setting::autoInstance();
See also
Settings::init

Definition at line 41 of file settings.h.

Constructor & Destructor Documentation

◆ Settings()

QuasarAppUtils::Settings::Settings ( )

Definition at line 16 of file settings.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ boolOptions()

const QSet< QString > & QuasarAppUtils::Settings::boolOptions ( ) const

boolOptions returns current map with keys that has a bool type.

Returns
current map with keys that has a bool type
See also
Settings::setBoolOptions
Settings::isBool

Definition at line 58 of file settings.cpp.

◆ defaultSettings()

QHash< QString, QVariant > QuasarAppUtils::Settings::defaultSettings ( )
overrideprotectedvirtual

Implements QuasarAppUtils::ISettings.

Definition at line 50 of file settings.cpp.

◆ getValueImplementation()

QVariant QuasarAppUtils::Settings::getValueImplementation ( const QString key,
const QVariant def 
)
overrideprotectedvirtual

getValueImplementation This method will return the value of the settings.

Parameters
keyThis is name of the required settings value.
defThis is default value if a value is not finded.
Returns
value of a key

Implements QuasarAppUtils::ISettings.

Definition at line 34 of file settings.cpp.

Here is the call graph for this function:

◆ ignoreToRest()

bool QuasarAppUtils::Settings::ignoreToRest ( const QString key) const
overrideprotectedvirtual

ignoreToRest This method should be returns true if the key setting is not be reset on the resetToDefault method.

Parameters
keyThis is keuy value.
Returns
true if the key option can't be reset to default. The default implementaion alwayes return false.

Reimplemented from QuasarAppUtils::ISettings.

Definition at line 46 of file settings.cpp.

◆ initService()

bool QuasarAppUtils::Settings::initService ( )
static

initService This method initialize default object of the QuasarAppUtils::Settings type.

Returns
true if initialization finished successfull else false.
See also
ISettings::initService

Definition at line 68 of file settings.cpp.

Here is the call graph for this function:

◆ isBool()

bool QuasarAppUtils::Settings::isBool ( const QString key) const
protectedvirtual

isBool This method should be return true if the key's type is bool. This is needed because QVariant will be converted alvays to true value in a qml code.

Parameters
keyThis is key of checks setting.
Returns
true if the key is boolean variable. The default implementation check key in the inner map.
See also
Settings::setBoolOptions
Settings::boolOptions

Definition at line 54 of file settings.cpp.

Here is the caller graph for this function:

◆ setBoolOptions()

void QuasarAppUtils::Settings::setBoolOptions ( const QSet< QString > &  newBoolOptions)

setBoolOptions This method sets new map of the boolean options.

Parameters
newBoolOptionsThis is new map of the boolean options.
See also
Settings::boolOptions
Settings::isBool

Definition at line 63 of file settings.cpp.

Here is the call graph for this function:

◆ setGroup()

void QuasarAppUtils::Settings::setGroup ( const QString )
protected

◆ setValueImplementation()

void QuasarAppUtils::Settings::setValueImplementation ( const QString  key,
const QVariant value 
)
overrideprotectedvirtual

setValueImplementation This slot will set a new value for the key parameter.

Parameters
keyThis is name of the changed setting.
valueThis is a new value of the setting

Implements QuasarAppUtils::ISettings.

Definition at line 42 of file settings.cpp.

Here is the call graph for this function:

◆ syncImplementation()

void QuasarAppUtils::Settings::syncImplementation ( )
overrideprotectedvirtual

syncImplementation This method should save all configuration data to the hard drive;

Implements QuasarAppUtils::ISettings.

Definition at line 30 of file settings.cpp.


The documentation for this class was generated from the following files: