|
|
|
@ -40,8 +40,15 @@ class CachedSettingValue
@@ -40,8 +40,15 @@ class CachedSettingValue
|
|
|
|
|
using ProxyFunc = std::function<T (const T&)>; |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue = T() |
|
|
|
|
, ProxyFunc proxyFunc = [](const T &value) { return value; }) |
|
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue = T()) |
|
|
|
|
: m_keyName(QLatin1String(keyName)) |
|
|
|
|
, m_value(SettingsStorage::instance()->loadValue( |
|
|
|
|
m_keyName, defaultValue).template value<T>()) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
explicit CachedSettingValue(const char *keyName, const T &defaultValue |
|
|
|
|
, const ProxyFunc &proxyFunc) |
|
|
|
|
: m_keyName(QLatin1String(keyName)) |
|
|
|
|
, m_value(proxyFunc(SettingsStorage::instance()->loadValue( |
|
|
|
|
m_keyName, defaultValue).template value<T>())) |
|
|
|
@ -53,6 +60,11 @@ public:
@@ -53,6 +60,11 @@ public:
|
|
|
|
|
return m_value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
operator T() const |
|
|
|
|
{ |
|
|
|
|
return value(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CachedSettingValue<T> &operator=(const T &newValue) |
|
|
|
|
{ |
|
|
|
|
m_value = newValue; |
|
|
|
@ -60,11 +72,6 @@ public:
@@ -60,11 +72,6 @@ public:
|
|
|
|
|
return *this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
operator T() const |
|
|
|
|
{ |
|
|
|
|
return value(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
const QString m_keyName; |
|
|
|
|
T m_value; |
|
|
|
|