file/folder restructuring
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#include "boolfield.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
BoolField::BoolField(EffectRow *parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_BOOL)
|
||||
{}
|
||||
|
||||
bool BoolField::GetBoolAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toBool();
|
||||
}
|
||||
|
||||
QWidget *BoolField::CreateWidget()
|
||||
{
|
||||
QCheckBox* cb = new QCheckBox();
|
||||
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(UpdateFromWidget(bool)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
void BoolField::UpdateWidgetValue(QWidget *widget, double timecode)
|
||||
{
|
||||
QCheckBox* cb = static_cast<QCheckBox*>(widget);
|
||||
|
||||
// Setting the checked state on the checkbox below normally triggers a change() signal that will then trickle back
|
||||
// to setting a value on this field. Therefore we block its signals while we're setting this.
|
||||
|
||||
cb->blockSignals(true);
|
||||
|
||||
cb->setChecked(GetBoolAt(timecode));
|
||||
|
||||
cb->blockSignals(false);
|
||||
}
|
||||
|
||||
QVariant BoolField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return (s == "1");
|
||||
}
|
||||
|
||||
QString BoolField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return QString::number(v.toBool());
|
||||
}
|
||||
|
||||
void BoolField::UpdateFromWidget(bool b)
|
||||
{
|
||||
SetValueAt(Now(), b);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef BOOLFIELD_H
|
||||
#define BOOLFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class BoolField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BoolField(EffectRow* parent, const QString& id);
|
||||
|
||||
bool GetBoolAt(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;
|
||||
signals:
|
||||
void Toggled(bool);
|
||||
private slots:
|
||||
void UpdateFromWidget(bool b);
|
||||
};
|
||||
|
||||
#endif // BOOLFIELD_H
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "buttonfield.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
ButtonField::ButtonField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI),
|
||||
button_text_(string)
|
||||
{}
|
||||
|
||||
void ButtonField::SetCheckable(bool c)
|
||||
{
|
||||
checkable_ = c;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef BUTTONFIELD_H
|
||||
#define BUTTONFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class ButtonField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
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
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "colorfield.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include "ui/colorbutton.h"
|
||||
|
||||
ColorField::ColorField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_COLOR)
|
||||
{}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
QString ColorField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return v.value<QColor>().name();
|
||||
}
|
||||
|
||||
void ColorField::UpdateFromWidget(const QColor& c)
|
||||
{
|
||||
SetValueAt(Now(), c);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef COLORFIELD_H
|
||||
#define COLORFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class ColorField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorField(EffectRow* parent, const QString& id);
|
||||
|
||||
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
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "combofield.h"
|
||||
|
||||
#include "ui/comboboxex.h"
|
||||
|
||||
ComboField::ComboField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_COMBO)
|
||||
{}
|
||||
|
||||
void ComboField::AddItem(const QString &text, const QVariant &data)
|
||||
{
|
||||
ComboFieldItem item;
|
||||
|
||||
item.name = text;
|
||||
item.data = data;
|
||||
|
||||
items_.append(item);
|
||||
}
|
||||
|
||||
QWidget *ComboField::CreateWidget()
|
||||
{
|
||||
ComboBoxEx* cb = new ComboBoxEx();
|
||||
|
||||
cb->setScrollingEnabled(false);
|
||||
|
||||
for (int i=0;i<items_.size();i++) {
|
||||
cb->addItem(items_.at(i).name);
|
||||
}
|
||||
|
||||
connect(cb, SIGNAL(activated(int)), this, SLOT(UpdateFromWidget(int)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
|
||||
|
||||
return cb;
|
||||
}
|
||||
|
||||
void ComboField::UpdateFromWidget(int index)
|
||||
{
|
||||
SetValueAt(Now(), items_.at(index).data);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef COMBOFIELD_H
|
||||
#define COMBOFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
struct ComboFieldItem {
|
||||
QString name;
|
||||
QVariant data;
|
||||
};
|
||||
|
||||
class ComboField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ComboField(EffectRow* parent, const QString& id);
|
||||
|
||||
void AddItem(const QString& text, const QVariant& data);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
|
||||
signals:
|
||||
void IndexChanged(int i);
|
||||
|
||||
private:
|
||||
QVector<ComboFieldItem> items_;
|
||||
|
||||
private slots:
|
||||
void UpdateFromWidget(int index);
|
||||
};
|
||||
|
||||
#endif // COMBOFIELD_H
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "doublefield.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
DoubleField::DoubleField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_DOUBLE),
|
||||
min_(qSNaN()),
|
||||
max_(qSNaN()),
|
||||
default_(0),
|
||||
display_type_(LabelSlider::Normal),
|
||||
frame_rate_(30),
|
||||
value_set_(false)
|
||||
{
|
||||
connect(this, SIGNAL(Changed()), this, SLOT(ValueHasBeenSet()), Qt::DirectConnection);
|
||||
}
|
||||
|
||||
double DoubleField::GetDoubleAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toDouble();
|
||||
}
|
||||
|
||||
void DoubleField::SetMinimum(double minimum)
|
||||
{
|
||||
min_ = minimum;
|
||||
}
|
||||
|
||||
void DoubleField::SetMaximum(double maximum)
|
||||
{
|
||||
max_ = maximum;
|
||||
}
|
||||
|
||||
void DoubleField::SetDefault(double d)
|
||||
{
|
||||
default_ = d;
|
||||
|
||||
if (!value_set_) {
|
||||
SetValueAt(0, d);
|
||||
value_set_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DoubleField::SetDisplayType(LabelSlider::DisplayType type)
|
||||
{
|
||||
display_type_ = type;
|
||||
}
|
||||
|
||||
void DoubleField::SetFrameRate(const double &rate)
|
||||
{
|
||||
frame_rate_ = rate;
|
||||
}
|
||||
|
||||
QVariant DoubleField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return s.toDouble();
|
||||
}
|
||||
|
||||
QString DoubleField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return QString::number(v.toDouble());
|
||||
}
|
||||
|
||||
QWidget *DoubleField::CreateWidget()
|
||||
{
|
||||
LabelSlider* ls = new LabelSlider();
|
||||
|
||||
if (!qIsNaN(min_)) {
|
||||
ls->SetMinimum(min_);
|
||||
}
|
||||
ls->SetDefault(default_);
|
||||
if (!qIsNaN(max_)) {
|
||||
ls->SetMaximum(max_);
|
||||
}
|
||||
ls->SetDisplayType(display_type_);
|
||||
ls->SetFrameRate(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)));
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
void DoubleField::UpdateWidgetValue(QWidget *widget, double timecode)
|
||||
{
|
||||
static_cast<LabelSlider*>(widget)->SetValue(GetDoubleAt(timecode));
|
||||
}
|
||||
|
||||
void DoubleField::ValueHasBeenSet()
|
||||
{
|
||||
value_set_ = true;
|
||||
}
|
||||
|
||||
void DoubleField::UpdateFromWidget(double d)
|
||||
{
|
||||
SetValueAt(Now(), d);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef DOUBLEFIELD_H
|
||||
#define DOUBLEFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
#include "ui/labelslider.h"
|
||||
|
||||
class DoubleField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DoubleField(EffectRow* parent, const QString& id);
|
||||
|
||||
/**
|
||||
* @brief Get double value at timecode
|
||||
*
|
||||
* Convenience function. Equivalent to GetValueAt().toDouble()
|
||||
*
|
||||
* @param timecode
|
||||
*
|
||||
* Timecode to retrieve value at
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* Double value at the set timecode
|
||||
*/
|
||||
double GetDoubleAt(double timecode);
|
||||
|
||||
void SetMinimum(double minimum);
|
||||
void SetMaximum(double maximum);
|
||||
void SetDefault(double maximum);
|
||||
|
||||
void SetDisplayType(LabelSlider::DisplayType type);
|
||||
void SetFrameRate(const double& rate);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
private:
|
||||
double min_;
|
||||
double max_;
|
||||
double default_;
|
||||
|
||||
LabelSlider::DisplayType display_type_;
|
||||
double frame_rate_;
|
||||
|
||||
bool value_set_;
|
||||
private slots:
|
||||
void ValueHasBeenSet();
|
||||
void UpdateFromWidget(double d);
|
||||
};
|
||||
|
||||
#endif // DOUBLEFIELD_H
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "filefield.h"
|
||||
|
||||
#include "ui/embeddedfilechooser.h"
|
||||
|
||||
FileField::FileField(EffectRow* parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_FILE)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef FILEFIELD_H
|
||||
#define FILEFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class FileField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
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
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "fontfield.h"
|
||||
|
||||
#include <QFontDatabase>
|
||||
|
||||
#include "ui/comboboxex.h"
|
||||
|
||||
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()
|
||||
{
|
||||
ComboBoxEx* fcb = new ComboBoxEx();
|
||||
|
||||
fcb->setScrollingEnabled(false);
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef FONTFIELD_H
|
||||
#define FONTFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class FontField : public EffectField {
|
||||
Q_OBJECT
|
||||
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
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "labelfield.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
LabelField::LabelField(EffectRow *parent, const QString &string) :
|
||||
EffectField(parent, nullptr, EFFECT_FIELD_UI),
|
||||
label_text_(string)
|
||||
{}
|
||||
|
||||
QWidget *LabelField::CreateWidget()
|
||||
{
|
||||
QLabel* label = new QLabel(label_text_);
|
||||
|
||||
label->setEnabled(IsEnabled());
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
|
||||
|
||||
return label;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef LABELFIELD_H
|
||||
#define LABELFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class LabelField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LabelField(EffectRow* parent, const QString& string);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
private:
|
||||
QString label_text_;
|
||||
};
|
||||
|
||||
#endif // LABELFIELD_H
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "stringfield.h"
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
#include "ui/texteditex.h"
|
||||
#include "global/config.h"
|
||||
|
||||
StringField::StringField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_STRING)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString StringField::GetStringAt(double timecode)
|
||||
{
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
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
|
||||
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&)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), text_edit, SLOT(setEnabled(bool)));
|
||||
|
||||
return text_edit;
|
||||
}
|
||||
|
||||
void StringField::UpdateFromWidget(const QString &s)
|
||||
{
|
||||
SetValueAt(Now(), s);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef STRINGFIELD_H
|
||||
#define STRINGFIELD_H
|
||||
|
||||
#include "../effectfield.h"
|
||||
|
||||
class StringField : public EffectField
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StringField(EffectRow* parent, const QString& id);
|
||||
|
||||
QString GetStringAt(double timecode);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QString& b);
|
||||
};
|
||||
|
||||
#endif // STRINGFIELD_H
|
||||
Reference in New Issue
Block a user