began work on exr proxy task
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFileDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
@@ -45,67 +44,119 @@ ProjectPropertiesDialog::ProjectPropertiesDialog(Project* p, QWidget *parent) :
|
||||
|
||||
setWindowTitle(tr("Project Properties for '%1'").arg(working_project_->name()));
|
||||
|
||||
QGroupBox* color_group = new QGroupBox();
|
||||
color_group->setTitle(tr("Color Management"));
|
||||
{
|
||||
// Color management group
|
||||
QGroupBox* color_group = new QGroupBox();
|
||||
color_group->setTitle(tr("Color Management"));
|
||||
|
||||
QGridLayout* color_layout = new QGridLayout(color_group);
|
||||
QGridLayout* color_layout = new QGridLayout(color_group);
|
||||
|
||||
int row = 0;
|
||||
int row = 0;
|
||||
|
||||
color_layout->addWidget(new QLabel(tr("OpenColorIO Configuration:")), row, 0);
|
||||
color_layout->addWidget(new QLabel(tr("OpenColorIO Configuration:")), row, 0);
|
||||
|
||||
ocio_filename_ = new QLineEdit();
|
||||
ocio_filename_->setPlaceholderText(tr("(default)"));
|
||||
color_layout->addWidget(ocio_filename_, row, 1);
|
||||
ocio_filename_ = new QLineEdit();
|
||||
ocio_filename_->setPlaceholderText(tr("(default)"));
|
||||
color_layout->addWidget(ocio_filename_, row, 1);
|
||||
|
||||
row++;
|
||||
row++;
|
||||
|
||||
color_layout->addWidget(new QLabel(tr("Default Input Color Space:")), row, 0);
|
||||
color_layout->addWidget(new QLabel(tr("Default Input Color Space:")), row, 0);
|
||||
|
||||
default_input_colorspace_ = new QComboBox();
|
||||
color_layout->addWidget(default_input_colorspace_, row, 1, 1, 2);
|
||||
default_input_colorspace_ = new QComboBox();
|
||||
color_layout->addWidget(default_input_colorspace_, row, 1, 1, 2);
|
||||
|
||||
row++;
|
||||
row++;
|
||||
|
||||
QPushButton* browse_btn = new QPushButton(tr("Browse"));
|
||||
color_layout->addWidget(browse_btn, 0, 2);
|
||||
connect(browse_btn, SIGNAL(clicked(bool)), this, SLOT(BrowseForOCIOConfig()));
|
||||
QPushButton* browse_btn = new QPushButton(tr("Browse"));
|
||||
color_layout->addWidget(browse_btn, 0, 2);
|
||||
connect(browse_btn, &QPushButton::clicked, this, &ProjectPropertiesDialog::BrowseForOCIOConfig);
|
||||
|
||||
layout->addWidget(color_group);
|
||||
layout->addWidget(color_group);
|
||||
|
||||
QDialogButtonBox* dialog_btns = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
|
||||
layout->addWidget(dialog_btns);
|
||||
connect(dialog_btns, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(dialog_btns, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
ocio_filename_->setText(working_project_->color_manager()->GetConfigFilename());
|
||||
|
||||
if (working_project_ == nullptr) {
|
||||
QMessageBox::critical(this,
|
||||
tr("No Active Project"),
|
||||
tr("No project is currently open to set the properties for"),
|
||||
QMessageBox::Ok);
|
||||
reject();
|
||||
return;
|
||||
connect(ocio_filename_, &QLineEdit::textChanged, this, &ProjectPropertiesDialog::OCIOFilenameUpdated);
|
||||
OCIOFilenameUpdated();
|
||||
}
|
||||
|
||||
ocio_filename_->setText(working_project_->color_manager()->GetConfigFilename());
|
||||
{
|
||||
// Paths group
|
||||
QGroupBox* paths_group = new QGroupBox();
|
||||
paths_group->setTitle(tr("Paths"));
|
||||
|
||||
connect(ocio_filename_, &QLineEdit::textChanged, this, &ProjectPropertiesDialog::FilenameUpdated);
|
||||
FilenameUpdated();
|
||||
QGridLayout* paths_layout = new QGridLayout(paths_group);
|
||||
|
||||
cache_path_ = new PathWidget(working_project_->cache_path(), this);
|
||||
proxy_path_ = new PathWidget(working_project_->proxy_path(), this);
|
||||
|
||||
int row = 0;
|
||||
|
||||
paths_layout->addWidget(new QLabel(tr("Cache Path:")), row, 0);
|
||||
paths_layout->addWidget(cache_path_->path_edit(), row, 1);
|
||||
paths_layout->addWidget(cache_path_->browse_btn(), row, 2);
|
||||
paths_layout->addWidget(cache_path_->default_box(), row, 3);
|
||||
|
||||
row++;
|
||||
|
||||
paths_layout->addWidget(new QLabel(tr("Proxy Path:")), row, 0);
|
||||
paths_layout->addWidget(proxy_path_->path_edit(), row, 1);
|
||||
paths_layout->addWidget(proxy_path_->browse_btn(), row, 2);
|
||||
paths_layout->addWidget(proxy_path_->default_box(), row, 3);
|
||||
|
||||
layout->addWidget(paths_group);
|
||||
}
|
||||
|
||||
QDialogButtonBox* dialog_btns = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
|
||||
Qt::Horizontal);
|
||||
layout->addWidget(dialog_btns);
|
||||
connect(dialog_btns, &QDialogButtonBox::accepted, this, &ProjectPropertiesDialog::accept);
|
||||
connect(dialog_btns, &QDialogButtonBox::rejected, this, &ProjectPropertiesDialog::reject);
|
||||
}
|
||||
|
||||
void ProjectPropertiesDialog::accept()
|
||||
{
|
||||
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();
|
||||
} else {
|
||||
QMessageBox::critical(this,
|
||||
tr("OpenColorIO Config Error"),
|
||||
tr("Failed to set OpenColorIO configuration: %1").arg(ocio_config_error_),
|
||||
QMessageBox::Ok);
|
||||
if (!ocio_config_is_valid_) {
|
||||
QMessageBox mb(this);
|
||||
mb.setWindowModality(Qt::WindowModal);
|
||||
mb.setIcon(QMessageBox::Critical);
|
||||
mb.setWindowTitle(tr("OpenColorIO Config Error"));
|
||||
mb.setText(tr("Failed to set OpenColorIO configuration: %1").arg(ocio_config_error_));
|
||||
mb.addButton(QMessageBox::Ok);
|
||||
mb.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cache_path_->PathIsValid(true)) {
|
||||
QMessageBox mb(this);
|
||||
mb.setWindowModality(Qt::WindowModal);
|
||||
mb.setIcon(QMessageBox::Critical);
|
||||
mb.setWindowTitle(tr("Invalid path"));
|
||||
mb.setText(tr("The cache path is invalid. Please check it and try again."));
|
||||
mb.addButton(QMessageBox::Ok);
|
||||
mb.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!proxy_path_->PathIsValid(true)) {
|
||||
QMessageBox mb(this);
|
||||
mb.setWindowModality(Qt::WindowModal);
|
||||
mb.setIcon(QMessageBox::Critical);
|
||||
mb.setWindowTitle(tr("Invalid path"));
|
||||
mb.setText(tr("The proxy path is invalid. Please check it and try again."));
|
||||
mb.addButton(QMessageBox::Ok);
|
||||
mb.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
working_project_->set_cache_path(cache_path_->path_edit()->text());
|
||||
working_project_->set_proxy_path(proxy_path_->path_edit()->text());
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
void ProjectPropertiesDialog::BrowseForOCIOConfig()
|
||||
@@ -116,7 +167,7 @@ void ProjectPropertiesDialog::BrowseForOCIOConfig()
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPropertiesDialog::FilenameUpdated()
|
||||
void ProjectPropertiesDialog::OCIOFilenameUpdated()
|
||||
{
|
||||
default_input_colorspace_->clear();
|
||||
|
||||
@@ -150,4 +201,54 @@ void ProjectPropertiesDialog::FilenameUpdated()
|
||||
}
|
||||
}
|
||||
|
||||
PathWidget::PathWidget(const QString &path, QWidget *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
path_edit_ = new QLineEdit();
|
||||
path_edit_->setText(path);
|
||||
connect(path_edit_, &QLineEdit::textChanged, this, &PathWidget::LineEditChanged);
|
||||
|
||||
default_box_ = new QCheckBox(tr("Default"));
|
||||
|
||||
browse_btn_ = new QPushButton(tr("Browse"));
|
||||
|
||||
connect(default_box_, &QCheckBox::toggled, this, &PathWidget::DefaultToggled);
|
||||
|
||||
default_box_->setChecked(path.isEmpty());
|
||||
|
||||
connect(browse_btn_, &QPushButton::clicked, this, &PathWidget::BrowseClicked);
|
||||
}
|
||||
|
||||
bool PathWidget::PathIsValid(bool try_to_create) const
|
||||
{
|
||||
return default_box_->isChecked()
|
||||
|| QDir(path_edit_->text()).exists()
|
||||
|| (try_to_create && QDir(path_edit_->text()).mkpath(QStringLiteral(".")));
|
||||
}
|
||||
|
||||
void PathWidget::DefaultToggled(bool e)
|
||||
{
|
||||
path_edit_->setEnabled(!e);
|
||||
}
|
||||
|
||||
void PathWidget::BrowseClicked()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(static_cast<QWidget*>(parent()),
|
||||
tr("Browse for path"),
|
||||
path_edit_->text());
|
||||
|
||||
if (!dir.isEmpty()) {
|
||||
path_edit_->setText(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void PathWidget::LineEditChanged()
|
||||
{
|
||||
if (PathIsValid(false)) {
|
||||
path_edit_->setStyleSheet(QString());
|
||||
} else {
|
||||
path_edit_->setStyleSheet(QStringLiteral("QLineEdit {color: red;}"));
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user