implemented settings type safety
This commit is contained in:
parent
167a6852a7
commit
7e64d166ab
3 changed files with 14 additions and 2 deletions
|
@ -35,6 +35,18 @@ public:
|
||||||
return QMetaEnum::fromType<AppInternalSetting>().valueToKey(key);
|
return QMetaEnum::fromType<AppInternalSetting>().valueToKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QVariant::Type keyToType(int key) {
|
||||||
|
QMap<AppInternalSetting, QVariant::Type> types = {
|
||||||
|
{AppThemeSetting, QVariant::String},
|
||||||
|
{BaseStationIpSetting, QVariant::String}
|
||||||
|
};
|
||||||
|
|
||||||
|
if(types.contains(AppInternalSetting(key)))
|
||||||
|
return types[AppInternalSetting(key)];
|
||||||
|
|
||||||
|
return QVariant::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 150b33b483547b1e8df49eb9bb5b149da0b29a0e
|
Subproject commit d982bafab14b45e407b30efdaa6c1acdcbe6b781
|
|
@ -22,7 +22,7 @@ ScStwAppSettings * pGlobalAppSettings = nullptr;
|
||||||
ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
|
ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
|
||||||
:ScStwRemoteSettings(client, parent)
|
:ScStwRemoteSettings(client, parent)
|
||||||
{
|
{
|
||||||
this->registerKeyLevelHandler(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString);
|
this->registerKeyLevelConverters(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString, &ScStwAppSettings::keyToType);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
|
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {
|
||||||
|
|
Reference in a new issue