merged with master

This commit is contained in:
itsmattkc
2019-03-21 17:22:36 +11:00
46 changed files with 943 additions and 320 deletions
+38 -21
View File
@@ -20,6 +20,10 @@
#include "exportdialog.h"
extern "C" {
#include <libavformat/avformat.h>
}
#include <QOpenGLWidget>
#include <QFileDialog>
#include <QThread>
@@ -39,10 +43,6 @@
#include "rendering/exportthread.h"
#include "ui/mainwindow.h"
extern "C" {
#include <libavformat/avformat.h>
}
enum ExportFormats {
FORMAT_3GPP,
FORMAT_AIFF,
@@ -118,9 +118,6 @@ ExportDialog::ExportDialog(QWidget *parent) :
vcodec_params.threads = 0;
}
ExportDialog::~ExportDialog()
{}
void ExportDialog::add_codec_to_combobox(QComboBox* box, enum AVCodecID codec) {
QString codec_name;
@@ -334,30 +331,53 @@ void ExportDialog::format_changed(int index) {
}
void ExportDialog::render_thread_finished() {
if (progressBar->value() < 100 && !cancelled) {
// Determine if the export succeeded
bool succeeded = (progressBar->value() == 100);
// If it failed and we didn't cancel it, it must have errored out. Show an error message.
if (!succeeded && !et->WasInterrupted()) {
QMessageBox::critical(
this,
tr("Export Failed"),
tr("Export failed - %1").arg(export_error),
tr("Export failed - %1").arg(et->GetError()),
QMessageBox::Ok
);
}
// Clear audio buffer
clear_audio_ibuffer();
// Re-enable/disable UI widgets based on the rendering state
prep_ui_for_render(false);
// Move OpenGL context back to the sequence viewer
panel_sequence_viewer->viewer_widget->makeCurrent();
panel_sequence_viewer->viewer_widget->initializeGL();
// Update the application UI
update_ui(false);
// Disconnect cancel button from export thread
disconnect(renderCancel, SIGNAL(clicked(bool)), et, SLOT(Interrupt()));
// Free the export thread
et->deleteLater();
if (progressBar->value() == 100) accept();
// If the export succeeded, close the dialog
if (succeeded) {
accept();
}
}
void ExportDialog::prep_ui_for_render(bool r) {
export_button->setEnabled(!r);
cancel_button->setEnabled(!r);
videoGroupbox->setEnabled(!r);
audioGroupbox->setEnabled(!r);
renderCancel->setEnabled(r);
}
void ExportDialog::export_action() {
void ExportDialog::StartExport() {
if (widthSpinbox->value()%2 == 1 || heightSpinbox->value()%2 == 1) {
QMessageBox::critical(
this,
@@ -515,6 +535,7 @@ void ExportDialog::export_action() {
}
}
// Set up export parameters to send to the ExportThread
ExportParams params;
params.filename = filename;
params.video_enabled = videoGroupbox->isChecked();
@@ -540,11 +561,15 @@ void ExportDialog::export_action() {
params.end_frame = qMin(olive::ActiveSequence->workarea_out, params.end_frame);
}
// Create export thread
et = new ExportThread(params, vcodec_params, this);
// Connect export thread signals/slots
connect(et, SIGNAL(finished()), this, SLOT(render_thread_finished()));
connect(et, SIGNAL(progress_changed(int, qint64)), this, SLOT(update_progress_bar(int, qint64)));
connect(et, SIGNAL(ProgressChanged(int, qint64)), this, SLOT(update_progress_bar(int, qint64)));
connect(renderCancel, SIGNAL(clicked(bool)), et, SLOT(Interrupt()));
// Close all currently open clips
close_active_clips(olive::ActiveSequence.get());
olive::Global->set_rendering_state(true);
@@ -553,8 +578,6 @@ void ExportDialog::export_action() {
prep_ui_for_render(true);
cancelled = false;
total_export_time_start = QDateTime::currentMSecsSinceEpoch();
et->start();
@@ -587,11 +610,6 @@ void ExportDialog::update_progress_bar(int value, qint64 remaining_ms) {
progressBar->setValue(value);
}
void ExportDialog::cancel_render() {
et->continueEncode = false;
cancelled = true;
}
void ExportDialog::vcodec_changed(int index) {
compressionTypeCombobox->clear();
@@ -755,7 +773,6 @@ void ExportDialog::setup_ui() {
renderCancel = new QPushButton(this);
renderCancel->setIcon(QIcon(":/icons/error.svg"));
renderCancel->setEnabled(false);
connect(renderCancel, SIGNAL(clicked(bool)), this, SLOT(cancel_render()));
progressLayout->addWidget(renderCancel);
verticalLayout->addLayout(progressLayout);
@@ -765,7 +782,7 @@ void ExportDialog::setup_ui() {
export_button = new QPushButton(this);
export_button->setText("Export");
connect(export_button, SIGNAL(clicked(bool)), this, SLOT(export_action()));
connect(export_button, SIGNAL(clicked(bool)), this, SLOT(StartExport()));
buttonLayout->addWidget(export_button);