MCPcopy Create free account
hub / github.com/MrKepzie/Natron / tryLoadOpenColorIOConfig

Method tryLoadOpenColorIOConfig

Engine/Settings.cpp:2128–2214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2126} // restoreSettings
2127
2128bool
2129Settings::tryLoadOpenColorIOConfig()
2130{
2131 // the default value is the environment variable "OCIO"
2132 QString configFile = QFile::decodeName( qgetenv(NATRON_OCIO_ENV_VAR_NAME) );
2133
2134 // OCIO environment variable overrides everything, then try the custom config...
2135 if ( configFile.isEmpty() && _customOcioConfigFile->isEnabled(0) ) {
2136 ///try to load from the file
2137 std::string file;
2138 try {
2139 file = _customOcioConfigFile->getValue();
2140 } catch (...) {
2141 // ignore exceptions
2142 }
2143 if ( file.empty() ) {
2144 return false;
2145 }
2146 configFile = QString::fromUtf8( file.c_str() );
2147 }
2148 if ( !configFile.isEmpty() ) {
2149 if ( !QFile::exists(configFile) ) {
2150 Dialogs::errorDialog( "OpenColorIO", tr("%1: No such file.").arg(configFile).toStdString() );
2151
2152 return false;
2153 }
2154 } else {
2155 // ... and finally try the setting from the choice menu.
2156 try {
2157 ///try to load from the combobox
2158 QString activeEntryText = QString::fromUtf8( _ocioConfigKnob->getActiveEntry().id.c_str() );
2159 QString configFileName = QString( activeEntryText + QString::fromUtf8(".ocio") );
2160 QStringList defaultConfigsPaths = getDefaultOcioConfigPaths();
2161 Q_FOREACH(const QString &defaultConfigsDirStr, defaultConfigsPaths) {
2162 QDir defaultConfigsDir(defaultConfigsDirStr);
2163
2164 if ( !defaultConfigsDir.exists() ) {
2165 qDebug() << "Attempt to read an OpenColorIO configuration but the configuration directory"
2166 << defaultConfigsDirStr << "does not exist.";
2167 continue;
2168 }
2169 ///try to open the .ocio config file first in the defaultConfigsDir
2170 ///if we can't find it, try to look in a subdirectory with the name of the config for the file config.ocio
2171 if ( !defaultConfigsDir.exists(configFileName) ) {
2172 QDir subDir(defaultConfigsDirStr + QDir::separator() + activeEntryText);
2173 if ( !subDir.exists() ) {
2174 Dialogs::errorDialog( "OpenColorIO", tr("%1: No such file or directory.").arg( subDir.absoluteFilePath( QString::fromUtf8("config.ocio") ) ).toStdString() );
2175
2176 return false;
2177 }
2178 if ( !subDir.exists( QString::fromUtf8("config.ocio") ) ) {
2179 Dialogs::errorDialog( "OpenColorIO", tr("%1: No such file or directory.").arg( subDir.absoluteFilePath( QString::fromUtf8("config.ocio") ) ).toStdString() );
2180
2181 return false;
2182 }
2183 configFile = subDir.absoluteFilePath( QString::fromUtf8("config.ocio") );
2184 } else {
2185 configFile = defaultConfigsDir.absoluteFilePath(configFileName);

Callers

nothing calls this directly

Calls 12

QStringClass · 0.85
utf8_to_utf16Function · 0.85
emptyMethod · 0.80
toStdStringMethod · 0.80
getActiveEntryMethod · 0.80
isEmptyMethod · 0.45
isEnabledMethod · 0.45
getValueMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected