diff --git a/effects/effect.cpp b/effects/effect.cpp index 81cdd83d5..964487a90 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -67,6 +67,7 @@ #include "effects/internal/vsthost.h" #include "effects/internal/fillleftrighteffect.h" #include "effects/internal/frei0reffect.h" +#include "effects/internal/richtexteffect.h" QVector effects; @@ -91,6 +92,7 @@ EffectPtr Effect::Create(Clip* c, const EffectMeta* em) { #ifndef NOFREI0R case EFFECT_INTERNAL_FREI0R: return std::make_shared(c, em); #endif + case EFFECT_INTERNAL_RICHTEXT: return std::make_shared(c, em); } } else if (!em->filename.isEmpty()) { // load effect from file diff --git a/effects/effect.h b/effects/effect.h index dd0780c5a..4944ad5d4 100644 --- a/effects/effect.h +++ b/effects/effect.h @@ -93,6 +93,7 @@ enum EffectInternal { EFFECT_INTERNAL_VST, EFFECT_INTERNAL_CORNERPIN, EFFECT_INTERNAL_FREI0R, + EFFECT_INTERNAL_RICHTEXT, EFFECT_INTERNAL_COUNT }; diff --git a/effects/effectloaders.cpp b/effects/effectloaders.cpp index d00c8b67b..d53390ab5 100644 --- a/effects/effectloaders.cpp +++ b/effects/effectloaders.cpp @@ -99,6 +99,11 @@ void load_internal_effects() { em.internal = EFFECT_INTERNAL_TEXT; effects.append(em); + em.name = "Rich Text"; + em.category = "Render"; + em.internal = EFFECT_INTERNAL_RICHTEXT; + effects.append(em); + em.name = "Timecode"; em.internal = EFFECT_INTERNAL_TIMECODE; effects.append(em); diff --git a/effects/fields/stringfield.cpp b/effects/fields/stringfield.cpp index 35c58f2a1..45d7b023c 100644 --- a/effects/fields/stringfield.cpp +++ b/effects/fields/stringfield.cpp @@ -6,8 +6,9 @@ #include "ui/texteditex.h" #include "global/config.h" -StringField::StringField(EffectRow* parent, const QString& id) : - EffectField(parent, id, EFFECT_FIELD_STRING) +StringField::StringField(EffectRow* parent, const QString& id, bool rich_text) : + EffectField(parent, id, EFFECT_FIELD_STRING), + rich_text_(rich_text) { } @@ -19,7 +20,7 @@ QString StringField::GetStringAt(double timecode) QWidget *StringField::CreateWidget() { - TextEditEx* text_edit = new TextEditEx(); + TextEditEx* text_edit = new TextEditEx(nullptr, rich_text_); text_edit->setEnabled(IsEnabled()); text_edit->setUndoRedoEnabled(true); @@ -43,7 +44,11 @@ void StringField::UpdateWidgetValue(QWidget *widget, double timecode) int pos = text->textCursor().position(); - text->setHtml(GetValueAt(timecode).toString()); + if (rich_text_) { + text->setHtml(GetValueAt(timecode).toString()); + } else { + text->setPlainText(GetValueAt(timecode).toString()); + } QTextCursor new_cursor(text->document()); new_cursor.setPosition(pos); diff --git a/effects/fields/stringfield.h b/effects/fields/stringfield.h index 969ce52af..6202afb27 100644 --- a/effects/fields/stringfield.h +++ b/effects/fields/stringfield.h @@ -7,7 +7,7 @@ class StringField : public EffectField { Q_OBJECT public: - StringField(EffectRow* parent, const QString& id); + StringField(EffectRow* parent, const QString& id, bool rich_text = true); QString GetStringAt(double timecode); @@ -15,6 +15,8 @@ public: virtual void UpdateWidgetValue(QWidget* widget, double timecode) override; private slots: void UpdateFromWidget(const QString& b); +private: + bool rich_text_; }; #endif // STRINGFIELD_H diff --git a/effects/internal/richtexteffect.cpp b/effects/internal/richtexteffect.cpp index 271799156..30a1f0fef 100644 --- a/effects/internal/richtexteffect.cpp +++ b/effects/internal/richtexteffect.cpp @@ -1,8 +1,12 @@ #include "richtexteffect.h" -RichTextEffect::RichTextEffect(Clip *c, const EffectMeta *em) -{ +#include +RichTextEffect::RichTextEffect(Clip *c, const EffectMeta *em) : + Effect(c, em) +{ + EffectRow* text_row = new EffectRow(this, tr("Text")); + text_val = new StringField(text_row, "text"); } void RichTextEffect::redraw(double timecode) diff --git a/effects/internal/richtexteffect.h b/effects/internal/richtexteffect.h index 7bd0bd214..37eb50530 100644 --- a/effects/internal/richtexteffect.h +++ b/effects/internal/richtexteffect.h @@ -8,7 +8,7 @@ class RichTextEffect : public Effect { public: RichTextEffect(Clip* c, const EffectMeta *em); void redraw(double timecode); - +private: StringField* text_val; }; diff --git a/effects/internal/texteffect.cpp b/effects/internal/texteffect.cpp index 5f562181b..8365a57ce 100644 --- a/effects/internal/texteffect.cpp +++ b/effects/internal/texteffect.cpp @@ -48,7 +48,7 @@ TextEffect::TextEffect(Clip* c, const EffectMeta* em) : SetFlags(Effect::SuperimposeFlag); EffectRow* text_field = new EffectRow(this, tr("Text")); - text_val = new StringField(text_field, "text"); + text_val = new StringField(text_field, "text", false); text_val->SetColumnSpan(2); EffectRow* font_row = new EffectRow(this, tr("Font"));