projectproperties: updated to assume empty config is default config
This commit is contained in:
@@ -38,7 +38,8 @@ OLIVE_NAMESPACE_ENTER
|
|||||||
|
|
||||||
ProjectPropertiesDialog::ProjectPropertiesDialog(Project* p, QWidget *parent) :
|
ProjectPropertiesDialog::ProjectPropertiesDialog(Project* p, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
working_project_(p)
|
working_project_(p),
|
||||||
|
ocio_config_is_valid_(true)
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -87,46 +88,52 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project* p, QWidget *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
ocio_filename_->setText(working_project_->color_manager()->GetConfigFilename());
|
ocio_filename_->setText(working_project_->color_manager()->GetConfigFilename());
|
||||||
ListPossibleInputSpaces(working_project_->color_manager()->GetConfig());
|
|
||||||
|
connect(ocio_filename_, &QLineEdit::textChanged, this, &ProjectPropertiesDialog::FilenameUpdated);
|
||||||
|
FilenameUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPropertiesDialog::accept()
|
void ProjectPropertiesDialog::accept()
|
||||||
{
|
{
|
||||||
try {
|
if (ocio_config_is_valid_) {
|
||||||
// This should ripple changes throughout the program that the color config has changed, therefore must be done last
|
// This should ripple changes throughout the program that the color config has changed, therefore must be done last
|
||||||
working_project_->color_manager()->SetConfigAndDefaultInput(ocio_filename_->text(), default_input_colorspace_->currentText());
|
working_project_->color_manager()->SetConfigAndDefaultInput(ocio_filename_->text(), default_input_colorspace_->currentText());
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
} catch (OCIO::Exception& e) {
|
} else {
|
||||||
QMessageBox::critical(this,
|
QMessageBox::critical(this,
|
||||||
tr("OpenColorIO Config Error"),
|
tr("OpenColorIO Config Error"),
|
||||||
tr("Failed to set OpenColorIO configuration: %1").arg(e.what()),
|
tr("Failed to set OpenColorIO configuration: %1").arg(ocio_config_error_),
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProjectPropertiesDialog::VerifyOCIOConfig(const QString &fn)
|
void ProjectPropertiesDialog::BrowseForOCIOConfig()
|
||||||
{
|
{
|
||||||
try {
|
QString fn = QFileDialog::getOpenFileName(this, tr("Browse for OpenColorIO configuration"));
|
||||||
OCIO::Config::CreateFromFile(fn.toUtf8());
|
if (!fn.isEmpty()) {
|
||||||
|
ocio_filename_->setText(fn);
|
||||||
return true;
|
|
||||||
} catch (OCIO::Exception& e) {
|
|
||||||
QMessageBox::critical(this,
|
|
||||||
tr("OpenColorIO Config Error"),
|
|
||||||
tr("Failed to set OpenColorIO configuration: %1").arg(e.what()),
|
|
||||||
QMessageBox::Ok);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPropertiesDialog::ListPossibleInputSpaces(OCIO::ConstConfigRcPtr config)
|
void ProjectPropertiesDialog::FilenameUpdated()
|
||||||
{
|
{
|
||||||
try {
|
default_input_colorspace_->clear();
|
||||||
default_input_colorspace_->clear();
|
|
||||||
|
|
||||||
QStringList input_cs = ColorManager::ListAvailableInputColorspaces(config);
|
try {
|
||||||
|
OCIO::ConstConfigRcPtr c;
|
||||||
|
|
||||||
|
if (ocio_filename_->text().isEmpty()) {
|
||||||
|
c = ColorManager::GetDefaultConfig();
|
||||||
|
} else {
|
||||||
|
c = OCIO::Config::CreateFromFile(ocio_filename_->text().toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
ocio_filename_->setStyleSheet(QString());
|
||||||
|
ocio_config_is_valid_ = true;
|
||||||
|
|
||||||
|
// List input color spaces
|
||||||
|
QStringList input_cs = ColorManager::ListAvailableInputColorspaces(c);
|
||||||
|
|
||||||
foreach (QString cs, input_cs) {
|
foreach (QString cs, input_cs) {
|
||||||
default_input_colorspace_->addItem(cs);
|
default_input_colorspace_->addItem(cs);
|
||||||
@@ -135,19 +142,11 @@ void ProjectPropertiesDialog::ListPossibleInputSpaces(OCIO::ConstConfigRcPtr con
|
|||||||
default_input_colorspace_->setCurrentIndex(default_input_colorspace_->count()-1);
|
default_input_colorspace_->setCurrentIndex(default_input_colorspace_->count()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (OCIO::Exception&) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectPropertiesDialog::BrowseForOCIOConfig()
|
} catch (OCIO::Exception& e) {
|
||||||
{
|
ocio_config_is_valid_ = false;
|
||||||
QString fn = QFileDialog::getOpenFileName(this, tr("Browse for OpenColorIO configuration"));
|
ocio_filename_->setStyleSheet(QStringLiteral("QLineEdit {color: red;}"));
|
||||||
if (!fn.isEmpty()) {
|
ocio_config_error_ = e.what();
|
||||||
if (VerifyOCIOConfig(fn)) {
|
|
||||||
ocio_filename_->setText(fn);
|
|
||||||
|
|
||||||
ListPossibleInputSpaces(OCIO::Config::CreateFromFile(fn.toUtf8()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,19 +39,21 @@ public slots:
|
|||||||
virtual void accept() override;
|
virtual void accept() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool VerifyOCIOConfig(const QString& fn);
|
|
||||||
|
|
||||||
void ListPossibleInputSpaces(OpenColorIO::v1::ConstConfigRcPtr config);
|
|
||||||
|
|
||||||
Project* working_project_;
|
Project* working_project_;
|
||||||
|
|
||||||
QLineEdit* ocio_filename_;
|
QLineEdit* ocio_filename_;
|
||||||
|
|
||||||
QComboBox* default_input_colorspace_;
|
QComboBox* default_input_colorspace_;
|
||||||
|
|
||||||
|
bool ocio_config_is_valid_;
|
||||||
|
|
||||||
|
QString ocio_config_error_;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void BrowseForOCIOConfig();
|
void BrowseForOCIOConfig();
|
||||||
|
|
||||||
|
void FilenameUpdated();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OLIVE_NAMESPACE_EXIT
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
|
|
||||||
OLIVE_NAMESPACE_ENTER
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
QString ColorManager::default_config_;
|
OCIO::ConstConfigRcPtr ColorManager::default_config_;
|
||||||
|
|
||||||
ColorManager::ColorManager()
|
ColorManager::ColorManager()
|
||||||
{
|
{
|
||||||
// Ensures config is set to something
|
// Ensures config is set to something
|
||||||
config_ = OCIO::GetCurrentConfig();
|
config_ = GetDefaultConfig();
|
||||||
|
|
||||||
// Default input space
|
// Default input space
|
||||||
default_input_color_space_ = QStringLiteral("sRGB OETF");
|
default_input_color_space_ = QStringLiteral("sRGB OETF");
|
||||||
@@ -54,6 +54,11 @@ const QString &ColorManager::GetConfigFilename() const
|
|||||||
return config_filename_;
|
return config_filename_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||||
|
{
|
||||||
|
return default_config_;
|
||||||
|
}
|
||||||
|
|
||||||
void ColorManager::SetUpDefaultConfig()
|
void ColorManager::SetUpDefaultConfig()
|
||||||
{
|
{
|
||||||
// Kind of hacky, but it'll work
|
// Kind of hacky, but it'll work
|
||||||
@@ -62,9 +67,7 @@ void ColorManager::SetUpDefaultConfig()
|
|||||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
|
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
|
||||||
dir);
|
dir);
|
||||||
|
|
||||||
default_config_ = QDir(dir).filePath(QStringLiteral("config.ocio"));
|
default_config_ = OCIO::Config::CreateFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")).toUtf8());
|
||||||
|
|
||||||
OCIO::SetCurrentConfig(OCIO::Config::CreateFromFile(default_config_.toUtf8()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorManager::SetConfig(const QString &filename)
|
void ColorManager::SetConfig(const QString &filename)
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public:
|
|||||||
|
|
||||||
const QString& GetConfigFilename() const;
|
const QString& GetConfigFilename() const;
|
||||||
|
|
||||||
|
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||||
|
|
||||||
static void SetUpDefaultConfig();
|
static void SetUpDefaultConfig();
|
||||||
|
|
||||||
void SetConfig(const QString& filename);
|
void SetConfig(const QString& filename);
|
||||||
@@ -110,7 +112,7 @@ private:
|
|||||||
|
|
||||||
QString reference_space_;
|
QString reference_space_;
|
||||||
|
|
||||||
static QString default_config_;
|
static OCIO::ConstConfigRcPtr default_config_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user