reimplemented updating UI from effect fields
This commit is contained in:
@@ -23,6 +23,13 @@ QWidget *ColorField::CreateWidget()
|
||||
return cb;
|
||||
}
|
||||
|
||||
void ColorField::UpdateWidgetValue(QWidget *widget, double timecode)
|
||||
{
|
||||
ColorButton* cb = static_cast<ColorButton*>(widget);
|
||||
|
||||
cb->set_color(GetColorAt(timecode));
|
||||
}
|
||||
|
||||
QVariant ColorField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return QColor(s);
|
||||
|
||||
@@ -12,6 +12,7 @@ public:
|
||||
QColor GetColorAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
virtual QString ConvertValueToString(const QVariant& v) override;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "combofield.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "ui/comboboxex.h"
|
||||
|
||||
ComboField::ComboField(EffectRow* parent, const QString& id) :
|
||||
@@ -32,6 +34,24 @@ QWidget *ComboField::CreateWidget()
|
||||
return cb;
|
||||
}
|
||||
|
||||
void ComboField::UpdateWidgetValue(QWidget *widget, double timecode)
|
||||
{
|
||||
QVariant data = GetValueAt(timecode);
|
||||
|
||||
ComboBoxEx* cb = static_cast<ComboBoxEx*>(widget);
|
||||
|
||||
for (int i=0;i<items_.size();i++) {
|
||||
if (items_.at(i).data == data) {
|
||||
cb->blockSignals(true);
|
||||
cb->setCurrentIndex(i);
|
||||
cb->blockSignals(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Failed to set ComboField value from data";
|
||||
}
|
||||
|
||||
void ComboField::UpdateFromWidget(int index)
|
||||
{
|
||||
SetValueAt(Now(), items_.at(index).data);
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void AddItem(const QString& text, const QVariant& data);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
signals:
|
||||
void IndexChanged(int i);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "fontfield.h"
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ui/comboboxex.h"
|
||||
|
||||
// NOTE/TODO: This shares a lot of similarity with ComboField, and could probably be a derived class of it
|
||||
|
||||
FontField::FontField(EffectRow* parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_FONT)
|
||||
{
|
||||
@@ -31,6 +34,24 @@ QWidget *FontField::CreateWidget()
|
||||
return fcb;
|
||||
}
|
||||
|
||||
void FontField::UpdateWidgetValue(QWidget *widget, double timecode)
|
||||
{
|
||||
QVariant data = GetValueAt(timecode);
|
||||
|
||||
ComboBoxEx* cb = static_cast<ComboBoxEx*>(widget);
|
||||
|
||||
for (int i=0;i<font_list.size();i++) {
|
||||
if (font_list.at(i) == data) {
|
||||
cb->blockSignals(true);
|
||||
cb->setCurrentIndex(i);
|
||||
cb->blockSignals(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Failed to set FontField value from data";
|
||||
}
|
||||
|
||||
void FontField::UpdateFromWidget(const QString& s)
|
||||
{
|
||||
SetValueAt(Now(), s);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef FONTFIELD_H
|
||||
#define FONTFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
#include "combofield.h"
|
||||
|
||||
class FontField : public EffectField {
|
||||
Q_OBJECT
|
||||
@@ -11,6 +11,8 @@ public:
|
||||
QString GetFontAt(double timecode);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
private:
|
||||
QStringList font_list;
|
||||
private slots:
|
||||
|
||||
@@ -34,6 +34,11 @@ QWidget *StringField::CreateWidget()
|
||||
return text_edit;
|
||||
}
|
||||
|
||||
void StringField::UpdateWidgetValue(QWidget *widget, double timecode)
|
||||
{
|
||||
static_cast<TextEditEx*>(widget)->setHtml(GetValueAt(timecode).toString());
|
||||
}
|
||||
|
||||
void StringField::UpdateFromWidget(const QString &s)
|
||||
{
|
||||
SetValueAt(Now(), s);
|
||||
|
||||
@@ -12,6 +12,7 @@ public:
|
||||
QString GetStringAt(double timecode);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QString& b);
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) :
|
||||
EffectRow* opacity_row = new EffectRow(this, tr("Opacity"));
|
||||
opacity_field = new DoubleField(opacity_row, "opacity");
|
||||
opacity_field->SetMinimum(0);
|
||||
opacity_field->SetDefault(0);
|
||||
opacity_field->SetDefault(100);
|
||||
opacity_field->SetMaximum(100);
|
||||
|
||||
EffectRow* solid_color_row = new EffectRow(this, tr("Color"));
|
||||
|
||||
Reference in New Issue
Block a user