reimplemented text field

This commit is contained in:
itsmattkc
2019-03-13 01:10:17 +11:00
parent df2c5be7a7
commit d01e868d60
5 changed files with 53 additions and 21 deletions
+26
View File
@@ -1,5 +1,10 @@
#include "stringfield.h"
#include <QtMath>
#include "ui/texteditex.h"
#include "io/config.h"
StringField::StringField(EffectRow* parent, const QString& id) :
EffectField(parent, id, EFFECT_FIELD_STRING)
{
@@ -10,3 +15,24 @@ QString StringField::GetStringAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *StringField::CreateWidget()
{
TextEditEx* text_edit = new TextEditEx();
text_edit->setUndoRedoEnabled(true);
// the "2" looks like a magic number, but it's just one pixel on the top and the bottom
text_edit->setFixedHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::CurrentConfig.effect_textbox_lines
+ text_edit->document()->documentMargin()
+ text_edit->document()->documentMargin() + 2));
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
return text_edit;
}
void StringField::UpdateFromWidget(const QString &s)
{
SetValueAt(Now(), s);
}