diff --git a/app/core.cpp b/app/core.cpp index 20ad00698..49d67df99 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -233,8 +233,12 @@ void Core::DialogProjectPropertiesShow() void Core::DialogExportShow() { - ExportDialog ed(main_window_); - ed.exec(); + ViewerPanel* latest_viewer = olive::panel_manager->MostRecentlyFocused(); + + if (latest_viewer && latest_viewer->GetConnectedViewer()) { + ExportDialog ed(latest_viewer->GetConnectedViewer(), main_window_); + ed.exec(); + } } void Core::CreateNewFolder() @@ -446,6 +450,18 @@ QList Core::SupportedSampleRates() return sample_rates; } +QList Core::SupportedChannelLayouts() +{ + QList channel_layouts; + + channel_layouts.append(AV_CH_LAYOUT_MONO); + channel_layouts.append(AV_CH_LAYOUT_STEREO); + channel_layouts.append(AV_CH_LAYOUT_5POINT1); + channel_layouts.append(AV_CH_LAYOUT_7POINT1); + + return channel_layouts; +} + QString Core::FrameRateToString(const rational &frame_rate) { return tr("%1 FPS").arg(frame_rate.toDouble()); @@ -455,3 +471,19 @@ QString Core::SampleRateToString(const int &sample_rate) { return tr("%1 Hz").arg(sample_rate); } + +QString Core::ChannelLayoutToString(const uint64_t &layout) +{ + switch (layout) { + case AV_CH_LAYOUT_MONO: + return tr("Mono"); + case AV_CH_LAYOUT_STEREO: + return tr("Stereo"); + case AV_CH_LAYOUT_5POINT1: + return tr("5.1"); + case AV_CH_LAYOUT_7POINT1: + return tr("7.1"); + default: + return tr("Unknown (0x%1)").arg(layout, 1, 16); + } +} diff --git a/app/core.h b/app/core.h index 3eac8062d..fa3b468de 100644 --- a/app/core.h +++ b/app/core.h @@ -139,6 +139,10 @@ public: * @brief Return a list of supported sample rates in integer form */ static QList SupportedSampleRates(); + /** + * @brief Return a list of supported channel layouts as or'd flags + */ + static QList SupportedChannelLayouts(); /** * @brief Convert rational frame rate (i.e. flipped timebase) to a user-friendly string @@ -150,6 +154,11 @@ public: */ static QString SampleRateToString(const int &sample_rate); + /** + * @brief Convert channel layout to a user-friendly string + */ + static QString ChannelLayoutToString(const uint64_t &layout); + public slots: /** * @brief Set the current application-wide tool diff --git a/app/dialog/sequence/sequence.cpp b/app/dialog/sequence/sequence.cpp index 932c4e602..c49aa6c1a 100644 --- a/app/dialog/sequence/sequence.cpp +++ b/app/dialog/sequence/sequence.cpp @@ -114,10 +114,10 @@ SequenceDialog::SequenceDialog(Sequence* s, Type t, QWidget* parent) : } // Set up available channel layouts - AddChannelLayout(AV_CH_LAYOUT_MONO); - AddChannelLayout(AV_CH_LAYOUT_STEREO); - AddChannelLayout(AV_CH_LAYOUT_5POINT1); - AddChannelLayout(AV_CH_LAYOUT_7POINT1); + QList channel_layouts = Core::SupportedChannelLayouts(); + foreach (const uint64_t& layout, channel_layouts) { + audio_channels_field_->addItem(Core::ChannelLayoutToString(layout), layout); + } // Set values based on input sequence video_width_field_->setValue(sequence_->video_params().width()); @@ -189,30 +189,6 @@ void SequenceDialog::accept() QDialog::accept(); } -void SequenceDialog::AddChannelLayout(int layout) -{ - QString layout_name; - - switch (layout) { - case AV_CH_LAYOUT_MONO: - layout_name = tr("Mono"); - break; - case AV_CH_LAYOUT_STEREO: - layout_name = tr("Stereo"); - break; - case AV_CH_LAYOUT_5POINT1: - layout_name = tr("5.1"); - break; - case AV_CH_LAYOUT_7POINT1: - layout_name = tr("7.1"); - break; - default: - layout_name = tr("Unknown (0x%1)").arg(layout, 1, 16); - } - - audio_channels_field_->addItem(layout_name, layout); -} - SequenceDialog::SequenceParamCommand::SequenceParamCommand(Sequence* s, const VideoParams& video_params, const AudioParams& audio_params, diff --git a/app/dialog/sequence/sequence.h b/app/dialog/sequence/sequence.h index 75b2da436..44c49ad0a 100644 --- a/app/dialog/sequence/sequence.h +++ b/app/dialog/sequence/sequence.h @@ -82,11 +82,6 @@ public slots: virtual void accept() override; private: - /** - * @brief Internal function for adding a selectable channel layout - */ - void AddChannelLayout(int layout); - Sequence* sequence_; bool make_undoable_;