Add a mechanism for per-platform defaults

So we can have different default settings on different target platforms.
This commit is contained in:
Vincent Lang 2015-10-22 14:41:01 +02:00
parent 592af53b5d
commit ad0347d191

View File

@ -386,8 +386,26 @@ void SettingsComponent::parseSection(const QJsonObject& sectionObject)
if (!valobj.contains("value") || !valobj.contains("default") || valobj.value("value").isNull())
continue;
QJsonValue defaults = valobj.value("default");
QVariant defaultval = defaults.toVariant();
if (defaults.isArray())
{
defaultval = QVariant();
// Whichever default matches the current platform first is used.
foreach(const auto& v, defaults.toArray())
{
auto vobj = v.toObject();
int defPlatformMask = platformMaskFromObject(vobj);
if ((defPlatformMask & Utils::CurrentPlatform()) == Utils::CurrentPlatform())
{
defaultval = vobj.value("value").toVariant();
break;
}
}
}
int vPlatformMask = platformMaskFromObject(valobj);
SettingsValue* setting = new SettingsValue(valobj.value("value").toString(), valobj.value("default").toVariant(), (quint8)vPlatformMask, this);
SettingsValue* setting = new SettingsValue(valobj.value("value").toString(), defaultval, (quint8)vPlatformMask, this);
setting->setHidden(valobj.value("hidden").toBool(false));
setting->setIndexOrder(order ++);