colormanager: implement default config

This commit is contained in:
itsmattkc
2020-04-22 05:08:33 +10:00
parent 141ac8b12f
commit ccb02d30aa
45 changed files with 721897 additions and 196 deletions
+21 -1
View File
@@ -20,19 +20,26 @@
#include "colormanager.h"
#include <QDir>
#include <QFloat16>
#include "common/define.h"
#include "common/filefunctions.h"
#include "config/config.h"
#include "core.h"
OLIVE_NAMESPACE_ENTER
QString ColorManager::default_config_;
ColorManager::ColorManager()
{
// Ensures config is set to something
config_ = OCIO::GetCurrentConfig();
// Default input space is first in config
default_input_color_space_ = ListAvailableInputColorspaces().first();
// Default reference space is scene linear
reference_space_ = OCIO::ROLE_SCENE_LINEAR;
}
@@ -47,6 +54,19 @@ const QString &ColorManager::GetConfigFilename() const
return config_filename_;
}
void ColorManager::SetUpDefaultConfig()
{
// Kind of hacky, but it'll work
QString dir = QDir(FileFunctions::GetTempPath()).filePath(QStringLiteral("ocioconf"));
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
dir);
default_config_ = QDir(dir).filePath(QStringLiteral("config.ocio"));
OCIO::SetCurrentConfig(OCIO::Config::CreateFromFile(default_config_.toUtf8()));
}
void ColorManager::SetConfig(const QString &filename)
{
if (filename != config_filename_) {
@@ -63,7 +83,7 @@ void ColorManager::SetConfigInternal(const QString &filename)
OCIO::ConstConfigRcPtr cfg;
if (config_filename_.isEmpty()) {
cfg = OCIO::Config::CreateFromEnv();
cfg = OCIO::GetCurrentConfig();
} else {
cfg = OCIO::Config::CreateFromFile(filename.toUtf8());
}