mirror of
https://github.com/QuasarApp/QuasarAppLib.git
synced 2025-04-28 02:34:43 +00:00
This commit is contained in:
parent
dcb12781be
commit
ff2a2dbed0
@ -61,7 +61,7 @@ add_library(${PROJECT_NAME} ${SOURCE_CPP})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
setVersion(1 5 1)
|
||||
setVersion(1 5 2)
|
||||
|
||||
initAll()
|
||||
make_directory("${CMAKE_CURRENT_SOURCE_DIR}/Distro")
|
||||
|
14
isettings.h
14
isettings.h
@ -35,9 +35,9 @@ enum class SettingsSaveMode: quint64 {
|
||||
*
|
||||
* @note The all child classes should be initialized before used.
|
||||
*
|
||||
* ```
|
||||
* auto settingsInstance = Setting::init<Setting>();
|
||||
* ```
|
||||
* @code{cpp}
|
||||
* auto settingsInstance = Setting::initService<Setting>();
|
||||
* @endcode
|
||||
*
|
||||
* @see ISettings::init method.
|
||||
*
|
||||
@ -187,8 +187,6 @@ protected:
|
||||
*/
|
||||
void clearCache();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief settingsMap This method returns initialized settings map.
|
||||
* Settings map contains pairs with settings key and default value.
|
||||
@ -204,9 +202,11 @@ private:
|
||||
QHash<QString, QVariant> _cache;
|
||||
QHash<QString, QVariant> *_defaultConfig = nullptr;
|
||||
|
||||
// static ISettings* _settings;
|
||||
friend class Service<ISettings>;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
} ;
|
||||
|
||||
|
||||
#endif // ISETTINGS_H
|
||||
|
@ -66,8 +66,7 @@ template<class Base>
|
||||
class Service
|
||||
{
|
||||
public:
|
||||
Service() {
|
||||
};
|
||||
Service() {};
|
||||
|
||||
/**
|
||||
* @brief initService This method initialize the @a Base object as a service.
|
||||
@ -79,8 +78,8 @@ public:
|
||||
*/
|
||||
template<class BaseClass = Base, class... Args>
|
||||
static Base* initService(Args&&... args) {
|
||||
auto instanceObj = privateInstance();
|
||||
if(instanceObj->_data) {
|
||||
Service<Base>* instanceObj = privateInstance();
|
||||
if(!instanceObj->_data) {
|
||||
instanceObj->_data = new BaseClass(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@ -121,7 +120,7 @@ public:
|
||||
* @see autoInstance
|
||||
*/
|
||||
static void deinitService() {
|
||||
auto instanceObj = privateInstance();
|
||||
Service<Base>* instanceObj = privateInstance();
|
||||
if(instanceObj->_data) {
|
||||
delete instanceObj->_data;
|
||||
instanceObj->_data = nullptr;
|
||||
|
@ -43,6 +43,14 @@ void Settings::setValueImplementation(const QString key, const QVariant &value)
|
||||
return _settings->setValue(key, value);
|
||||
}
|
||||
|
||||
bool Settings::ignoreToRest(const QString &) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QHash<QString, QVariant> Settings::defaultSettings() {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool Settings::isBool(const QString &) const {
|
||||
return false;
|
||||
}
|
||||
|
26
settings.h
26
settings.h
@ -20,9 +20,21 @@ namespace QuasarAppUtils {
|
||||
*
|
||||
* Example of initialisation :
|
||||
*
|
||||
* ```
|
||||
* auto settingsInstance = Setting::init();
|
||||
* ```
|
||||
* @code{cpp}
|
||||
* 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();
|
||||
* @endcode
|
||||
*
|
||||
* **Or** you can use the Settings::autoInstance method.
|
||||
*
|
||||
* @code{cpp}
|
||||
* auto settingsInstance = QuasarAppUtils::Setting::autoInstance();
|
||||
* @endcode
|
||||
*
|
||||
* @see Settings::init
|
||||
*/
|
||||
@ -51,9 +63,11 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void syncImplementation();
|
||||
QVariant getValueImplementation(const QString &key, const QVariant &def);
|
||||
void setValueImplementation(const QString key, const QVariant &value);
|
||||
void syncImplementation() override;
|
||||
QVariant getValueImplementation(const QString &key, const QVariant &def) override;
|
||||
void setValueImplementation(const QString key, const QVariant &value) override;
|
||||
bool ignoreToRest(const QString &) const override;
|
||||
QHash<QString, QVariant> defaultSettings() override;
|
||||
|
||||
/**
|
||||
* @brief isBool This method should be return true if the key's type is bool.
|
||||
|
Loading…
x
Reference in New Issue
Block a user