implemented settings type safety

This commit is contained in:
Dorian Zedler 2020-07-30 11:29:11 +02:00
parent 167a6852a7
commit 7e64d166ab
Signed by: dorian
GPG key ID: D3B255CB8BC7CD37
3 changed files with 14 additions and 2 deletions

View file

@ -35,6 +35,18 @@ public:
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:
public slots:

@ -1 +1 @@
Subproject commit 150b33b483547b1e8df49eb9bb5b149da0b29a0e
Subproject commit d982bafab14b45e407b30efdaa6c1acdcbe6b781

View file

@ -22,7 +22,7 @@ ScStwAppSettings * pGlobalAppSettings = nullptr;
ScStwAppSettings::ScStwAppSettings(ScStwClient * client, QObject* parent)
:ScStwRemoteSettings(client, parent)
{
this->registerKeyLevelHandler(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString);
this->registerKeyLevelConverters(ScStwAppSettings::KeyLevel, &ScStwAppSettings::keyToString, &ScStwAppSettings::keyToType);
}
QVariant ScStwAppSettings::readSetting(AppInternalSetting key) {