moved load project functions from project panel to global
This commit is contained in:
@@ -33,7 +33,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
AdvancedVideoDialog::AdvancedVideoDialog(QWidget *parent,
|
||||
int encoding_codec,
|
||||
AVCodecID encoding_codec,
|
||||
VideoCodecParams &iparams) :
|
||||
QDialog(parent),
|
||||
params_(iparams)
|
||||
|
||||
@@ -36,11 +36,29 @@
|
||||
class AdvancedVideoDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief AdvancedVideoDialog Constructor
|
||||
*
|
||||
* @param parent
|
||||
*
|
||||
* QWidget parent. Usually ExportDialog.
|
||||
*
|
||||
* @param encoding_codec
|
||||
*
|
||||
* The AVCodecID of the selected export codec.
|
||||
*
|
||||
* @param iparams
|
||||
*
|
||||
* A VideoCodecParams struct containing the extra codec data.
|
||||
*/
|
||||
AdvancedVideoDialog(QWidget* parent,
|
||||
int encoding_codec,
|
||||
AVCodecID encoding_codec,
|
||||
VideoCodecParams& iparams);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Overrided accept for saving the UI data into the provided VideoCodecParams struct.
|
||||
*/
|
||||
virtual void accept() override;
|
||||
private:
|
||||
/**
|
||||
|
||||
+11
-11
@@ -330,16 +330,16 @@ void ExportDialog::format_changed(int index) {
|
||||
audioGroupbox->setEnabled(audio_enabled);
|
||||
}
|
||||
|
||||
void ExportDialog::render_thread_finished() {
|
||||
void ExportDialog::export_thread_finished() {
|
||||
// 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()) {
|
||||
if (!succeeded && !export_thread_->WasInterrupted()) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Export Failed"),
|
||||
tr("Export failed - %1").arg(et->GetError()),
|
||||
tr("Export failed - %1").arg(export_thread_->GetError()),
|
||||
QMessageBox::Ok
|
||||
);
|
||||
}
|
||||
@@ -358,10 +358,10 @@ void ExportDialog::render_thread_finished() {
|
||||
update_ui(false);
|
||||
|
||||
// Disconnect cancel button from export thread
|
||||
disconnect(renderCancel, SIGNAL(clicked(bool)), et, SLOT(Interrupt()));
|
||||
disconnect(renderCancel, SIGNAL(clicked(bool)), export_thread_, SLOT(Interrupt()));
|
||||
|
||||
// Free the export thread
|
||||
et->deleteLater();
|
||||
export_thread_->deleteLater();
|
||||
|
||||
// If the export succeeded, close the dialog
|
||||
if (succeeded) {
|
||||
@@ -562,12 +562,12 @@ void ExportDialog::StartExport() {
|
||||
}
|
||||
|
||||
// Create export thread
|
||||
et = new ExportThread(params, vcodec_params, this);
|
||||
export_thread_ = new ExportThread(params, vcodec_params, this);
|
||||
|
||||
// Connect export thread signals/slots
|
||||
connect(et, SIGNAL(finished()), this, SLOT(render_thread_finished()));
|
||||
connect(et, SIGNAL(ProgressChanged(int, qint64)), this, SLOT(update_progress_bar(int, qint64)));
|
||||
connect(renderCancel, SIGNAL(clicked(bool)), et, SLOT(Interrupt()));
|
||||
connect(export_thread_, SIGNAL(finished()), this, SLOT(export_thread_finished()));
|
||||
connect(export_thread_, SIGNAL(ProgressChanged(int, qint64)), this, SLOT(update_progress_bar(int, qint64)));
|
||||
connect(renderCancel, SIGNAL(clicked(bool)), export_thread_, SLOT(Interrupt()));
|
||||
|
||||
// Close all currently open clips
|
||||
close_active_clips(olive::ActiveSequence.get());
|
||||
@@ -580,7 +580,7 @@ void ExportDialog::StartExport() {
|
||||
|
||||
total_export_time_start = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
et->start();
|
||||
export_thread_->start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +667,7 @@ void ExportDialog::comp_type_changed(int) {
|
||||
}
|
||||
|
||||
void ExportDialog::open_advanced_video_dialog() {
|
||||
AdvancedVideoDialog avd(this, vcodecCombobox->currentData().toInt(), vcodec_params);
|
||||
AdvancedVideoDialog avd(this, static_cast<AVCodecID>(vcodecCombobox->currentData().toInt()), vcodec_params);
|
||||
avd.exec();
|
||||
}
|
||||
|
||||
|
||||
+167
-4
@@ -68,42 +68,205 @@ private slots:
|
||||
* Asks the user for the file to save to.
|
||||
*/
|
||||
void StartExport();
|
||||
|
||||
/**
|
||||
* @brief Slot for the export thread to update the progress bar's value
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* An value between 0 - 100. A percentage of the Sequence that has been exported so far.
|
||||
*
|
||||
* @param remaining_ms
|
||||
*
|
||||
* The estimated time in milliseconds that it will take to complete the rest of the Sequence.
|
||||
*/
|
||||
void update_progress_bar(int value, qint64 remaining_ms);
|
||||
void render_thread_finished();
|
||||
|
||||
/**
|
||||
* @brief Slot for the export thread completing (both succeeding and failing)
|
||||
*
|
||||
* Runs whenever the thread has finished. Determines whether the thread succeeded or not (and shows an error message
|
||||
* if not), cleans up the ExportThread object, sets the UI state back to normal.
|
||||
*
|
||||
* Connect to ExportThread::finished().
|
||||
*/
|
||||
void export_thread_finished();
|
||||
|
||||
/**
|
||||
* @brief Slot for when the video codec changes
|
||||
*
|
||||
* Some video codecs require different settings. In the case of that, this function sorts through those.
|
||||
*
|
||||
* @param index
|
||||
*
|
||||
* Current vcodecCombobox index - its item data contains the AVCodecID.
|
||||
*/
|
||||
void vcodec_changed(int index);
|
||||
|
||||
/**
|
||||
* @brief Slot for when the compression type changes
|
||||
*
|
||||
* Different UI objects should be displayed for different compression types.
|
||||
*
|
||||
* @param index
|
||||
*
|
||||
* Unused.
|
||||
*/
|
||||
void comp_type_changed(int index);
|
||||
|
||||
/**
|
||||
* @brief Slot to open the Advanced Video Dialog
|
||||
*
|
||||
* Opens a dialog for setting more advanced video settings and passes a reference to vcodec_params to it.
|
||||
*/
|
||||
void open_advanced_video_dialog();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Function to create UI objects.
|
||||
*/
|
||||
void setup_ui();
|
||||
|
||||
/**
|
||||
* @brief Enables/disables certain UI objects based on the exporting state.
|
||||
*
|
||||
* Some UI controls don't need to be set while exporting. This function enables/disables them appropriately.
|
||||
*
|
||||
* @param r
|
||||
*
|
||||
* TRUE if we're exporting, FALSE if we finished.
|
||||
*/
|
||||
void prep_ui_for_render(bool r);
|
||||
|
||||
QVector<QString> format_strings;
|
||||
ExportThread* et;
|
||||
|
||||
/**
|
||||
* @brief Retrieves the human-readable name of an AVCodecID and adds it to a QComboBox
|
||||
*
|
||||
* Also sets that item's data to the AVCodecID so it can be retrieved directly from the QComboBox.
|
||||
*
|
||||
* @param box
|
||||
*
|
||||
* The QComboBox to add the item to.
|
||||
*
|
||||
* @param codec
|
||||
*
|
||||
* The codec to add to the QComboBox.
|
||||
*/
|
||||
void add_codec_to_combobox(QComboBox* box, enum AVCodecID codec);
|
||||
|
||||
/**
|
||||
* @brief Internal array of human-readable names corresponding to enum ExportFormats
|
||||
*/
|
||||
QVector<QString> format_strings;
|
||||
|
||||
/**
|
||||
* @brief Pointer to an ExportThread
|
||||
*
|
||||
* Set when exporting starts, and deleted by export_thread_finished() when the thread is complete.
|
||||
*/
|
||||
ExportThread* export_thread_;
|
||||
|
||||
/**
|
||||
* @brief Struct for advanced video codec parameters.
|
||||
*
|
||||
* More advanced video encoding parameters to be sent to the ExportThread. These variables are not directly editable
|
||||
* in this dialog, instead calling open_advanced_video_dialog() will open an AdvancedVideoDialog for setting these
|
||||
* values directly. vcodec_changed() should also set these to the defaults for that codec where appropriate.
|
||||
*/
|
||||
VideoCodecParams vcodec_params;
|
||||
|
||||
/**
|
||||
* @brief ComboBox for selecting the time range of the Sequence to export
|
||||
*/
|
||||
QComboBox* rangeCombobox;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for the exported video's width
|
||||
*/
|
||||
QSpinBox* widthSpinbox;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for the exported video's bitrate
|
||||
*/
|
||||
QDoubleSpinBox* videobitrateSpinbox;
|
||||
|
||||
/**
|
||||
* @brief Label for the exported video's bitrate - changes depending on the compression type
|
||||
*/
|
||||
QLabel* videoBitrateLabel;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for the exported video's frame rate
|
||||
*/
|
||||
QDoubleSpinBox* framerateSpinbox;
|
||||
|
||||
/**
|
||||
* @brief ComboBox for the exported video codec
|
||||
*/
|
||||
QComboBox* vcodecCombobox;
|
||||
|
||||
/**
|
||||
* @brief ComboBox for the exported audio's codec
|
||||
*/
|
||||
QComboBox* acodecCombobox;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for the exported audio's sample rate
|
||||
*/
|
||||
QSpinBox* samplingRateSpinbox;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for the exported audio's bitrate
|
||||
*/
|
||||
QSpinBox* audiobitrateSpinbox;
|
||||
|
||||
/**
|
||||
* @brief Progress bar for visually showing the export progress
|
||||
*/
|
||||
QProgressBar* progressBar;
|
||||
|
||||
/**
|
||||
* @brief ComboBox for the exported video's format
|
||||
*/
|
||||
QComboBox* formatCombobox;
|
||||
|
||||
/**
|
||||
* @brief SpinBox for the exported video's height
|
||||
*/
|
||||
QSpinBox* heightSpinbox;
|
||||
|
||||
/**
|
||||
* @brief Export button to trigger the start of an export
|
||||
*/
|
||||
QPushButton* export_button;
|
||||
|
||||
/**
|
||||
* @brief Dialog cancel button to close this dialog
|
||||
*/
|
||||
QPushButton* cancel_button;
|
||||
|
||||
/**
|
||||
* @brief Cancel button to abort the export before completion
|
||||
*/
|
||||
QPushButton* renderCancel;
|
||||
|
||||
/**
|
||||
* @brief GroupBox containing all video-related UI objects
|
||||
*/
|
||||
QGroupBox* videoGroupbox;
|
||||
|
||||
/**
|
||||
* @brief GroupBox containing all audio-related UI objects
|
||||
*/
|
||||
QGroupBox* audioGroupbox;
|
||||
|
||||
/**
|
||||
* @brief ComboBox for the exported video compression type
|
||||
*/
|
||||
QComboBox* compressionTypeCombobox;
|
||||
|
||||
/**
|
||||
* @brief Time value set when exporting begins to determine the total duration of the export
|
||||
*/
|
||||
qint64 total_export_time_start;
|
||||
};
|
||||
|
||||
|
||||
+5
-23
@@ -31,7 +31,7 @@
|
||||
#include "ui/sourcetable.h"
|
||||
#include "ui/mainwindow.h"
|
||||
|
||||
LoadDialog::LoadDialog(QWidget *parent, const QString& fn, bool autorecovery, bool clear) :
|
||||
LoadDialog::LoadDialog(QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("Loading..."));
|
||||
@@ -46,7 +46,7 @@ LoadDialog::LoadDialog(QWidget *parent, const QString& fn, bool autorecovery, bo
|
||||
layout->addWidget(bar);
|
||||
|
||||
cancel_button = new QPushButton(tr("Cancel"), this);
|
||||
connect(cancel_button, SIGNAL(clicked(bool)), this, SLOT(cancel()));
|
||||
connect(cancel_button, SIGNAL(clicked(bool)), this, SIGNAL(cancel()));
|
||||
|
||||
hboxLayout = new QHBoxLayout();
|
||||
hboxLayout->addStretch();
|
||||
@@ -54,27 +54,9 @@ LoadDialog::LoadDialog(QWidget *parent, const QString& fn, bool autorecovery, bo
|
||||
hboxLayout->addStretch();
|
||||
|
||||
layout->addLayout(hboxLayout);
|
||||
|
||||
update();
|
||||
|
||||
lt = new LoadThread(fn, autorecovery, clear);
|
||||
QObject::connect(lt, SIGNAL(success()), this, SLOT(thread_done()));
|
||||
QObject::connect(lt, SIGNAL(error()), this, SLOT(die()));
|
||||
QObject::connect(lt, SIGNAL(report_progress(int)), bar, SLOT(setValue(int)));
|
||||
lt->start();
|
||||
}
|
||||
|
||||
void LoadDialog::cancel() {
|
||||
lt->cancel();
|
||||
lt->wait();
|
||||
die();
|
||||
}
|
||||
|
||||
void LoadDialog::die() {
|
||||
olive::Global->new_project();
|
||||
reject();
|
||||
}
|
||||
|
||||
void LoadDialog::thread_done() {
|
||||
accept();
|
||||
QProgressBar *LoadDialog::progress_bar()
|
||||
{
|
||||
return bar;
|
||||
}
|
||||
|
||||
+26
-4
@@ -28,15 +28,37 @@
|
||||
#include "project/projectelements.h"
|
||||
#include "project/loadthread.h"
|
||||
|
||||
/**
|
||||
* @brief The LoadDialog class
|
||||
*
|
||||
* Shows a modal dialog for loading a project and creates a LoadThread to load it.
|
||||
*/
|
||||
class LoadDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LoadDialog(QWidget* parent, const QString& filename, bool autorecovery, bool clear);
|
||||
private slots:
|
||||
/**
|
||||
* @brief LoadDialog Constructor
|
||||
*
|
||||
* @param parent
|
||||
*
|
||||
* QWidget parent. Usually MainWindow.
|
||||
*
|
||||
* @param filename
|
||||
*
|
||||
* URL of the project file to load.
|
||||
*
|
||||
* @param autorecovery
|
||||
*
|
||||
* TRUE if this is an autorecovery project
|
||||
*
|
||||
* @param clear
|
||||
*/
|
||||
LoadDialog(QWidget* parent);
|
||||
|
||||
QProgressBar* progress_bar();
|
||||
signals:
|
||||
void cancel();
|
||||
void die();
|
||||
void thread_done();
|
||||
private:
|
||||
QProgressBar* bar;
|
||||
QPushButton* cancel_button;
|
||||
|
||||
Reference in New Issue
Block a user