From 6b8168dc6a7900ac4df7b2beffafa351c7d49e6c Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 14 Dec 2018 22:19:52 +1100 Subject: [PATCH] export dialog updates ui when done --- dialogs/exportdialog.cpp | 4 +- io/loadthread.cpp | 4 +- project/effect.cpp | 425 ++++++++++++++++++++------------------- project/effect.h | 1 + 4 files changed, 224 insertions(+), 210 deletions(-) diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index 772c35823..20b010913 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -313,8 +313,7 @@ void ExportDialog::on_formatCombobox_currentIndexChanged(int index) ui->audioGroupbox->setEnabled(audio_enabled); } -void ExportDialog::on_pushButton_2_clicked() -{ +void ExportDialog::on_pushButton_2_clicked() { close(); } @@ -325,6 +324,7 @@ void ExportDialog::render_thread_finished() { prep_ui_for_render(false); panel_sequence_viewer->viewer_widget->makeCurrent(); panel_sequence_viewer->viewer_widget->initializeGL(); + update_ui(false); if (ui->progressBar->value() == 100) close(); } diff --git a/io/loadthread.cpp b/io/loadthread.cpp index d35d3e791..68340bac5 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -1,4 +1,4 @@ -#include "loadthread.h" +#include "loadthread.h" #include "mainwindow.h" #include "panels/panels.h" @@ -114,6 +114,8 @@ void load_effect(QXmlStreamReader& stream, Clip* c) { e->set_enabled(effect_enabled); e->load(stream); + e->moveToThread(QApplication::instance()->thread()); + c->effects.append(e); } } diff --git a/project/effect.cpp b/project/effect.cpp index 3358e4822..376419fa4 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -38,33 +38,40 @@ #include #include #include +#include QVector effects; QMutex effects_loaded; Effect* create_effect(Clip* c, const EffectMeta* em) { + Effect* e = NULL; if (!em->filename.isEmpty()) { // load effect from file - return new Effect(c, em); - } else if (em->internal >= 0 && em->internal < EFFECT_INTERNAL_COUNT) { + e = new Effect(c, em); + } else { // must be an internal effect switch (em->internal) { - case EFFECT_INTERNAL_TRANSFORM: return new TransformEffect(c, em); - case EFFECT_INTERNAL_TEXT: return new TextEffect(c, em); - case EFFECT_INTERNAL_TIMECODE: return new TimecodeEffect(c, em); - case EFFECT_INTERNAL_SOLID: return new SolidEffect(c, em); - case EFFECT_INTERNAL_NOISE: return new AudioNoiseEffect(c, em); - case EFFECT_INTERNAL_VOLUME: return new VolumeEffect(c, em); - case EFFECT_INTERNAL_PAN: return new PanEffect(c, em); - case EFFECT_INTERNAL_TONE: return new ToneEffect(c, em); - case EFFECT_INTERNAL_SHAKE: return new ShakeEffect(c, em); - case EFFECT_INTERNAL_CORNERPIN: return new CornerPinEffect(c, em); + case EFFECT_INTERNAL_TRANSFORM: e = new TransformEffect(c, em); break; + case EFFECT_INTERNAL_TEXT: e = new TextEffect(c, em); break; + case EFFECT_INTERNAL_TIMECODE: e = new TimecodeEffect(c, em); break; + case EFFECT_INTERNAL_SOLID: e = new SolidEffect(c, em); break; + case EFFECT_INTERNAL_NOISE: e = new AudioNoiseEffect(c, em); break; + case EFFECT_INTERNAL_VOLUME: e = new VolumeEffect(c, em); break; + case EFFECT_INTERNAL_PAN: e = new PanEffect(c, em); break; + case EFFECT_INTERNAL_TONE: e = new ToneEffect(c, em); break; + case EFFECT_INTERNAL_SHAKE: e = new ShakeEffect(c, em); break; + case EFFECT_INTERNAL_CORNERPIN: e = new CornerPinEffect(c, em); break; } - } else { - dout << "[ERROR] Invalid effect data"; - QMessageBox::critical(mainWindow, "Invalid effect", "No candidate for effect '" + em->name + "'. This effect may be corrupt. Try reinstalling it or Olive."); - } - return NULL; + } + if (e == NULL) { + dout << "[ERROR] Invalid effect data"; + QMessageBox::critical(mainWindow, "Invalid effect", "No candidate for effect '" + em->name + "'. This effect may be corrupt. Try reinstalling it or Olive."); + } else { + // make sure we're in the main thread + e->moveToThread(QApplication::instance()->thread()); + e->init_ui(); + } + return e; } const EffectMeta* get_internal_meta(int internal_id, int type) { @@ -157,8 +164,10 @@ void load_internal_effects() { void load_shader_effects() { QString effects_path = get_effects_dir(); QDir effects_dir(effects_path); + if (effects_dir.exists()) { QList entries = effects_dir.entryList(QStringList("*.xml"), QDir::Files); + for (int i=0;ienabled_check, SIGNAL(clicked(bool)), this, SLOT(field_changed())); - ui = new QWidget(); - ui_layout = new QGridLayout(); - ui_layout->setSpacing(4); - ui->setLayout(ui_layout); - container->setContents(ui); - - connect(container->title_bar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&))); - - // set up UI from effect file - container->setText(em->name); - - if (!em->filename.isEmpty()) { - QFile effect_file(get_effects_dir() + "/" + em->filename); - if (effect_file.open(QFile::ReadOnly)) { - QXmlStreamReader reader(&effect_file); - - while (!reader.atEnd()) { - if (reader.name() == "row" && reader.isStartElement()) { - QString row_name; - const QXmlStreamAttributes& attributes = reader.attributes(); - for (int i=0;ifilename << "- ID cannot be empty."; - } else if (type > -1) { - EffectField* field = row->add_field(type, id); - connect(field, SIGNAL(changed()), this, SLOT(field_changed())); - switch (type) { - case EFFECT_FIELD_DOUBLE: - for (int i=0;iset_double_default_value(attr.value().toDouble()); - } else if (attr.name() == "min") { - field->set_double_minimum_value(attr.value().toDouble()); - } else if (attr.name() == "max") { - field->set_double_maximum_value(attr.value().toDouble()); - } - } - break; - case EFFECT_FIELD_COLOR: - { - QColor color; - for (int i=0;iset_color_value(color); - } - break; - case EFFECT_FIELD_STRING: - for (int i=0;iset_string_value(attr.value().toString()); - } - } - break; - case EFFECT_FIELD_BOOL: - for (int i=0;iset_bool_value(attr.value() == "1"); - } - } - break; - case EFFECT_FIELD_COMBO: - { - int combo_index = 0; - for (int i=0;iadd_combo_item(reader.text().toString(), 0); - } - } - field->set_combo_index(combo_index); - } - break; - case EFFECT_FIELD_FONT: - for (int i=0;iset_font_name(attr.value().toString()); - } - } - break; - } - } - } - } - } - } else if (reader.name() == "shader" && reader.isStartElement()) { - enable_shader = true; - const QXmlStreamAttributes& attributes = reader.attributes(); - for (int i=0;ifilename; - enable_superimpose = false; - } - break; - } - } - } - reader.readNext(); - } - - effect_file.close(); - } else { - dout << "[ERROR] Failed to open effect file" << em->filename; - } - } -} +{} Effect::~Effect() { if (isOpen) { @@ -442,6 +262,197 @@ Effect::~Effect() { } } +void Effect::init_ui() { + // set up base UI + container = new CollapsibleWidget(); + connect(container->enabled_check, SIGNAL(clicked(bool)), this, SLOT(field_changed())); + ui = new QWidget(container); + ui_layout = new QGridLayout(ui); + ui_layout->setSpacing(4); + ui->setLayout(ui_layout); + container->setContents(ui); + + connect(container->title_bar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&))); + + // set up UI from effect file + container->setText(meta->name); + + if (!meta->filename.isEmpty()) { + QFile effect_file(get_effects_dir() + "/" + meta->filename); + if (effect_file.open(QFile::ReadOnly)) { + QXmlStreamReader reader(&effect_file); + + while (!reader.atEnd()) { + if (reader.name() == "row" && reader.isStartElement()) { + QString row_name; + const QXmlStreamAttributes& attributes = reader.attributes(); + for (int i=0;ifilename << "- ID cannot be empty."; + } else if (type > -1) { + EffectField* field = row->add_field(type, id); + connect(field, SIGNAL(changed()), this, SLOT(field_changed())); + switch (type) { + case EFFECT_FIELD_DOUBLE: + for (int i=0;iset_double_default_value(attr.value().toDouble()); + } else if (attr.name() == "min") { + field->set_double_minimum_value(attr.value().toDouble()); + } else if (attr.name() == "max") { + field->set_double_maximum_value(attr.value().toDouble()); + } + } + break; + case EFFECT_FIELD_COLOR: + { + QColor color; + for (int i=0;iset_color_value(color); + } + break; + case EFFECT_FIELD_STRING: + for (int i=0;iset_string_value(attr.value().toString()); + } + } + break; + case EFFECT_FIELD_BOOL: + for (int i=0;iset_bool_value(attr.value() == "1"); + } + } + break; + case EFFECT_FIELD_COMBO: + { + int combo_index = 0; + for (int i=0;iadd_combo_item(reader.text().toString(), 0); + } + } + field->set_combo_index(combo_index); + } + break; + case EFFECT_FIELD_FONT: + for (int i=0;iset_font_name(attr.value().toString()); + } + } + break; + } + } + } + } + } + } else if (reader.name() == "shader" && reader.isStartElement()) { + enable_shader = true; + const QXmlStreamAttributes& attributes = reader.attributes(); + for (int i=0;ifilename; + enable_superimpose = false; + } + break; + } + } + } + reader.readNext(); + } + + effect_file.close(); + } else { + dout << "[ERROR] Failed to open effect file" << meta->filename; + } + } +} + void Effect::copy_field_keyframes(Effect* e) { for (int i=0;i