mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-05-12 17:39:45 +00:00
ref #111 Added intarface for settings
This commit is contained in:
parent
bd14ed499f
commit
3994904b0a
@ -9,7 +9,9 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
using namespace QuasarAppUtils;
|
namespace QuasarAppUtils {
|
||||||
|
|
||||||
|
ISettings* ISettings::_settings = nullptr;
|
||||||
|
|
||||||
ISettings::ISettings(SettingsSaveMode mode) {
|
ISettings::ISettings(SettingsSaveMode mode) {
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
@ -23,15 +25,6 @@ void ISettings::setMode(const SettingsSaveMode &mode) {
|
|||||||
_mode = mode;
|
_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ISettings *ISettings::initSettings(SettingsSaveMode mode) {
|
|
||||||
// static ISettings* res = new ISettings(mode);
|
|
||||||
// return res;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ISettings *ISettings::instance() {
|
|
||||||
// return initSettings();
|
|
||||||
//}
|
|
||||||
|
|
||||||
QVariant ISettings::getValue(const QString &key, const QVariant &def) {
|
QVariant ISettings::getValue(const QString &key, const QVariant &def) {
|
||||||
return getValueImplementation(key, def);
|
return getValueImplementation(key, def);
|
||||||
}
|
}
|
||||||
@ -59,3 +52,5 @@ void ISettings::setValue(const QString key, const QVariant &value) {
|
|||||||
void ISettings::setStrValue(const QString &key, const QString &value) {
|
void ISettings::setStrValue(const QString &key, const QString &value) {
|
||||||
setValue(key, value);
|
setValue(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
24
isettings.h
24
isettings.h
@ -36,11 +36,21 @@ class QUASARAPPSHARED_EXPORT ISettings : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @brief instance This method return instance of the settings object
|
* @brief instance This method return instance of the settings object
|
||||||
// * @return pointer to a settings object;
|
* @return pointer to a settings object;
|
||||||
// */
|
*/
|
||||||
// static ISettings* instance();
|
template <class Settingstype>
|
||||||
|
static ISettings* instance() {
|
||||||
|
static_assert (std::is_base_of<Settingstype, ISettings>::value,
|
||||||
|
"the Settingstype type must be ISettings");
|
||||||
|
|
||||||
|
if(_settings == nullptr){
|
||||||
|
_settings = new Settingstype();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _settings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getValue This method return the value of the settings.
|
* @brief getValue This method return the value of the settings.
|
||||||
@ -132,9 +142,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsSaveMode _mode = SettingsSaveMode::Auto;
|
SettingsSaveMode _mode = SettingsSaveMode::Auto;
|
||||||
|
static ISettings* _settings;
|
||||||
// static ISettings* initSettings(SettingsSaveMode mode = SettingsSaveMode::Auto);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user