added rich text mode
This commit is contained in:
@@ -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<EffectMeta> effects;
|
||||
|
||||
@@ -91,6 +92,7 @@ EffectPtr Effect::Create(Clip* c, const EffectMeta* em) {
|
||||
#ifndef NOFREI0R
|
||||
case EFFECT_INTERNAL_FREI0R: return std::make_shared<Frei0rEffect>(c, em);
|
||||
#endif
|
||||
case EFFECT_INTERNAL_RICHTEXT: return std::make_shared<RichTextEffect>(c, em);
|
||||
}
|
||||
} else if (!em->filename.isEmpty()) {
|
||||
// load effect from file
|
||||
|
||||
@@ -93,6 +93,7 @@ enum EffectInternal {
|
||||
EFFECT_INTERNAL_VST,
|
||||
EFFECT_INTERNAL_CORNERPIN,
|
||||
EFFECT_INTERNAL_FREI0R,
|
||||
EFFECT_INTERNAL_RICHTEXT,
|
||||
EFFECT_INTERNAL_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include "richtexteffect.h"
|
||||
|
||||
RichTextEffect::RichTextEffect(Clip *c, const EffectMeta *em)
|
||||
{
|
||||
#include <QTextDocument>
|
||||
|
||||
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)
|
||||
|
||||
@@ -8,7 +8,7 @@ class RichTextEffect : public Effect {
|
||||
public:
|
||||
RichTextEffect(Clip* c, const EffectMeta *em);
|
||||
void redraw(double timecode);
|
||||
|
||||
private:
|
||||
StringField* text_val;
|
||||
};
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user