MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / restoreKnobsFromSettings

Method restoreKnobsFromSettings

Engine/Settings.cpp:2013–2064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2011} // saveSettings
2012
2013void
2014Settings::restoreKnobsFromSettings(const std::vector<KnobI*>& knobs)
2015{
2016 QSettings settings( QString::fromUtf8(NATRON_ORGANIZATION_NAME), QString::fromUtf8(NATRON_APPLICATION_NAME) );
2017
2018 for (U32 i = 0; i < knobs.size(); ++i) {
2019 KnobStringBase* isString = dynamic_cast<KnobStringBase*>(knobs[i]);
2020 KnobIntBase* isInt = dynamic_cast<KnobIntBase*>(knobs[i]);
2021 KnobChoice* isChoice = dynamic_cast<KnobChoice*>(knobs[i]);
2022 KnobDoubleBase* isDouble = dynamic_cast<KnobDoubleBase*>(knobs[i]);
2023 KnobBoolBase* isBool = dynamic_cast<KnobBoolBase*>(knobs[i]);
2024
2025 const std::string& name = knobs[i]->getName();
2026
2027 for (int j = 0; j < knobs[i]->getDimension(); ++j) {
2028 std::string dimensionName = knobs[i]->getDimension() > 1 ? name + '.' + knobs[i]->getDimensionName(j) : name;
2029 QString qDimName = QString::fromUtf8( dimensionName.c_str() );
2030
2031 if ( settings.contains(qDimName) ) {
2032 if (isString) {
2033 isString->setValue(settings.value(qDimName).toString().toStdString(), ViewSpec::all(), j);
2034 } else if (isInt) {
2035 if (isChoice) {
2036 ///For choices,serialize the choice name instead
2037 std::string value = settings.value(qDimName).toString().toStdString();
2038 const std::vector<ChoiceOption> entries = isChoice->getEntries_mt_safe();
2039 int found = -1;
2040
2041 for (U32 k = 0; k < entries.size(); ++k) {
2042 if (entries[k].id == value) {
2043 found = (int)k;
2044 break;
2045 }
2046 }
2047
2048 if (found >= 0) {
2049 isChoice->setValue(found, ViewSpec::all(), j);
2050 }
2051 } else {
2052 isInt->setValue(settings.value(qDimName).toInt(), ViewSpec::all(), j);
2053 }
2054 } else if (isDouble) {
2055 isDouble->setValue(settings.value(qDimName).toDouble(), ViewSpec::all(), j);
2056 } else if (isBool) {
2057 isBool->setValue(settings.value(qDimName).toBool(), ViewSpec::all(), j);
2058 } else {
2059 assert(false);
2060 }
2061 }
2062 }
2063 }
2064} // Settings::restoreKnobsFromSettings
2065
2066void
2067Settings::restoreKnobsFromSettings(const KnobsVec& knobs)

Callers 1

closeEventMethod · 0.80

Calls 11

allFunction · 0.85
getNameMethod · 0.80
getDimensionNameMethod · 0.80
toStdStringMethod · 0.80
getEntries_mt_safeMethod · 0.80
sizeMethod · 0.45
getDimensionMethod · 0.45
containsMethod · 0.45
setValueMethod · 0.45
valueMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected