implemented all field UIs

This commit is contained in:
itsmattkc
2019-03-13 08:43:46 +11:00
parent b7b9c866a8
commit e82b0e4914
26 changed files with 256 additions and 131 deletions
+22 -4
View File
@@ -1,10 +1,11 @@
#include "buttonfield.h"
#include <QPushButton>
ButtonField::ButtonField(EffectRow *parent, const QString &string) :
EffectField(parent, nullptr, EFFECT_FIELD_UI)
{
SetValueAt(0, string);
}
EffectField(parent, nullptr, EFFECT_FIELD_UI),
button_text_(string)
{}
void ButtonField::SetCheckable(bool c)
{
@@ -16,3 +17,20 @@ void ButtonField::SetChecked(bool c)
checked_ = c;
emit CheckedChanged(c);
}
QWidget *ButtonField::CreateWidget()
{
QPushButton* button = new QPushButton();
button->setCheckable(checkable_);
button->setEnabled(IsEnabled());
button->setText(button_text_);
connect(this, SIGNAL(CheckedChanged(bool)), button, SLOT(setChecked(bool)));
connect(this, SIGNAL(EnabledChanged(bool)), button, SLOT(setEnabled(bool)));
connect(button, SIGNAL(clicked(bool)), this, SIGNAL(Clicked()));
connect(button, SIGNAL(toggled(bool)), this, SLOT(SetChecked(bool)));
connect(button, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
return button;
}
+8
View File
@@ -10,12 +10,20 @@ public:
ButtonField(EffectRow* parent, const QString& string);
void SetCheckable(bool c);
virtual QWidget* CreateWidget() override;
public slots:
void SetChecked(bool c);
signals:
void CheckedChanged(bool);
void Toggled(bool);
private:
bool checkable_;
bool checked_;
QString button_text_;
};
#endif // BUTTONFIELD_H
+17
View File
@@ -2,6 +2,8 @@
#include <QColor>
#include "ui/colorbutton.h"
ColorField::ColorField(EffectRow* parent, const QString& id) :
EffectField(parent, id, EFFECT_FIELD_COLOR)
{}
@@ -11,6 +13,16 @@ QColor ColorField::GetColorAt(double timecode)
return GetValueAt(timecode).value<QColor>();
}
QWidget *ColorField::CreateWidget()
{
ColorButton* cb = new ColorButton();
connect(cb, SIGNAL(color_changed(const QColor &)), this, SLOT(UpdateFromWidget(const QColor &)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
return cb;
}
QVariant ColorField::ConvertStringToValue(const QString &s)
{
return QColor(s);
@@ -20,3 +32,8 @@ QString ColorField::ConvertValueToString(const QVariant &v)
{
return v.value<QColor>().name();
}
void ColorField::UpdateFromWidget(const QColor& c)
{
SetValueAt(Now(), c);
}
+4
View File
@@ -11,8 +11,12 @@ public:
QColor GetColorAt(double timecode);
virtual QWidget* CreateWidget() override;
virtual QVariant ConvertStringToValue(const QString& s) override;
virtual QString ConvertValueToString(const QVariant& v) override;
private slots:
void UpdateFromWidget(const QColor &c);
};
#endif // COLORFIELD_H
+1
View File
@@ -25,6 +25,7 @@ QWidget *ComboField::CreateWidget()
}
connect(cb, SIGNAL(activated(int)), this, SLOT(UpdateFromWidget(int)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
return cb;
}
+2
View File
@@ -71,6 +71,8 @@ QWidget *DoubleField::CreateWidget()
ls->set_display_type(display_type_);
ls->set_frame_rate(frame_rate_);
ls->setEnabled(IsEnabled());
connect(ls, SIGNAL(valueChanged(double)), this, SLOT(UpdateFromWidget(double)));
connect(ls, SIGNAL(clicked()), this, SIGNAL(Clicked()));
connect(this, SIGNAL(EnabledChanged(bool)), ls, SLOT(setEnabled(bool)));
+1
View File
@@ -85,6 +85,7 @@ private:
signals:
void Changed();
void Clicked();
void EnabledChanged(bool);
};
+17
View File
@@ -1,5 +1,7 @@
#include "filefield.h"
#include "ui/embeddedfilechooser.h"
FileField::FileField(EffectRow* parent, const QString &id) :
EffectField(parent, id, EFFECT_FIELD_FILE)
{
@@ -10,3 +12,18 @@ QString FileField::GetFileAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *FileField::CreateWidget()
{
EmbeddedFileChooser* efc = new EmbeddedFileChooser();
connect(efc, SIGNAL(changed(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
connect(this, SIGNAL(EnabledChanged(bool)), efc, SLOT(setEnabled(bool)));
return efc;
}
void FileField::UpdateFromWidget(const QString &s)
{
SetValueAt(Now(), s);
}
+4
View File
@@ -10,6 +10,10 @@ public:
FileField(EffectRow* parent, const QString& id);
QString GetFileAt(double timecode);
virtual QWidget* CreateWidget() override;
private slots:
void UpdateFromWidget(const QString &s);
};
#endif // FILEFIELD_H
+22
View File
@@ -1,12 +1,34 @@
#include "fontfield.h"
#include <QComboBox>
#include <QFontDatabase>
FontField::FontField(EffectRow* parent, const QString &id) :
EffectField(parent, id, EFFECT_FIELD_FONT)
{
font_list = QFontDatabase().families();
SetValueAt(0, font_list.first());
}
QString FontField::GetFontAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *FontField::CreateWidget()
{
QComboBox* fcb = new QComboBox();
fcb->addItems(font_list);
connect(fcb, SIGNAL(currentTextChanged(const QString &)), this, SLOT(UpdateFromWidget(const QString &)));
connect(this, SIGNAL(EnabledChanged(bool)), fcb, SLOT(setEnabled(bool)));
return fcb;
}
void FontField::UpdateFromWidget(const QString& s)
{
SetValueAt(Now(), s);
}
+6
View File
@@ -9,6 +9,12 @@ public:
FontField(EffectRow* parent, const QString& id);
QString GetFontAt(double timecode);
virtual QWidget *CreateWidget() override;
private:
QStringList font_list;
private slots:
void UpdateFromWidget(const QString& index);
};
#endif // FONTFIELD_H
+13 -2
View File
@@ -1,7 +1,18 @@
#include "labelfield.h"
#include <QLabel>
LabelField::LabelField(EffectRow *parent, const QString &string) :
EffectField(parent, nullptr, EFFECT_FIELD_UI)
EffectField(parent, nullptr, EFFECT_FIELD_UI),
label_text_(string)
{}
QWidget *LabelField::CreateWidget()
{
SetValueAt(0, string);
QLabel* label = new QLabel(label_text_);
label->setEnabled(IsEnabled());
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
return label;
}
+4
View File
@@ -8,6 +8,10 @@ class LabelField : public EffectField
Q_OBJECT
public:
LabelField(EffectRow* parent, const QString& string);
virtual QWidget* CreateWidget() override;
private:
QString label_text_;
};
#endif // LABELFIELD_H
+2
View File
@@ -20,6 +20,7 @@ QWidget *StringField::CreateWidget()
{
TextEditEx* text_edit = new TextEditEx();
text_edit->setEnabled(IsEnabled());
text_edit->setUndoRedoEnabled(true);
// the "2" looks like a magic number, but it's just one pixel on the top and the bottom
@@ -28,6 +29,7 @@ QWidget *StringField::CreateWidget()
+ text_edit->document()->documentMargin() + 2));
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
connect(this, SIGNAL(EnabledChanged(bool)), text_edit, SLOT(setEnabled(bool)));
return text_edit;
}