filled out various further UI functions for the export dialog

This commit is contained in:
itsmattkc
2019-12-16 03:03:40 +11:00
parent abf579cb84
commit 4bd8c0c850
6 changed files with 135 additions and 24 deletions
+37 -7
View File
@@ -11,8 +11,9 @@
#include "ui/icons/icons.h"
ExportDialog::ExportDialog(QWidget *parent) :
ExportDialog::ExportDialog(ViewerOutput *viewer_node, QWidget *parent) :
QDialog(parent),
viewer_node_(viewer_node),
previously_selected_format_(0)
{
QHBoxLayout* layout = new QHBoxLayout(this);
@@ -124,6 +125,17 @@ ExportDialog::ExportDialog(QWidget *parent) :
// Set defaults
format_combobox_->setCurrentIndex(kFormatMPEG4);
video_tab_->width_slider()->SetValue(viewer_node_->video_params().width());
video_tab_->height_slider()->SetValue(viewer_node_->video_params().height());
video_tab_->set_frame_rate(viewer_node_->video_params().time_base().flipped());
audio_tab_->set_sample_rate(viewer_node_->audio_params().sample_rate());
audio_tab_->set_channel_layout(viewer_node_->audio_params().channel_layout());
video_aspect_ratio_ = static_cast<double>(viewer_node_->video_params().width()) / static_cast<double>(viewer_node_->video_params().height());
connect(video_tab_->width_slider(), SIGNAL(ValueChanged(int64_t)), this, SLOT(ResolutionChanged()));
connect(video_tab_->height_slider(), SIGNAL(ValueChanged(int64_t)), this, SLOT(ResolutionChanged()));
connect(video_tab_->maintain_aspect_checkbox(), SIGNAL(toggled(bool)), this, SLOT(ResolutionChanged()));
}
void ExportDialog::BrowseFilename()
@@ -171,6 +183,24 @@ void ExportDialog::FormatChanged(int index)
}
}
void ExportDialog::ResolutionChanged()
{
if (video_tab_->maintain_aspect_checkbox()->isChecked()) {
// Keep aspect ratio maintained
if (sender() == video_tab_->height_slider()) {
video_tab_->width_slider()->SetValue(qRound(static_cast<double>(video_tab_->height_slider()->GetValue()) * video_aspect_ratio_));
} else {
// This catches both the width slider changing and the maintain aspect ratio checkbox changing
video_tab_->height_slider()->SetValue(qRound(static_cast<double>(video_tab_->width_slider()->GetValue()) / video_aspect_ratio_));
}
} else {
double current_ratio = static_cast<double>(video_tab_->width_slider()->GetValue()) / static_cast<double>(video_tab_->height_slider()->GetValue());
// Enable scaling method combobox only if width/height are not equal to sequence size
video_tab_->scaling_method_combobox()->setEnabled(!qFuzzyCompare(current_ratio, video_aspect_ratio_));
}
}
void ExportDialog::SetUpFormats()
{
// Set up codecs
@@ -206,8 +236,8 @@ void ExportDialog::SetUpFormats()
case kCodecAAC:
codecs_.append(ExportCodec(tr("AAC"), "aac"));
break;
case kCodecPCMS16LE:
codecs_.append(ExportCodec(tr("PCM (Signed 16-Bit Little Endian)"), "pcms16le"));
case kCodecPCM:
codecs_.append(ExportCodec(tr("PCM (Uncompressed)"), "pcm"));
break;
case kCodecCount:
break;
@@ -218,19 +248,19 @@ void ExportDialog::SetUpFormats()
for (int i=0;i<kFormatCount;i++) {
switch (static_cast<Format>(i)) {
case kFormatDNxHD:
formats_.append(ExportFormat(tr("DNxHD"), "mxf", {kCodecDNxHD}, {kCodecPCMS16LE}));
formats_.append(ExportFormat(tr("DNxHD"), "mxf", {kCodecDNxHD}, {kCodecPCM}));
break;
case kFormatMatroska:
formats_.append(ExportFormat(tr("Matroska Video"), "mkv", {kCodecH264, kCodecH265}, {kCodecAAC, kCodecMP2, kCodecMP3, kCodecPCMS16LE}));
formats_.append(ExportFormat(tr("Matroska Video"), "mkv", {kCodecH264, kCodecH265}, {kCodecAAC, kCodecMP2, kCodecMP3, kCodecPCM}));
break;
case kFormatMPEG4:
formats_.append(ExportFormat(tr("MPEG-4 Video"), "mp4", {kCodecH264, kCodecH265}, {kCodecAAC, kCodecMP2, kCodecMP3, kCodecPCMS16LE}));
formats_.append(ExportFormat(tr("MPEG-4 Video"), "mp4", {kCodecH264, kCodecH265}, {kCodecAAC, kCodecMP2, kCodecMP3, kCodecPCM}));
break;
case kFormatOpenEXR:
formats_.append(ExportFormat(tr("OpenEXR"), "exr", {kCodecOpenEXR}, {}));
break;
case kFormatQuickTime:
formats_.append(ExportFormat(tr("QuickTime"), "mov", {kCodecH264, kCodecH265, kCodecProRes}, {kCodecAAC, kCodecMP2, kCodecMP3, kCodecPCMS16LE}));
formats_.append(ExportFormat(tr("QuickTime"), "mov", {kCodecH264, kCodecH265, kCodecProRes}, {kCodecAAC, kCodecMP2, kCodecMP3, kCodecPCM}));
break;
case kFormatPNG:
formats_.append(ExportFormat(tr("PNG"), "png", {kCodecPNG}, {}));
+8 -2
View File
@@ -15,13 +15,15 @@ class ExportDialog : public QDialog
{
Q_OBJECT
public:
ExportDialog(QWidget* parent = nullptr);
ExportDialog(ViewerOutput* viewer_node, QWidget* parent = nullptr);
private:
void SetUpFormats();
void LoadPresets();
void SetDefaultFilename();
ViewerOutput* viewer_node_;
QList<ExportFormat> formats_;
int previously_selected_format_;
@@ -34,6 +36,8 @@ private:
ExportVideoTab* video_tab_;
ExportAudioTab* audio_tab_;
double video_aspect_ratio_;
enum Format {
kFormatDNxHD,
kFormatMatroska,
@@ -58,7 +62,7 @@ private:
kCodecMP2,
kCodecMP3,
kCodecAAC,
kCodecPCMS16LE,
kCodecPCM,
kCodecCount
};
@@ -68,6 +72,8 @@ private slots:
void FormatChanged(int index);
void ResolutionChanged();
};
#endif // EXPORTDIALOG_H
+19 -3
View File
@@ -25,8 +25,8 @@ ExportAudioTab::ExportAudioTab(QWidget* parent) :
layout->addWidget(new QLabel(tr("Sample Rate:")), row, 0);
sample_rate_combobox_ = new QComboBox();
QList<int> sample_rates = Core::SupportedSampleRates();
foreach (const int& sr, sample_rates) {
sample_rates_ = Core::SupportedSampleRates();
foreach (const int& sr, sample_rates_) {
sample_rate_combobox_->addItem(Core::SampleRateToString(sr));
}
layout->addWidget(sample_rate_combobox_, row, 1);
@@ -34,7 +34,13 @@ ExportAudioTab::ExportAudioTab(QWidget* parent) :
row++;
layout->addWidget(new QLabel(tr("Channel Layout:")), row, 0);
layout->addWidget(new QComboBox(), row, 1);
channel_layout_combobox_ = new QComboBox();
channel_layouts_ = Core::SupportedChannelLayouts();
foreach (const uint64_t& layout, channel_layouts_) {
channel_layout_combobox_->addItem(Core::ChannelLayoutToString(layout));
}
layout->addWidget(channel_layout_combobox_, row, 1);
row++;
@@ -53,3 +59,13 @@ QComboBox *ExportAudioTab::sample_rate_combobox() const
{
return sample_rate_combobox_;
}
void ExportAudioTab::set_sample_rate(int rate)
{
sample_rate_combobox_->setCurrentIndex(sample_rates_.indexOf(rate));
}
void ExportAudioTab::set_channel_layout(uint64_t layout)
{
channel_layout_combobox_->setCurrentIndex(channel_layouts_.indexOf(layout));
}
+7
View File
@@ -12,9 +12,16 @@ public:
QComboBox* codec_combobox() const;
QComboBox* sample_rate_combobox() const;
void set_sample_rate(int rate);
void set_channel_layout(uint64_t layout);
private:
QComboBox* codec_combobox_;
QComboBox* sample_rate_combobox_;
QComboBox* channel_layout_combobox_;
QList<int> sample_rates_;
QList<uint64_t> channel_layouts_;
};
#endif // EXPORTAUDIOTAB_H
+44 -12
View File
@@ -6,8 +6,6 @@
#include <QLabel>
#include "core.h"
#include "common/rational.h"
#include "widget/slider/integerslider.h"
ExportVideoTab::ExportVideoTab(QWidget *parent) :
QWidget(parent)
@@ -16,10 +14,10 @@ ExportVideoTab::ExportVideoTab(QWidget *parent) :
outer_layout->addWidget(SetupResolutionSection());
outer_layout->addWidget(SetupColorSection());
outer_layout->addWidget(SetupCodecSection());
outer_layout->addWidget(SetupColorSection());
outer_layout->addStretch();
}
@@ -28,6 +26,31 @@ QComboBox *ExportVideoTab::codec_combobox() const
return codec_combobox_;
}
IntegerSlider *ExportVideoTab::width_slider() const
{
return width_slider_;
}
IntegerSlider *ExportVideoTab::height_slider() const
{
return height_slider_;
}
QCheckBox *ExportVideoTab::maintain_aspect_checkbox() const
{
return maintain_aspect_checkbox_;
}
QComboBox *ExportVideoTab::scaling_method_combobox() const
{
return scaling_method_combobox_;
}
void ExportVideoTab::set_frame_rate(const rational &frame_rate)
{
frame_rate_combobox_->setCurrentIndex(frame_rates_.indexOf(frame_rate));
}
QWidget* ExportVideoTab::SetupResolutionSection()
{
int row = 0;
@@ -39,33 +62,42 @@ QWidget* ExportVideoTab::SetupResolutionSection()
layout->addWidget(new QLabel(tr("Width:")), row, 0);
IntegerSlider* width_slider = new IntegerSlider();
layout->addWidget(width_slider, row, 1);
width_slider_ = new IntegerSlider();
layout->addWidget(width_slider_, row, 1);
row++;
layout->addWidget(new QLabel(tr("Height:")), row, 0);
IntegerSlider* height_slider = new IntegerSlider();
layout->addWidget(height_slider, row, 1);
height_slider_ = new IntegerSlider();
layout->addWidget(height_slider_, row, 1);
row++;
layout->addWidget(new QLabel(tr("Maintain Aspect Ratio:")), row, 0);
layout->addWidget(new QCheckBox(), row, 1);
maintain_aspect_checkbox_ = new QCheckBox();
maintain_aspect_checkbox_->setChecked(true);
layout->addWidget(maintain_aspect_checkbox_, row, 1);
row++;
layout->addWidget(new QLabel(tr("Scaling Method:")), row, 0);
layout->addWidget(new QComboBox(), row, 1);
scaling_method_combobox_ = new QComboBox();
scaling_method_combobox_->setEnabled(false);
scaling_method_combobox_->addItem(tr("Fit"));
scaling_method_combobox_->addItem(tr("Stretch"));
scaling_method_combobox_->addItem(tr("Crop"));
layout->addWidget(scaling_method_combobox_, row, 1);
row++;
layout->addWidget(new QLabel(tr("Frame Rate:")), row, 0);
frame_rate_combobox_ = new QComboBox();
QList<rational> frame_rates = Core::SupportedFrameRates();
foreach (const rational& fr, frame_rates) {
frame_rates_ = Core::SupportedFrameRates();
foreach (const rational& fr, frame_rates_) {
frame_rate_combobox_->addItem(Core::FrameRateToString(fr));
}
+20
View File
@@ -1,16 +1,28 @@
#ifndef EXPORTVIDEOTAB_H
#define EXPORTVIDEOTAB_H
#include <QCheckBox>
#include <QComboBox>
#include <QWidget>
#include "common/rational.h"
#include "widget/slider/integerslider.h"
class ExportVideoTab : public QWidget
{
Q_OBJECT
public:
ExportVideoTab(QWidget* parent = nullptr);
QComboBox* codec_combobox() const;
IntegerSlider* width_slider() const;
IntegerSlider* height_slider() const;
QCheckBox* maintain_aspect_checkbox() const;
QComboBox* scaling_method_combobox() const;
void set_frame_rate(const rational& frame_rate);
private:
QWidget* SetupResolutionSection();
QWidget* SetupColorSection();
@@ -18,6 +30,14 @@ private:
QComboBox* codec_combobox_;
QComboBox* frame_rate_combobox_;
QCheckBox* maintain_aspect_checkbox_;
QComboBox* scaling_method_combobox_;
IntegerSlider* width_slider_;
IntegerSlider* height_slider_;
QList<rational> frame_rates_;
};
#endif // EXPORTVIDEOTAB_H