From 2fa7a638d590082146d2c367784199cccf84b332 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 14 Dec 2018 22:25:23 +1100 Subject: [PATCH] reverted some files erroneously added in previous commit --- io/loadthread.cpp | 4 +- project/effect.cpp | 425 ++++++++++++++++++++++----------------------- project/effect.h | 1 - 3 files changed, 208 insertions(+), 222 deletions(-) diff --git a/io/loadthread.cpp b/io/loadthread.cpp index 68340bac5..d35d3e791 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,8 +114,6 @@ 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 376419fa4..3358e4822 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -38,40 +38,33 @@ #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 - e = new Effect(c, em); - } else { + return new Effect(c, em); + } else if (em->internal >= 0 && em->internal < EFFECT_INTERNAL_COUNT) { // must be an internal effect switch (em->internal) { - 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; + 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); } - } - 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; + } 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; } const EffectMeta* get_internal_meta(int internal_id, int type) { @@ -164,10 +157,8 @@ 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) { @@ -262,197 +442,6 @@ 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