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) :
|
||||
QDialog(parent),
|
||||
working_project_(p)
|
||||
working_project_(p),
|
||||
ocio_config_is_valid_(true)
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -87,46 +88,52 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project* p, QWidget *parent) :
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
try {
|
||||
if (ocio_config_is_valid_) {
|
||||
// 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());
|
||||
|
||||
QDialog::accept();
|
||||
} catch (OCIO::Exception& e) {
|
||||
} else {
|
||||
QMessageBox::critical(this,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
bool ProjectPropertiesDialog::VerifyOCIOConfig(const QString &fn)
|
||||
void ProjectPropertiesDialog::BrowseForOCIOConfig()
|
||||
{
|
||||
try {
|
||||
OCIO::Config::CreateFromFile(fn.toUtf8());
|
||||
|
||||
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;
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Browse for OpenColorIO configuration"));
|
||||
if (!fn.isEmpty()) {
|
||||
ocio_filename_->setText(fn);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPropertiesDialog::ListPossibleInputSpaces(OCIO::ConstConfigRcPtr config)
|
||||
void ProjectPropertiesDialog::FilenameUpdated()
|
||||
{
|
||||
try {
|
||||
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) {
|
||||
default_input_colorspace_->addItem(cs);
|
||||
@@ -135,19 +142,11 @@ void ProjectPropertiesDialog::ListPossibleInputSpaces(OCIO::ConstConfigRcPtr con
|
||||
default_input_colorspace_->setCurrentIndex(default_input_colorspace_->count()-1);
|
||||
}
|
||||
}
|
||||
} catch (OCIO::Exception&) {
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPropertiesDialog::BrowseForOCIOConfig()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Browse for OpenColorIO configuration"));
|
||||
if (!fn.isEmpty()) {
|
||||
if (VerifyOCIOConfig(fn)) {
|
||||
ocio_filename_->setText(fn);
|
||||
|
||||
ListPossibleInputSpaces(OCIO::Config::CreateFromFile(fn.toUtf8()));
|
||||
}
|
||||
} catch (OCIO::Exception& e) {
|
||||
ocio_config_is_valid_ = false;
|
||||
ocio_filename_->setStyleSheet(QStringLiteral("QLineEdit {color: red;}"));
|
||||
ocio_config_error_ = e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,19 +39,21 @@ public slots:
|
||||
virtual void accept() override;
|
||||
|
||||
private:
|
||||
bool VerifyOCIOConfig(const QString& fn);
|
||||
|
||||
void ListPossibleInputSpaces(OpenColorIO::v1::ConstConfigRcPtr config);
|
||||
|
||||
Project* working_project_;
|
||||
|
||||
QLineEdit* ocio_filename_;
|
||||
|
||||
QComboBox* default_input_colorspace_;
|
||||
|
||||
bool ocio_config_is_valid_;
|
||||
|
||||
QString ocio_config_error_;
|
||||
|
||||
private slots:
|
||||
void BrowseForOCIOConfig();
|
||||
|
||||
void FilenameUpdated();
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
QString ColorManager::default_config_;
|
||||
OCIO::ConstConfigRcPtr ColorManager::default_config_;
|
||||
|
||||
ColorManager::ColorManager()
|
||||
{
|
||||
// Ensures config is set to something
|
||||
config_ = OCIO::GetCurrentConfig();
|
||||
config_ = GetDefaultConfig();
|
||||
|
||||
// Default input space
|
||||
default_input_color_space_ = QStringLiteral("sRGB OETF");
|
||||
@@ -54,6 +54,11 @@ const QString &ColorManager::GetConfigFilename() const
|
||||
return config_filename_;
|
||||
}
|
||||
|
||||
OCIO::ConstConfigRcPtr ColorManager::GetDefaultConfig()
|
||||
{
|
||||
return default_config_;
|
||||
}
|
||||
|
||||
void ColorManager::SetUpDefaultConfig()
|
||||
{
|
||||
// Kind of hacky, but it'll work
|
||||
@@ -62,9 +67,7 @@ void ColorManager::SetUpDefaultConfig()
|
||||
FileFunctions::CopyDirectory(QStringLiteral(":/ocioconf"),
|
||||
dir);
|
||||
|
||||
default_config_ = QDir(dir).filePath(QStringLiteral("config.ocio"));
|
||||
|
||||
OCIO::SetCurrentConfig(OCIO::Config::CreateFromFile(default_config_.toUtf8()));
|
||||
default_config_ = OCIO::Config::CreateFromFile(QDir(dir).filePath(QStringLiteral("config.ocio")).toUtf8());
|
||||
}
|
||||
|
||||
void ColorManager::SetConfig(const QString &filename)
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
|
||||
const QString& GetConfigFilename() const;
|
||||
|
||||
static OCIO::ConstConfigRcPtr GetDefaultConfig();
|
||||
|
||||
static void SetUpDefaultConfig();
|
||||
|
||||
void SetConfig(const QString& filename);
|
||||
@@ -110,7 +112,7 @@ private:
|
||||
|
||||
QString reference_space_;
|
||||
|
||||
static QString default_config_;
|
||||
static OCIO::ConstConfigRcPtr default_config_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user