style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PRESETMANAGER_H
|
||||
#define PRESETMANAGER_H
|
||||
#ifndef OAK_PRESETMANAGER_H
|
||||
#define OAK_PRESETMANAGER_H
|
||||
|
||||
#include <memory>
|
||||
#include <QCoreApplication>
|
||||
@@ -47,19 +47,19 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const QString &GetName() const
|
||||
const QString &get_name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
void SetName(const QString &s)
|
||||
void set_name(const QString &s)
|
||||
{
|
||||
name_ = s;
|
||||
}
|
||||
|
||||
virtual void Load(QXmlStreamReader *reader) = 0;
|
||||
virtual void load(QXmlStreamReader *reader) = 0;
|
||||
|
||||
virtual void Save(QXmlStreamWriter *writer) const = 0;
|
||||
virtual void save(QXmlStreamWriter *writer) const = 0;
|
||||
|
||||
private:
|
||||
QString name_;
|
||||
@@ -74,17 +74,17 @@ public:
|
||||
, parent_(parent)
|
||||
{
|
||||
// Load custom preset data from file
|
||||
QFile preset_file(GetCustomPresetFilename());
|
||||
QFile preset_file(get_custom_preset_filename());
|
||||
if (preset_file.open(QFile::ReadOnly)) {
|
||||
QXmlStreamReader reader(&preset_file);
|
||||
|
||||
while (XMLReadNextStartElement(&reader)) {
|
||||
while (xml_read_next_start_element(&reader)) {
|
||||
if (reader.name() == QStringLiteral("presets")) {
|
||||
while (XMLReadNextStartElement(&reader)) {
|
||||
while (xml_read_next_start_element(&reader)) {
|
||||
if (reader.name() == QStringLiteral("preset")) {
|
||||
PresetPtr p = std::make_unique<T>();
|
||||
|
||||
p->Load(&reader);
|
||||
p->load(&reader);
|
||||
|
||||
custom_preset_data_.append(p);
|
||||
} else {
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
~PresetManager()
|
||||
{
|
||||
// Save custom presets to disk
|
||||
QFile preset_file(GetCustomPresetFilename());
|
||||
QFile preset_file(get_custom_preset_filename());
|
||||
if (preset_file.open(QFile::WriteOnly)) {
|
||||
QXmlStreamWriter writer(&preset_file);
|
||||
writer.setAutoFormatting(true);
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
foreach (PresetPtr p, custom_preset_data_) {
|
||||
writer.writeStartElement(QStringLiteral("preset"));
|
||||
|
||||
p->Save(&writer);
|
||||
p->save(&writer);
|
||||
|
||||
writer.writeEndElement(); // preset
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
QString GetPresetName(QString start) const
|
||||
QString get_preset_name(QString start) const
|
||||
{
|
||||
bool ok;
|
||||
|
||||
@@ -163,25 +163,25 @@ public:
|
||||
return start;
|
||||
}
|
||||
|
||||
enum SaveStatus { kAppended, kReplaced, kNotSaved };
|
||||
enum SaveStatus { k_appended, k_replaced, k_not_saved };
|
||||
|
||||
SaveStatus SavePreset(PresetPtr preset)
|
||||
SaveStatus save_preset(PresetPtr preset)
|
||||
{
|
||||
QString preset_name;
|
||||
int existing_preset;
|
||||
|
||||
forever
|
||||
{
|
||||
preset_name = GetPresetName(preset_name);
|
||||
preset_name = get_preset_name(preset_name);
|
||||
|
||||
if (preset_name.isEmpty()) {
|
||||
// Dialog cancelled - leave function entirely
|
||||
return kNotSaved;
|
||||
return k_not_saved;
|
||||
}
|
||||
|
||||
existing_preset = -1;
|
||||
for (int i = 0; i < custom_preset_data_.size(); i++) {
|
||||
if (custom_preset_data_.at(i)->GetName() == preset_name) {
|
||||
if (custom_preset_data_.at(i)->get_name() == preset_name) {
|
||||
existing_preset = i;
|
||||
break;
|
||||
}
|
||||
@@ -200,39 +200,39 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
preset->SetName(preset_name);
|
||||
preset->set_name(preset_name);
|
||||
|
||||
if (existing_preset >= 0) {
|
||||
custom_preset_data_.replace(existing_preset, preset);
|
||||
return kReplaced;
|
||||
return k_replaced;
|
||||
} else {
|
||||
custom_preset_data_.append(preset);
|
||||
return kAppended;
|
||||
return k_appended;
|
||||
}
|
||||
}
|
||||
|
||||
QString GetCustomPresetFilename() const
|
||||
QString get_custom_preset_filename() const
|
||||
{
|
||||
return QDir(FileFunctions::GetConfigurationLocation())
|
||||
return QDir(FileFunctions::get_configuration_location())
|
||||
.filePath(preset_name_);
|
||||
}
|
||||
|
||||
PresetPtr GetPreset(int index)
|
||||
PresetPtr get_preset(int index)
|
||||
{
|
||||
return custom_preset_data_.at(index);
|
||||
}
|
||||
|
||||
void DeletePreset(int index)
|
||||
void delete_preset(int index)
|
||||
{
|
||||
custom_preset_data_.removeAt(index);
|
||||
}
|
||||
|
||||
int GetNumberOfPresets() const
|
||||
int get_number_of_presets() const
|
||||
{
|
||||
return custom_preset_data_.size();
|
||||
}
|
||||
|
||||
const QVector<PresetPtr> &GetPresetData() const
|
||||
const QVector<PresetPtr> &get_preset_data() const
|
||||
{
|
||||
return custom_preset_data_;
|
||||
}
|
||||
@@ -247,4 +247,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // PRESETMANAGER_H
|
||||
#endif // OAK_PRESETMANAGER_H
|
||||
|
||||
@@ -54,12 +54,12 @@ SequenceDialog::SequenceDialog(Sequence *s, Type t, QWidget *parent)
|
||||
parameter_tab_ = new SequenceDialogParameterTab(sequence_);
|
||||
splitter->addWidget(parameter_tab_);
|
||||
|
||||
connect(preset_tab_, &SequenceDialogPresetTab::PresetChanged,
|
||||
parameter_tab_, &SequenceDialogParameterTab::PresetChanged);
|
||||
connect(preset_tab_, &SequenceDialogPresetTab::PresetAccepted, this,
|
||||
connect(preset_tab_, &SequenceDialogPresetTab::preset_changed,
|
||||
parameter_tab_, &SequenceDialogParameterTab::preset_changed);
|
||||
connect(preset_tab_, &SequenceDialogPresetTab::preset_accepted, this,
|
||||
&SequenceDialog::accept);
|
||||
connect(parameter_tab_, &SequenceDialogParameterTab::SaveParametersAsPreset,
|
||||
preset_tab_, &SequenceDialogPresetTab::SaveParametersAsPreset);
|
||||
connect(parameter_tab_, &SequenceDialogParameterTab::save_parameters_as_preset,
|
||||
preset_tab_, &SequenceDialogPresetTab::save_parameters_as_preset);
|
||||
|
||||
// Set up name section
|
||||
QHBoxLayout *name_layout = new QHBoxLayout();
|
||||
@@ -78,28 +78,28 @@ SequenceDialog::SequenceDialog(Sequence *s, Type t, QWidget *parent)
|
||||
connect(buttons, &QDialogButtonBox::rejected, this,
|
||||
&SequenceDialog::reject);
|
||||
connect(default_btn, &QPushButton::clicked, this,
|
||||
&SequenceDialog::SetAsDefaultClicked);
|
||||
&SequenceDialog::set_as_default_clicked);
|
||||
layout->addWidget(buttons);
|
||||
|
||||
// Set window title based on type
|
||||
switch (t) {
|
||||
case kNew:
|
||||
case k_new:
|
||||
setWindowTitle(tr("New Sequence"));
|
||||
break;
|
||||
case kExisting:
|
||||
setWindowTitle(tr("Editing \"%1\"").arg(sequence_->GetLabel()));
|
||||
case k_existing:
|
||||
setWindowTitle(tr("Editing \"%1\"").arg(sequence_->get_label()));
|
||||
break;
|
||||
}
|
||||
|
||||
name_field_->setText(sequence_->GetLabel());
|
||||
name_field_->setText(sequence_->get_label());
|
||||
}
|
||||
|
||||
void SequenceDialog::SetUndoable(bool u)
|
||||
void SequenceDialog::set_undoable(bool u)
|
||||
{
|
||||
make_undoable_ = u;
|
||||
}
|
||||
|
||||
void SequenceDialog::SetNameIsEditable(bool e)
|
||||
void SequenceDialog::set_name_is_editable(bool e)
|
||||
{
|
||||
name_field_->setEnabled(e);
|
||||
}
|
||||
@@ -107,24 +107,24 @@ void SequenceDialog::SetNameIsEditable(bool e)
|
||||
void SequenceDialog::accept()
|
||||
{
|
||||
if (name_field_->isEnabled() && name_field_->text().isEmpty()) {
|
||||
QtUtils::MsgBox(this, QMessageBox::Critical,
|
||||
QtUtils::msg_box(this, QMessageBox::Critical,
|
||||
tr("Error editing Sequence"),
|
||||
tr("Please enter a name for this Sequence."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!VideoParams::FormatIsFloat(
|
||||
parameter_tab_->GetSelectedPreviewFormat()) &&
|
||||
!OLIVE_CONFIG("PreviewNonFloatDontAskAgain").toBool()) {
|
||||
if (!VideoParams::format_is_float(
|
||||
parameter_tab_->get_selected_preview_format()) &&
|
||||
!OAK_CONFIG("PreviewNonFloatDontAskAgain").toBool()) {
|
||||
QMessageBox b(this);
|
||||
QCheckBox *dont_show_again_ = new QCheckBox(tr("Don't ask me again"));
|
||||
QCheckBox *dont_show_again = new QCheckBox(tr("Don't ask me again"));
|
||||
|
||||
b.setIcon(QMessageBox::Warning);
|
||||
b.setWindowTitle(tr("Low Quality Preview"));
|
||||
b.setText(tr(
|
||||
"The preview resolution has been set to a non-float format. This may cause banding and clipping artifacts in the preview.\n\n"
|
||||
"Do you wish to continue?"));
|
||||
b.setCheckBox(dont_show_again_);
|
||||
b.setCheckBox(dont_show_again);
|
||||
|
||||
b.addButton(QMessageBox::Yes);
|
||||
b.addButton(QMessageBox::No);
|
||||
@@ -133,70 +133,70 @@ void SequenceDialog::accept()
|
||||
return;
|
||||
}
|
||||
|
||||
if (dont_show_again_->isChecked()) {
|
||||
OLIVE_CONFIG("PreviewNonFloatDontAskAgain") = true;
|
||||
if (dont_show_again->isChecked()) {
|
||||
OAK_CONFIG("PreviewNonFloatDontAskAgain") = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate video and audio parameter structs from data
|
||||
VideoParams video_params =
|
||||
VideoParams(parameter_tab_->GetSelectedVideoWidth(),
|
||||
parameter_tab_->GetSelectedVideoHeight(),
|
||||
parameter_tab_->GetSelectedVideoFrameRate().flipped(),
|
||||
parameter_tab_->GetSelectedPreviewFormat(),
|
||||
VideoParams::kInternalChannelCount,
|
||||
parameter_tab_->GetSelectedVideoPixelAspect(),
|
||||
parameter_tab_->GetSelectedVideoInterlacingMode(),
|
||||
parameter_tab_->GetSelectedPreviewResolution());
|
||||
VideoParams(parameter_tab_->get_selected_video_width(),
|
||||
parameter_tab_->get_selected_video_height(),
|
||||
parameter_tab_->get_selected_video_frame_rate().flipped(),
|
||||
parameter_tab_->get_selected_preview_format(),
|
||||
VideoParams::k_internal_channel_count,
|
||||
parameter_tab_->get_selected_video_pixel_aspect(),
|
||||
parameter_tab_->get_selected_video_interlacing_mode(),
|
||||
parameter_tab_->get_selected_preview_resolution());
|
||||
|
||||
AudioParams audio_params =
|
||||
AudioParams(parameter_tab_->GetSelectedAudioSampleRate(),
|
||||
parameter_tab_->GetSelectedAudioChannelLayout(),
|
||||
Sequence::kDefaultSampleFormat);
|
||||
AudioParams(parameter_tab_->get_selected_audio_sample_rate(),
|
||||
parameter_tab_->get_selected_audio_channel_layout(),
|
||||
Sequence::k_default_sample_format);
|
||||
|
||||
if (make_undoable_) {
|
||||
// Make undoable command to change the parameters
|
||||
SequenceParamCommand *param_command = new SequenceParamCommand(
|
||||
sequence_, video_params, audio_params, name_field_->text(),
|
||||
parameter_tab_->GetSelectedPreviewAutoCache());
|
||||
parameter_tab_->get_selected_preview_auto_cache());
|
||||
|
||||
Core::instance()->undo_stack()->push(
|
||||
param_command,
|
||||
tr("Set Sequence Parameters For \"%1\"").arg(sequence_->GetLabel()));
|
||||
tr("Set Sequence Parameters For \"%1\"").arg(sequence_->get_label()));
|
||||
|
||||
} else {
|
||||
// Set sequence values directly with no undo command
|
||||
sequence_->SetVideoParams(video_params);
|
||||
sequence_->SetAudioParams(audio_params);
|
||||
sequence_->SetLabel(name_field_->text());
|
||||
sequence_->SetVideoAutoCacheEnabled(
|
||||
parameter_tab_->GetSelectedPreviewAutoCache());
|
||||
sequence_->set_video_params(video_params);
|
||||
sequence_->set_audio_params(audio_params);
|
||||
sequence_->set_label(name_field_->text());
|
||||
sequence_->set_video_auto_cache_enabled(
|
||||
parameter_tab_->get_selected_preview_auto_cache());
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void SequenceDialog::SetAsDefaultClicked()
|
||||
void SequenceDialog::set_as_default_clicked()
|
||||
{
|
||||
if (QtUtils::MsgBox(
|
||||
if (QtUtils::msg_box(
|
||||
this, QMessageBox::Question, tr("Confirm Set As Default"),
|
||||
tr("Are you sure you want to set the current parameters as defaults?"),
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
// Maybe replace with Preset system
|
||||
OLIVE_CONFIG("DefaultSequenceWidth") =
|
||||
parameter_tab_->GetSelectedVideoWidth();
|
||||
OLIVE_CONFIG("DefaultSequenceHeight") =
|
||||
parameter_tab_->GetSelectedVideoHeight();
|
||||
OLIVE_CONFIG("DefaultSequencePixelAspect") =
|
||||
QVariant::fromValue(parameter_tab_->GetSelectedVideoPixelAspect());
|
||||
OLIVE_CONFIG("DefaultSequenceFrameRate") = QVariant::fromValue(
|
||||
parameter_tab_->GetSelectedVideoFrameRate().flipped());
|
||||
OLIVE_CONFIG("DefaultSequenceInterlacing") =
|
||||
parameter_tab_->GetSelectedVideoInterlacingMode();
|
||||
OLIVE_CONFIG("DefaultSequenceAudioFrequency") =
|
||||
parameter_tab_->GetSelectedAudioSampleRate();
|
||||
OLIVE_CONFIG("DefaultSequenceAudioLayout") = QVariant::fromValue(
|
||||
parameter_tab_->GetSelectedAudioChannelLayout());
|
||||
OAK_CONFIG("DefaultSequenceWidth") =
|
||||
parameter_tab_->get_selected_video_width();
|
||||
OAK_CONFIG("DefaultSequenceHeight") =
|
||||
parameter_tab_->get_selected_video_height();
|
||||
OAK_CONFIG("DefaultSequencePixelAspect") =
|
||||
QVariant::fromValue(parameter_tab_->get_selected_video_pixel_aspect());
|
||||
OAK_CONFIG("DefaultSequenceFrameRate") = QVariant::fromValue(
|
||||
parameter_tab_->get_selected_video_frame_rate().flipped());
|
||||
OAK_CONFIG("DefaultSequenceInterlacing") =
|
||||
parameter_tab_->get_selected_video_interlacing_mode();
|
||||
OAK_CONFIG("DefaultSequenceAudioFrequency") =
|
||||
parameter_tab_->get_selected_audio_sample_rate();
|
||||
OAK_CONFIG("DefaultSequenceAudioLayout") = QVariant::fromValue(
|
||||
parameter_tab_->get_selected_audio_channel_layout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,40 +208,40 @@ SequenceDialog::SequenceParamCommand::SequenceParamCommand(
|
||||
, new_audio_params_(audio_params)
|
||||
, new_name_(name)
|
||||
, new_autocache_(autocache)
|
||||
, old_video_params_(s->GetVideoParams())
|
||||
, old_audio_params_(s->GetAudioParams())
|
||||
, old_name_(s->GetLabel())
|
||||
, old_autocache_(s->IsVideoAutoCacheEnabled())
|
||||
, old_video_params_(s->get_video_params())
|
||||
, old_audio_params_(s->get_audio_params())
|
||||
, old_name_(s->get_label())
|
||||
, old_autocache_(s->is_video_auto_cache_enabled())
|
||||
{
|
||||
}
|
||||
|
||||
Project *SequenceDialog::SequenceParamCommand::GetRelevantProject() const
|
||||
Project *SequenceDialog::SequenceParamCommand::get_relevant_project() const
|
||||
{
|
||||
return sequence_->project();
|
||||
}
|
||||
|
||||
void SequenceDialog::SequenceParamCommand::redo()
|
||||
{
|
||||
if (sequence_->GetVideoParams() != new_video_params_) {
|
||||
sequence_->SetVideoParams(new_video_params_);
|
||||
if (sequence_->get_video_params() != new_video_params_) {
|
||||
sequence_->set_video_params(new_video_params_);
|
||||
}
|
||||
if (sequence_->GetAudioParams() != new_audio_params_) {
|
||||
sequence_->SetAudioParams(new_audio_params_);
|
||||
if (sequence_->get_audio_params() != new_audio_params_) {
|
||||
sequence_->set_audio_params(new_audio_params_);
|
||||
}
|
||||
sequence_->SetLabel(new_name_);
|
||||
sequence_->SetVideoAutoCacheEnabled(new_autocache_);
|
||||
sequence_->set_label(new_name_);
|
||||
sequence_->set_video_auto_cache_enabled(new_autocache_);
|
||||
}
|
||||
|
||||
void SequenceDialog::SequenceParamCommand::undo()
|
||||
{
|
||||
if (sequence_->GetVideoParams() != old_video_params_) {
|
||||
sequence_->SetVideoParams(old_video_params_);
|
||||
if (sequence_->get_video_params() != old_video_params_) {
|
||||
sequence_->set_video_params(old_video_params_);
|
||||
}
|
||||
if (sequence_->GetAudioParams() != old_audio_params_) {
|
||||
sequence_->SetAudioParams(old_audio_params_);
|
||||
if (sequence_->get_audio_params() != old_audio_params_) {
|
||||
sequence_->set_audio_params(old_audio_params_);
|
||||
}
|
||||
sequence_->SetLabel(old_name_);
|
||||
sequence_->SetVideoAutoCacheEnabled(old_autocache_);
|
||||
sequence_->set_label(old_name_);
|
||||
sequence_->set_video_auto_cache_enabled(old_autocache_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SEQUENCEDIALOG_H
|
||||
#define SEQUENCEDIALOG_H
|
||||
#ifndef OAK_SEQUENCEDIALOG_H
|
||||
#define OAK_SEQUENCEDIALOG_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
/**
|
||||
* @brief Used to set the dialog mode of operation (see SequenceDialog())
|
||||
*/
|
||||
enum Type { kNew, kExisting };
|
||||
enum Type { k_new, k_existing };
|
||||
|
||||
/**
|
||||
* @brief SequenceDialog Constructor
|
||||
@@ -68,21 +68,21 @@ public:
|
||||
* @param parent
|
||||
* QWidget parent
|
||||
*/
|
||||
SequenceDialog(Sequence *s, Type t = kExisting, QWidget *parent = nullptr);
|
||||
SequenceDialog(Sequence *s, Type t = k_existing, QWidget *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set whether the parameter changes should be made into an undo command or not
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
void SetUndoable(bool u);
|
||||
void set_undoable(bool u);
|
||||
|
||||
/**
|
||||
* @brief Set whether the name of this Sequence can be edited with this dialog
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
void SetNameIsEditable(bool e);
|
||||
void set_name_is_editable(bool e);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ private:
|
||||
const AudioParams &audio_params,
|
||||
const QString &name, bool autocache);
|
||||
|
||||
virtual Project *GetRelevantProject() const override;
|
||||
virtual Project *get_relevant_project() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
@@ -131,9 +131,9 @@ private:
|
||||
};
|
||||
|
||||
private slots:
|
||||
void SetAsDefaultClicked();
|
||||
void set_as_default_clicked();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SEQUENCEDIALOG_H
|
||||
#endif // OAK_SEQUENCEDIALOG_H
|
||||
|
||||
@@ -40,12 +40,12 @@ SequenceDialogParameterTab::SequenceDialogParameterTab(Sequence *sequence,
|
||||
QGridLayout *video_layout = new QGridLayout(video_group);
|
||||
video_layout->addWidget(new QLabel(tr("Width:")), row, 0);
|
||||
width_slider_ = new IntegerSlider();
|
||||
width_slider_->SetMinimum(0);
|
||||
width_slider_->set_minimum(0);
|
||||
video_layout->addWidget(width_slider_, row, 1);
|
||||
row++;
|
||||
video_layout->addWidget(new QLabel(tr("Height:")), row, 0);
|
||||
height_slider_ = new IntegerSlider();
|
||||
height_slider_->SetMinimum(0);
|
||||
height_slider_->set_minimum(0);
|
||||
video_layout->addWidget(height_slider_, row, 1);
|
||||
row++;
|
||||
video_layout->addWidget(new QLabel(tr("Frame Rate:")), row, 0);
|
||||
@@ -101,64 +101,64 @@ SequenceDialogParameterTab::SequenceDialogParameterTab(Sequence *sequence,
|
||||
layout->addWidget(preview_group);
|
||||
|
||||
// Set values based on input sequence
|
||||
VideoParams vp = sequence->GetVideoParams();
|
||||
AudioParams ap = sequence->GetAudioParams();
|
||||
width_slider_->SetValue(vp.width());
|
||||
height_slider_->SetValue(vp.height());
|
||||
framerate_combo_->SetFrameRate(vp.time_base().flipped());
|
||||
pixelaspect_combo_->SetPixelAspectRatio(vp.pixel_aspect_ratio());
|
||||
interlacing_combo_->SetInterlaceMode(vp.interlacing());
|
||||
preview_resolution_field_->SetDivider(vp.divider());
|
||||
preview_format_field_->SetPixelFormat(vp.format());
|
||||
preview_autocache_field_->setChecked(sequence->IsVideoAutoCacheEnabled());
|
||||
audio_sample_rate_field_->SetSampleRate(ap.sample_rate());
|
||||
audio_channels_field_->SetChannelLayout(ap.channel_layout());
|
||||
VideoParams vp = sequence->get_video_params();
|
||||
AudioParams ap = sequence->get_audio_params();
|
||||
width_slider_->set_value(vp.width());
|
||||
height_slider_->set_value(vp.height());
|
||||
framerate_combo_->set_frame_rate(vp.time_base().flipped());
|
||||
pixelaspect_combo_->set_pixel_aspect_ratio(vp.pixel_aspect_ratio());
|
||||
interlacing_combo_->set_interlace_mode(vp.interlacing());
|
||||
preview_resolution_field_->set_divider(vp.divider());
|
||||
preview_format_field_->set_pixel_format(vp.format());
|
||||
preview_autocache_field_->setChecked(sequence->is_video_auto_cache_enabled());
|
||||
audio_sample_rate_field_->set_sample_rate(ap.sample_rate());
|
||||
audio_channels_field_->set_channel_layout(ap.channel_layout());
|
||||
|
||||
connect(
|
||||
preview_resolution_field_,
|
||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &SequenceDialogParameterTab::UpdatePreviewResolutionLabel);
|
||||
this, &SequenceDialogParameterTab::update_preview_resolution_label);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
QPushButton *save_preset_btn = new QPushButton(tr("Save Preset"));
|
||||
connect(save_preset_btn, &QPushButton::clicked, this,
|
||||
&SequenceDialogParameterTab::SavePresetClicked);
|
||||
&SequenceDialogParameterTab::save_preset_clicked);
|
||||
layout->addWidget(save_preset_btn);
|
||||
|
||||
UpdatePreviewResolutionLabel();
|
||||
update_preview_resolution_label();
|
||||
}
|
||||
|
||||
void SequenceDialogParameterTab::PresetChanged(const SequencePreset &preset)
|
||||
void SequenceDialogParameterTab::preset_changed(const SequencePreset &preset)
|
||||
{
|
||||
width_slider_->SetValue(preset.width());
|
||||
height_slider_->SetValue(preset.height());
|
||||
framerate_combo_->SetFrameRate(preset.frame_rate());
|
||||
pixelaspect_combo_->SetPixelAspectRatio(preset.pixel_aspect());
|
||||
interlacing_combo_->SetInterlaceMode(preset.interlacing());
|
||||
audio_sample_rate_field_->SetSampleRate(preset.sample_rate());
|
||||
audio_channels_field_->SetChannelLayout(preset.channel_layout());
|
||||
preview_resolution_field_->SetDivider(preset.preview_divider());
|
||||
preview_format_field_->SetPixelFormat(preset.preview_format());
|
||||
width_slider_->set_value(preset.width());
|
||||
height_slider_->set_value(preset.height());
|
||||
framerate_combo_->set_frame_rate(preset.frame_rate());
|
||||
pixelaspect_combo_->set_pixel_aspect_ratio(preset.pixel_aspect());
|
||||
interlacing_combo_->set_interlace_mode(preset.interlacing());
|
||||
audio_sample_rate_field_->set_sample_rate(preset.sample_rate());
|
||||
audio_channels_field_->set_channel_layout(preset.channel_layout());
|
||||
preview_resolution_field_->set_divider(preset.preview_divider());
|
||||
preview_format_field_->set_pixel_format(preset.preview_format());
|
||||
preview_autocache_field_->setChecked(preset.preview_autocache());
|
||||
}
|
||||
|
||||
void SequenceDialogParameterTab::SavePresetClicked()
|
||||
void SequenceDialogParameterTab::save_preset_clicked()
|
||||
{
|
||||
emit SaveParametersAsPreset(SequencePreset(
|
||||
QString(), GetSelectedVideoWidth(), GetSelectedVideoHeight(),
|
||||
GetSelectedVideoFrameRate(), GetSelectedVideoPixelAspect(),
|
||||
GetSelectedVideoInterlacingMode(), GetSelectedAudioSampleRate(),
|
||||
GetSelectedAudioChannelLayout(), GetSelectedPreviewResolution(),
|
||||
GetSelectedPreviewFormat(), GetSelectedPreviewAutoCache()));
|
||||
emit save_parameters_as_preset(SequencePreset(
|
||||
QString(), get_selected_video_width(), get_selected_video_height(),
|
||||
get_selected_video_frame_rate(), get_selected_video_pixel_aspect(),
|
||||
get_selected_video_interlacing_mode(), get_selected_audio_sample_rate(),
|
||||
get_selected_audio_channel_layout(), get_selected_preview_resolution(),
|
||||
get_selected_preview_format(), get_selected_preview_auto_cache()));
|
||||
}
|
||||
|
||||
void SequenceDialogParameterTab::UpdatePreviewResolutionLabel()
|
||||
void SequenceDialogParameterTab::update_preview_resolution_label()
|
||||
{
|
||||
VideoParams test_param(GetSelectedVideoWidth(), GetSelectedVideoHeight(),
|
||||
PixelFormat::INVALID,
|
||||
VideoParams::kInternalChannelCount, rational(1),
|
||||
VideoParams::kInterlaceNone,
|
||||
VideoParams test_param(get_selected_video_width(), get_selected_video_height(),
|
||||
PixelFormat::invalid,
|
||||
VideoParams::k_internal_channel_count, Rational(1),
|
||||
VideoParams::k_interlace_none,
|
||||
preview_resolution_field_->currentData().toInt());
|
||||
|
||||
preview_resolution_label_->setText(
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SEQUENCEDIALOGPARAMETERTAB_H
|
||||
#define SEQUENCEDIALOGPARAMETERTAB_H
|
||||
#ifndef OAK_SEQUENCEDIALOGPARAMETERTAB_H
|
||||
#define OAK_SEQUENCEDIALOGPARAMETERTAB_H
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
@@ -37,52 +37,52 @@ class SequenceDialogParameterTab : public QWidget {
|
||||
public:
|
||||
SequenceDialogParameterTab(Sequence *sequence, QWidget *parent = nullptr);
|
||||
|
||||
int GetSelectedVideoWidth() const
|
||||
int get_selected_video_width() const
|
||||
{
|
||||
return width_slider_->GetValue();
|
||||
return width_slider_->get_value();
|
||||
}
|
||||
|
||||
int GetSelectedVideoHeight() const
|
||||
int get_selected_video_height() const
|
||||
{
|
||||
return height_slider_->GetValue();
|
||||
return height_slider_->get_value();
|
||||
}
|
||||
|
||||
rational GetSelectedVideoFrameRate() const
|
||||
Rational get_selected_video_frame_rate() const
|
||||
{
|
||||
return framerate_combo_->GetFrameRate();
|
||||
return framerate_combo_->get_frame_rate();
|
||||
}
|
||||
|
||||
rational GetSelectedVideoPixelAspect() const
|
||||
Rational get_selected_video_pixel_aspect() const
|
||||
{
|
||||
return pixelaspect_combo_->GetPixelAspectRatio();
|
||||
return pixelaspect_combo_->get_pixel_aspect_ratio();
|
||||
}
|
||||
|
||||
VideoParams::Interlacing GetSelectedVideoInterlacingMode() const
|
||||
VideoParams::Interlacing get_selected_video_interlacing_mode() const
|
||||
{
|
||||
return interlacing_combo_->GetInterlaceMode();
|
||||
return interlacing_combo_->get_interlace_mode();
|
||||
}
|
||||
|
||||
int GetSelectedAudioSampleRate() const
|
||||
int get_selected_audio_sample_rate() const
|
||||
{
|
||||
return audio_sample_rate_field_->GetSampleRate();
|
||||
return audio_sample_rate_field_->get_sample_rate();
|
||||
}
|
||||
|
||||
[[nodiscard]] uint64_t GetSelectedAudioChannelLayout() const
|
||||
[[nodiscard]] uint64_t get_selected_audio_channel_layout() const
|
||||
{
|
||||
return audio_channels_field_->GetChannelLayout();
|
||||
return audio_channels_field_->get_channel_layout();
|
||||
}
|
||||
|
||||
int GetSelectedPreviewResolution() const
|
||||
int get_selected_preview_resolution() const
|
||||
{
|
||||
return preview_resolution_field_->GetDivider();
|
||||
return preview_resolution_field_->get_divider();
|
||||
}
|
||||
|
||||
PixelFormat GetSelectedPreviewFormat() const
|
||||
PixelFormat get_selected_preview_format() const
|
||||
{
|
||||
return preview_format_field_->GetPixelFormat();
|
||||
return preview_format_field_->get_pixel_format();
|
||||
}
|
||||
|
||||
bool GetSelectedPreviewAutoCache() const
|
||||
bool get_selected_preview_auto_cache() const
|
||||
{
|
||||
//return preview_autocache_field_->isChecked();
|
||||
// TEMP: Disable sequence auto-cache, wanna see if clip cache supersedes it.
|
||||
@@ -90,10 +90,10 @@ public:
|
||||
}
|
||||
|
||||
public slots:
|
||||
void PresetChanged(const SequencePreset &preset);
|
||||
void preset_changed(const SequencePreset &preset);
|
||||
|
||||
signals:
|
||||
void SaveParametersAsPreset(const SequencePreset &preset);
|
||||
void save_parameters_as_preset(const SequencePreset &preset);
|
||||
|
||||
private:
|
||||
IntegerSlider *width_slider_;
|
||||
@@ -119,11 +119,11 @@ private:
|
||||
QCheckBox *preview_autocache_field_;
|
||||
|
||||
private slots:
|
||||
void SavePresetClicked();
|
||||
void save_preset_clicked();
|
||||
|
||||
void UpdatePreviewResolutionLabel();
|
||||
void update_preview_resolution_label();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SEQUENCEDIALOGPARAMETERTAB_H
|
||||
#endif // OAK_SEQUENCEDIALOGPARAMETERTAB_H
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const int kDataIsPreset = Qt::UserRole;
|
||||
const int kDataPresetIsCustomRole = Qt::UserRole + 1;
|
||||
const int kDataPresetDataRole = Qt::UserRole + 2;
|
||||
const int k_data_is_preset = Qt::UserRole;
|
||||
const int k_data_preset_is_custom_role = Qt::UserRole + 1;
|
||||
const int k_data_preset_data_role = Qt::UserRole + 2;
|
||||
|
||||
SequenceDialogPresetTab::SequenceDialogPresetTab(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
@@ -54,124 +54,124 @@ SequenceDialogPresetTab::SequenceDialogPresetTab(QWidget *parent)
|
||||
preset_tree_->setHeaderLabel(tr("Preset"));
|
||||
preset_tree_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(preset_tree_, &QTreeWidget::customContextMenuRequested, this,
|
||||
&SequenceDialogPresetTab::ShowContextMenu);
|
||||
&SequenceDialogPresetTab::show_context_menu);
|
||||
outer_layout->addWidget(preset_tree_);
|
||||
connect(preset_tree_, &QTreeWidget::currentItemChanged, this,
|
||||
&SequenceDialogPresetTab::SelectedItemChanged);
|
||||
&SequenceDialogPresetTab::selected_item_changed);
|
||||
connect(preset_tree_, &QTreeWidget::itemDoubleClicked, this,
|
||||
&SequenceDialogPresetTab::ItemDoubleClicked);
|
||||
&SequenceDialogPresetTab::item_double_clicked);
|
||||
|
||||
// Add "my presets" folder
|
||||
my_presets_folder_ = CreateFolder(tr("My Presets"));
|
||||
my_presets_folder_ = create_folder(tr("My Presets"));
|
||||
preset_tree_->addTopLevelItem(my_presets_folder_);
|
||||
|
||||
// Add presets
|
||||
preset_tree_->addTopLevelItem(
|
||||
CreateHDPresetFolder(tr("4K UHD"), 3840, 2160, 2));
|
||||
create_hd_preset_folder(tr("4K UHD"), 3840, 2160, 2));
|
||||
preset_tree_->addTopLevelItem(
|
||||
CreateHDPresetFolder(tr("1080p"), 1920, 1080, 1));
|
||||
create_hd_preset_folder(tr("1080p"), 1920, 1080, 1));
|
||||
preset_tree_->addTopLevelItem(
|
||||
CreateHDPresetFolder(tr("720p"), 1280, 720, 1));
|
||||
create_hd_preset_folder(tr("720p"), 1280, 720, 1));
|
||||
|
||||
preset_tree_->addTopLevelItem(
|
||||
CreateSDPresetFolder(tr("NTSC"), 720, 480, rational(30000, 1001),
|
||||
VideoParams::kPixelAspectNTSCStandard,
|
||||
VideoParams::kPixelAspectNTSCWidescreen, 1));
|
||||
create_sd_preset_folder(tr("NTSC"), 720, 480, Rational(30000, 1001),
|
||||
VideoParams::k_pixel_aspect_ntsc_standard,
|
||||
VideoParams::k_pixel_aspect_ntsc_widescreen, 1));
|
||||
preset_tree_->addTopLevelItem(
|
||||
CreateSDPresetFolder(tr("PAL"), 720, 576, rational(25, 1),
|
||||
VideoParams::kPixelAspectPALStandard,
|
||||
VideoParams::kPixelAspectPALWidescreen, 1));
|
||||
create_sd_preset_folder(tr("PAL"), 720, 576, Rational(25, 1),
|
||||
VideoParams::k_pixel_aspect_pal_standard,
|
||||
VideoParams::k_pixel_aspect_pal_widescreen, 1));
|
||||
|
||||
// Load custom presets
|
||||
for (int i = 0; i < GetNumberOfPresets(); i++) {
|
||||
AddCustomItem(my_presets_folder_, GetPreset(i), i);
|
||||
for (int i = 0; i < get_number_of_presets(); i++) {
|
||||
add_custom_item(my_presets_folder_, get_preset(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::SaveParametersAsPreset(SequencePreset preset)
|
||||
void SequenceDialogPresetTab::save_parameters_as_preset(SequencePreset preset)
|
||||
{
|
||||
PresetPtr preset_ptr = std::make_shared<SequencePreset>(preset);
|
||||
|
||||
// If replaced, no need to make another item. If not saved, shared ptr will delete itself
|
||||
if (SavePreset(preset_ptr) == kAppended) {
|
||||
AddCustomItem(my_presets_folder_, preset_ptr, GetNumberOfPresets() - 1);
|
||||
if (save_preset(preset_ptr) == k_appended) {
|
||||
add_custom_item(my_presets_folder_, preset_ptr, get_number_of_presets() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::CreateFolder(const QString &name)
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::create_folder(const QString &name)
|
||||
{
|
||||
QTreeWidgetItem *folder = new QTreeWidgetItem();
|
||||
folder->setText(0, name);
|
||||
folder->setIcon(0, icon::Folder);
|
||||
folder->setIcon(0, icon::folder);
|
||||
return folder;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *
|
||||
SequenceDialogPresetTab::CreateHDPresetFolder(const QString &name, int width,
|
||||
SequenceDialogPresetTab::create_hd_preset_folder(const QString &name, int width,
|
||||
int height, int divider)
|
||||
{
|
||||
const PixelFormat default_format = static_cast<PixelFormat::Format>(
|
||||
OLIVE_CONFIG("OfflinePixelFormat").toInt());
|
||||
OAK_CONFIG("OfflinePixelFormat").toInt());
|
||||
const bool default_autocache = false;
|
||||
QTreeWidgetItem *parent = CreateFolder(name);
|
||||
const uint64_t layout = kChannelLayoutStereo;
|
||||
AddStandardItem(parent,
|
||||
QTreeWidgetItem *parent = create_folder(name);
|
||||
const uint64_t layout = k_channel_layout_stereo;
|
||||
add_standard_item(parent,
|
||||
std::make_shared<SequencePreset>(
|
||||
tr("%1 23.976 FPS").arg(name), width, height,
|
||||
rational(24000, 1001), VideoParams::kPixelAspectSquare,
|
||||
VideoParams::kInterlaceNone, 48000, layout, divider,
|
||||
Rational(24000, 1001), VideoParams::k_pixel_aspect_square,
|
||||
VideoParams::k_interlace_none, 48000, layout, divider,
|
||||
default_format, default_autocache));
|
||||
AddStandardItem(parent,
|
||||
add_standard_item(parent,
|
||||
std::make_shared<SequencePreset>(
|
||||
tr("%1 25 FPS").arg(name), width, height,
|
||||
rational(25, 1), VideoParams::kPixelAspectSquare,
|
||||
VideoParams::kInterlaceNone, 48000, layout, divider,
|
||||
Rational(25, 1), VideoParams::k_pixel_aspect_square,
|
||||
VideoParams::k_interlace_none, 48000, layout, divider,
|
||||
default_format, default_autocache));
|
||||
AddStandardItem(parent,
|
||||
add_standard_item(parent,
|
||||
std::make_shared<SequencePreset>(
|
||||
tr("%1 29.97 FPS").arg(name), width, height,
|
||||
rational(30000, 1001), VideoParams::kPixelAspectSquare,
|
||||
VideoParams::kInterlaceNone, 48000, layout, divider,
|
||||
Rational(30000, 1001), VideoParams::k_pixel_aspect_square,
|
||||
VideoParams::k_interlace_none, 48000, layout, divider,
|
||||
default_format, default_autocache));
|
||||
AddStandardItem(parent,
|
||||
add_standard_item(parent,
|
||||
std::make_shared<SequencePreset>(
|
||||
tr("%1 50 FPS").arg(name), width, height,
|
||||
rational(50, 1), VideoParams::kPixelAspectSquare,
|
||||
VideoParams::kInterlaceNone, 48000, layout, divider,
|
||||
Rational(50, 1), VideoParams::k_pixel_aspect_square,
|
||||
VideoParams::k_interlace_none, 48000, layout, divider,
|
||||
default_format, default_autocache));
|
||||
AddStandardItem(parent,
|
||||
add_standard_item(parent,
|
||||
std::make_shared<SequencePreset>(
|
||||
tr("%1 59.94 FPS").arg(name), width, height,
|
||||
rational(60000, 1001), VideoParams::kPixelAspectSquare,
|
||||
VideoParams::kInterlaceNone, 48000, layout, divider,
|
||||
Rational(60000, 1001), VideoParams::k_pixel_aspect_square,
|
||||
VideoParams::k_interlace_none, 48000, layout, divider,
|
||||
default_format, default_autocache));
|
||||
return parent;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::CreateSDPresetFolder(
|
||||
const QString &name, int width, int height, const rational &frame_rate,
|
||||
const rational &standard_par, const rational &wide_par, int divider)
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::create_sd_preset_folder(
|
||||
const QString &name, int width, int height, const Rational &frame_rate,
|
||||
const Rational &standard_par, const Rational &wide_par, int divider)
|
||||
{
|
||||
const PixelFormat default_format = static_cast<PixelFormat::Format>(
|
||||
OLIVE_CONFIG("OfflinePixelFormat").toInt());
|
||||
OAK_CONFIG("OfflinePixelFormat").toInt());
|
||||
const bool default_autocache = false;
|
||||
QTreeWidgetItem *parent = CreateFolder(name);
|
||||
QTreeWidgetItem *parent = create_folder(name);
|
||||
preset_tree_->addTopLevelItem(parent);
|
||||
const uint64_t layout = kChannelLayoutStereo;
|
||||
AddStandardItem(
|
||||
const uint64_t layout = k_channel_layout_stereo;
|
||||
add_standard_item(
|
||||
parent, std::make_shared<SequencePreset>(
|
||||
tr("%1 Standard").arg(name), width, height, frame_rate,
|
||||
standard_par, VideoParams::kInterlacedBottomFirst, 48000,
|
||||
standard_par, VideoParams::k_interlaced_bottom_first, 48000,
|
||||
layout, divider, default_format, default_autocache));
|
||||
AddStandardItem(
|
||||
add_standard_item(
|
||||
parent, std::make_shared<SequencePreset>(
|
||||
tr("%1 Widescreen").arg(name), width, height, frame_rate,
|
||||
wide_par, VideoParams::kInterlacedBottomFirst, 48000,
|
||||
wide_par, VideoParams::k_interlaced_bottom_first, 48000,
|
||||
layout, divider, default_format, default_autocache));
|
||||
return parent;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::GetSelectedItem()
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::get_selected_item()
|
||||
{
|
||||
QList<QTreeWidgetItem *> selected_items = preset_tree_->selectedItems();
|
||||
|
||||
@@ -182,114 +182,114 @@ QTreeWidgetItem *SequenceDialogPresetTab::GetSelectedItem()
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::GetSelectedCustomPreset()
|
||||
QTreeWidgetItem *SequenceDialogPresetTab::get_selected_custom_preset()
|
||||
{
|
||||
QTreeWidgetItem *sel = GetSelectedItem();
|
||||
QTreeWidgetItem *sel = get_selected_item();
|
||||
|
||||
if (sel && sel->data(0, kDataIsPreset).toBool() &&
|
||||
sel->data(0, kDataPresetIsCustomRole).toBool()) {
|
||||
if (sel && sel->data(0, k_data_is_preset).toBool() &&
|
||||
sel->data(0, k_data_preset_is_custom_role).toBool()) {
|
||||
return sel;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::AddStandardItem(QTreeWidgetItem *folder,
|
||||
void SequenceDialogPresetTab::add_standard_item(QTreeWidgetItem *folder,
|
||||
PresetPtr preset,
|
||||
const QString &description)
|
||||
{
|
||||
int index = default_preset_data_.size();
|
||||
default_preset_data_.append(preset);
|
||||
AddItemInternal(folder, preset, false, index, description);
|
||||
add_item_internal(folder, preset, false, index, description);
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::AddCustomItem(QTreeWidgetItem *folder,
|
||||
void SequenceDialogPresetTab::add_custom_item(QTreeWidgetItem *folder,
|
||||
PresetPtr preset, int index,
|
||||
const QString &description)
|
||||
{
|
||||
AddItemInternal(folder, preset, true, index, description);
|
||||
add_item_internal(folder, preset, true, index, description);
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::AddItemInternal(QTreeWidgetItem *folder,
|
||||
void SequenceDialogPresetTab::add_item_internal(QTreeWidgetItem *folder,
|
||||
PresetPtr preset, bool is_custom,
|
||||
int index,
|
||||
const QString &description)
|
||||
{
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
|
||||
item->setText(0, preset->GetName());
|
||||
item->setIcon(0, icon::Video);
|
||||
item->setText(0, preset->get_name());
|
||||
item->setIcon(0, icon::video);
|
||||
item->setToolTip(0, description);
|
||||
item->setData(0, kDataIsPreset, true);
|
||||
item->setData(0, kDataPresetIsCustomRole, is_custom);
|
||||
item->setData(0, kDataPresetDataRole, index);
|
||||
item->setData(0, k_data_is_preset, true);
|
||||
item->setData(0, k_data_preset_is_custom_role, is_custom);
|
||||
item->setData(0, k_data_preset_data_role, index);
|
||||
|
||||
folder->addChild(item);
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::SelectedItemChanged(QTreeWidgetItem *current,
|
||||
void SequenceDialogPresetTab::selected_item_changed(QTreeWidgetItem *current,
|
||||
QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
|
||||
if (current->data(0, kDataIsPreset).toBool()) {
|
||||
int preset_index = current->data(0, kDataPresetDataRole).toInt();
|
||||
if (current->data(0, k_data_is_preset).toBool()) {
|
||||
int preset_index = current->data(0, k_data_preset_data_role).toInt();
|
||||
|
||||
PresetPtr preset_data =
|
||||
(current->data(0, kDataPresetIsCustomRole).toBool()) ?
|
||||
GetPreset(preset_index) :
|
||||
(current->data(0, k_data_preset_is_custom_role).toBool()) ?
|
||||
get_preset(preset_index) :
|
||||
default_preset_data_.at(preset_index);
|
||||
|
||||
emit PresetChanged(*static_cast<SequencePreset *>(preset_data.get()));
|
||||
emit preset_changed(*static_cast<SequencePreset *>(preset_data.get()));
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::ItemDoubleClicked(QTreeWidgetItem *item,
|
||||
void SequenceDialogPresetTab::item_double_clicked(QTreeWidgetItem *item,
|
||||
int column)
|
||||
{
|
||||
Q_UNUSED(column)
|
||||
|
||||
if (item->data(0, kDataIsPreset).toBool()) {
|
||||
emit PresetAccepted();
|
||||
if (item->data(0, k_data_is_preset).toBool()) {
|
||||
emit preset_accepted();
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::ShowContextMenu()
|
||||
void SequenceDialogPresetTab::show_context_menu()
|
||||
{
|
||||
QTreeWidgetItem *sel = GetSelectedCustomPreset();
|
||||
QTreeWidgetItem *sel = get_selected_custom_preset();
|
||||
|
||||
if (sel) {
|
||||
Menu m(this);
|
||||
|
||||
QAction *delete_action = m.addAction(tr("Delete Preset"));
|
||||
connect(delete_action, &QAction::triggered, this,
|
||||
&SequenceDialogPresetTab::DeleteSelectedPreset);
|
||||
&SequenceDialogPresetTab::delete_selected_preset);
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
}
|
||||
|
||||
void SequenceDialogPresetTab::DeleteSelectedPreset()
|
||||
void SequenceDialogPresetTab::delete_selected_preset()
|
||||
{
|
||||
QTreeWidgetItem *sel = GetSelectedCustomPreset();
|
||||
QTreeWidgetItem *sel = get_selected_custom_preset();
|
||||
|
||||
if (sel) {
|
||||
int preset_index = sel->data(0, kDataPresetDataRole).toInt();
|
||||
int preset_index = sel->data(0, k_data_preset_data_role).toInt();
|
||||
|
||||
// Shift all items whose index was after this preset forward
|
||||
for (int i = 0; i < my_presets_folder_->childCount(); i++) {
|
||||
QTreeWidgetItem *custom_item = my_presets_folder_->child(i);
|
||||
int this_item_index =
|
||||
custom_item->data(0, kDataPresetDataRole).toInt();
|
||||
custom_item->data(0, k_data_preset_data_role).toInt();
|
||||
|
||||
if (this_item_index > preset_index) {
|
||||
custom_item->setData(0, kDataPresetDataRole,
|
||||
custom_item->setData(0, k_data_preset_data_role,
|
||||
this_item_index - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the preset
|
||||
DeletePreset(preset_index);
|
||||
delete_preset(preset_index);
|
||||
|
||||
// Delete the item
|
||||
delete sel;
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SEQUENCEDIALOGPRESETTAB_H
|
||||
#define SEQUENCEDIALOGPRESETTAB_H
|
||||
#ifndef OAK_SEQUENCEDIALOGPRESETTAB_H
|
||||
#define OAK_SEQUENCEDIALOGPRESETTAB_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QTreeWidget>
|
||||
@@ -39,33 +39,33 @@ public:
|
||||
SequenceDialogPresetTab(QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void SaveParametersAsPreset(SequencePreset preset);
|
||||
void save_parameters_as_preset(SequencePreset preset);
|
||||
|
||||
signals:
|
||||
void PresetChanged(const SequencePreset &preset);
|
||||
void preset_changed(const SequencePreset &preset);
|
||||
|
||||
void PresetAccepted();
|
||||
void preset_accepted();
|
||||
|
||||
private:
|
||||
QTreeWidgetItem *CreateFolder(const QString &name);
|
||||
QTreeWidgetItem *create_folder(const QString &name);
|
||||
|
||||
QTreeWidgetItem *CreateHDPresetFolder(const QString &name, int width,
|
||||
QTreeWidgetItem *create_hd_preset_folder(const QString &name, int width,
|
||||
int height, int divider);
|
||||
|
||||
QTreeWidgetItem *CreateSDPresetFolder(
|
||||
const QString &name, int width, int height, const rational &frame_rate,
|
||||
const rational &standard_par, const rational &wide_par, int divider);
|
||||
QTreeWidgetItem *create_sd_preset_folder(
|
||||
const QString &name, int width, int height, const Rational &frame_rate,
|
||||
const Rational &standard_par, const Rational &wide_par, int divider);
|
||||
|
||||
QTreeWidgetItem *GetSelectedItem();
|
||||
QTreeWidgetItem *GetSelectedCustomPreset();
|
||||
QTreeWidgetItem *get_selected_item();
|
||||
QTreeWidgetItem *get_selected_custom_preset();
|
||||
|
||||
void AddStandardItem(QTreeWidgetItem *folder, PresetPtr preset,
|
||||
void add_standard_item(QTreeWidgetItem *folder, PresetPtr preset,
|
||||
const QString &description = QString());
|
||||
|
||||
void AddCustomItem(QTreeWidgetItem *folder, PresetPtr preset, int index,
|
||||
void add_custom_item(QTreeWidgetItem *folder, PresetPtr preset, int index,
|
||||
const QString &description = QString());
|
||||
|
||||
void AddItemInternal(QTreeWidgetItem *folder, PresetPtr preset,
|
||||
void add_item_internal(QTreeWidgetItem *folder, PresetPtr preset,
|
||||
bool is_custom, int index,
|
||||
const QString &description = QString());
|
||||
|
||||
@@ -76,16 +76,16 @@ private:
|
||||
QVector<PresetPtr> default_preset_data_;
|
||||
|
||||
private slots:
|
||||
void SelectedItemChanged(QTreeWidgetItem *current,
|
||||
void selected_item_changed(QTreeWidgetItem *current,
|
||||
QTreeWidgetItem *previous);
|
||||
|
||||
void ItemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
void item_double_clicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
void ShowContextMenu();
|
||||
void show_context_menu();
|
||||
|
||||
void DeleteSelectedPreset();
|
||||
void delete_selected_preset();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SEQUENCEDIALOGPRESETTAB_H
|
||||
#endif // OAK_SEQUENCEDIALOGPRESETTAB_H
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SEQUENCEPARAM_H
|
||||
#define SEQUENCEPARAM_H
|
||||
#ifndef OAK_SEQUENCEPARAM_H
|
||||
#define OAK_SEQUENCEPARAM_H
|
||||
|
||||
#include <olive/core/core.h>
|
||||
#include <QXmlStreamWriter>
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
SequencePreset() = default;
|
||||
|
||||
SequencePreset(const QString &name, int width, int height,
|
||||
const rational &frame_rate, const rational &pixel_aspect,
|
||||
const Rational &frame_rate, const Rational &pixel_aspect,
|
||||
VideoParams::Interlacing interlacing, int sample_rate,
|
||||
uint64_t channel_layout, int preview_divider,
|
||||
PixelFormat preview_format, bool preview_autocache)
|
||||
@@ -52,23 +52,23 @@ public:
|
||||
, preview_format_(preview_format)
|
||||
, preview_autocache_(preview_autocache)
|
||||
{
|
||||
SetName(name);
|
||||
set_name(name);
|
||||
}
|
||||
|
||||
virtual void Load(QXmlStreamReader *reader) override
|
||||
virtual void load(QXmlStreamReader *reader) override
|
||||
{
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("name")) {
|
||||
SetName(reader->readElementText());
|
||||
set_name(reader->readElementText());
|
||||
} else if (reader->name() == QStringLiteral("width")) {
|
||||
width_ = reader->readElementText().toInt();
|
||||
} else if (reader->name() == QStringLiteral("height")) {
|
||||
height_ = reader->readElementText().toInt();
|
||||
} else if (reader->name() == QStringLiteral("framerate")) {
|
||||
frame_rate_ = rational::fromString(
|
||||
frame_rate_ = Rational::from_string(
|
||||
reader->readElementText().toStdString());
|
||||
} else if (reader->name() == QStringLiteral("pixelaspect")) {
|
||||
pixel_aspect_ = rational::fromString(
|
||||
pixel_aspect_ = Rational::from_string(
|
||||
reader->readElementText().toStdString());
|
||||
} else if (reader->name() == QStringLiteral("interlacing") ||
|
||||
reader->name() == QStringLiteral("interlacing_")) {
|
||||
@@ -93,19 +93,19 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Save(QXmlStreamWriter *writer) const override
|
||||
virtual void save(QXmlStreamWriter *writer) const override
|
||||
{
|
||||
writer->writeTextElement(QStringLiteral("name"), GetName());
|
||||
writer->writeTextElement(QStringLiteral("name"), get_name());
|
||||
writer->writeTextElement(QStringLiteral("width"),
|
||||
QString::number(width_));
|
||||
writer->writeTextElement(QStringLiteral("height"),
|
||||
QString::number(height_));
|
||||
writer->writeTextElement(
|
||||
QStringLiteral("framerate"),
|
||||
QString::fromStdString(frame_rate_.toString()));
|
||||
QString::fromStdString(frame_rate_.to_string()));
|
||||
writer->writeTextElement(
|
||||
QStringLiteral("pixelaspect"),
|
||||
QString::fromStdString(pixel_aspect_.toString()));
|
||||
QString::fromStdString(pixel_aspect_.to_string()));
|
||||
writer->writeTextElement(QStringLiteral("interlacing"),
|
||||
QString::number(interlacing_));
|
||||
writer->writeTextElement(QStringLiteral("samplerate"),
|
||||
@@ -130,12 +130,12 @@ public:
|
||||
return height_;
|
||||
}
|
||||
|
||||
const rational &frame_rate() const
|
||||
const Rational &frame_rate() const
|
||||
{
|
||||
return frame_rate_;
|
||||
}
|
||||
|
||||
const rational &pixel_aspect() const
|
||||
const Rational &pixel_aspect() const
|
||||
{
|
||||
return pixel_aspect_;
|
||||
}
|
||||
@@ -173,8 +173,8 @@ public:
|
||||
private:
|
||||
int width_;
|
||||
int height_;
|
||||
rational frame_rate_;
|
||||
rational pixel_aspect_;
|
||||
Rational frame_rate_;
|
||||
Rational pixel_aspect_;
|
||||
VideoParams::Interlacing interlacing_;
|
||||
int sample_rate_;
|
||||
uint64_t channel_layout_;
|
||||
@@ -185,4 +185,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // SEQUENCEPARAM_H
|
||||
#endif // OAK_SEQUENCEPARAM_H
|
||||
|
||||
Reference in New Issue
Block a user