implemented #92
This commit is contained in:
@@ -11,9 +11,20 @@ bool BoolField::GetBoolAt(double timecode)
|
||||
return GetValueAt(timecode).toBool();
|
||||
}
|
||||
|
||||
QWidget *BoolField::CreateWidget()
|
||||
QWidget *BoolField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
QCheckBox* cb = new QCheckBox();
|
||||
QCheckBox* cb;
|
||||
|
||||
if (existing == nullptr) {
|
||||
|
||||
cb = new QCheckBox();
|
||||
cb->setEnabled(IsEnabled());
|
||||
|
||||
} else {
|
||||
|
||||
cb = static_cast<QCheckBox*>(existing);
|
||||
|
||||
}
|
||||
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(UpdateFromWidget(bool)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
|
||||
bool GetBoolAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
|
||||
@@ -18,13 +18,23 @@ void ButtonField::SetChecked(bool c)
|
||||
emit CheckedChanged(c);
|
||||
}
|
||||
|
||||
QWidget *ButtonField::CreateWidget()
|
||||
QWidget *ButtonField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
QPushButton* button = new QPushButton();
|
||||
QPushButton* button;
|
||||
|
||||
button->setCheckable(checkable_);
|
||||
button->setEnabled(IsEnabled());
|
||||
button->setText(button_text_);
|
||||
if (existing == nullptr) {
|
||||
|
||||
button = new QPushButton();
|
||||
|
||||
button->setCheckable(checkable_);
|
||||
button->setEnabled(IsEnabled());
|
||||
button->setText(button_text_);
|
||||
|
||||
} else {
|
||||
|
||||
button = static_cast<QPushButton*>(existing);
|
||||
|
||||
}
|
||||
|
||||
connect(this, SIGNAL(CheckedChanged(bool)), button, SLOT(setChecked(bool)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), button, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
ButtonField(EffectRow* parent, const QString& string);
|
||||
|
||||
void SetCheckable(bool c);
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void SetChecked(bool c);
|
||||
|
||||
@@ -13,9 +13,9 @@ QColor ColorField::GetColorAt(double timecode)
|
||||
return GetValueAt(timecode).value<QColor>();
|
||||
}
|
||||
|
||||
QWidget *ColorField::CreateWidget()
|
||||
QWidget *ColorField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
ColorButton* cb = new ColorButton();
|
||||
ColorButton* cb = (existing != nullptr) ? static_cast<ColorButton*>(existing) : new ColorButton();
|
||||
|
||||
connect(cb, SIGNAL(color_changed(const QColor &)), this, SLOT(UpdateFromWidget(const QColor &)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
|
||||
QColor GetColorAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
|
||||
@@ -18,14 +18,20 @@ void ComboField::AddItem(const QString &text, const QVariant &data)
|
||||
items_.append(item);
|
||||
}
|
||||
|
||||
QWidget *ComboField::CreateWidget()
|
||||
QWidget *ComboField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
ComboBoxEx* cb = new ComboBoxEx();
|
||||
ComboBoxEx* cb;
|
||||
|
||||
cb->setScrollingEnabled(false);
|
||||
if (existing == nullptr) {
|
||||
cb = new ComboBoxEx();
|
||||
|
||||
for (int i=0;i<items_.size();i++) {
|
||||
cb->addItem(items_.at(i).name);
|
||||
cb->setScrollingEnabled(false);
|
||||
|
||||
for (int i=0;i<items_.size();i++) {
|
||||
cb->addItem(items_.at(i).name);
|
||||
}
|
||||
} else {
|
||||
cb = static_cast<ComboBoxEx*>(existing);
|
||||
}
|
||||
|
||||
connect(cb, SIGNAL(activated(int)), this, SLOT(UpdateFromWidget(int)));
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
|
||||
void AddItem(const QString& text, const QVariant& data);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
signals:
|
||||
|
||||
@@ -60,22 +60,31 @@ QString DoubleField::ConvertValueToString(const QVariant &v)
|
||||
return QString::number(v.toDouble());
|
||||
}
|
||||
|
||||
QWidget *DoubleField::CreateWidget()
|
||||
QWidget *DoubleField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
LabelSlider* ls = new LabelSlider();
|
||||
LabelSlider* ls;
|
||||
|
||||
if (!qIsNaN(min_)) {
|
||||
ls->SetMinimum(min_);
|
||||
}
|
||||
ls->SetDefault(default_);
|
||||
if (!qIsNaN(max_)) {
|
||||
ls->SetMaximum(max_);
|
||||
}
|
||||
ls->SetDisplayType(display_type_);
|
||||
ls->SetFrameRate(frame_rate_);
|
||||
if (existing == nullptr) {
|
||||
|
||||
//qDebug() << "";
|
||||
ls->setEnabled(IsEnabled());
|
||||
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());
|
||||
|
||||
} else {
|
||||
|
||||
ls = static_cast<LabelSlider*>(existing);
|
||||
|
||||
}
|
||||
|
||||
connect(ls, SIGNAL(valueChanged(double)), this, SLOT(UpdateFromWidget(double)));
|
||||
connect(ls, SIGNAL(clicked()), this, SIGNAL(Clicked()));
|
||||
|
||||
@@ -32,10 +32,10 @@ public:
|
||||
void SetDisplayType(LabelSlider::DisplayType type);
|
||||
void SetFrameRate(const double& rate);
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
virtual QString ConvertValueToString(const QVariant& v) override;
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
private:
|
||||
double min_;
|
||||
|
||||
@@ -13,9 +13,9 @@ QString FileField::GetFileAt(double timecode)
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QWidget *FileField::CreateWidget()
|
||||
QWidget *FileField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
EmbeddedFileChooser* efc = new EmbeddedFileChooser();
|
||||
EmbeddedFileChooser* efc = (existing != nullptr) ? static_cast<EmbeddedFileChooser*>(existing) : new EmbeddedFileChooser();
|
||||
|
||||
connect(efc, SIGNAL(changed(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), efc, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
|
||||
QString GetFileAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QString &s);
|
||||
};
|
||||
|
||||
@@ -20,13 +20,23 @@ QString FontField::GetFontAt(double timecode)
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QWidget *FontField::CreateWidget()
|
||||
QWidget *FontField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
ComboBoxEx* fcb = new ComboBoxEx();
|
||||
|
||||
fcb->setScrollingEnabled(false);
|
||||
if (existing == nullptr) {
|
||||
|
||||
fcb->addItems(font_list);
|
||||
fcb = new ComboBoxEx();
|
||||
|
||||
fcb->setScrollingEnabled(false);
|
||||
|
||||
fcb->addItems(font_list);
|
||||
|
||||
} else {
|
||||
|
||||
fcb = static_cast<ComboBoxEx*>(existing);
|
||||
|
||||
}
|
||||
|
||||
connect(fcb, SIGNAL(currentTextChanged(const QString &)), this, SLOT(UpdateFromWidget(const QString &)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), fcb, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -10,7 +10,7 @@ public:
|
||||
|
||||
QString GetFontAt(double timecode);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,11 +7,22 @@ LabelField::LabelField(EffectRow *parent, const QString &string) :
|
||||
label_text_(string)
|
||||
{}
|
||||
|
||||
QWidget *LabelField::CreateWidget()
|
||||
QWidget *LabelField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
QLabel* label = new QLabel(label_text_);
|
||||
QLabel* label;
|
||||
|
||||
if (existing == nullptr) {
|
||||
|
||||
label = new QLabel(label_text_);
|
||||
|
||||
label->setEnabled(IsEnabled());
|
||||
|
||||
} else {
|
||||
|
||||
label = static_cast<QLabel*>(existing);
|
||||
|
||||
}
|
||||
|
||||
label->setEnabled(IsEnabled());
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
|
||||
|
||||
return label;
|
||||
|
||||
@@ -9,7 +9,7 @@ class LabelField : public EffectField
|
||||
public:
|
||||
LabelField(EffectRow* parent, const QString& string);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
|
||||
private:
|
||||
QString label_text_;
|
||||
};
|
||||
|
||||
@@ -18,17 +18,27 @@ QString StringField::GetStringAt(double timecode)
|
||||
return GetValueAt(timecode).toString();
|
||||
}
|
||||
|
||||
QWidget *StringField::CreateWidget()
|
||||
QWidget *StringField::CreateWidget(QWidget *existing)
|
||||
{
|
||||
TextEditEx* text_edit = new TextEditEx(nullptr, rich_text_);
|
||||
TextEditEx* text_edit;
|
||||
|
||||
text_edit->setEnabled(IsEnabled());
|
||||
text_edit->setUndoRedoEnabled(true);
|
||||
if (existing == nullptr) {
|
||||
|
||||
// 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));
|
||||
text_edit = new TextEditEx(nullptr, rich_text_);
|
||||
|
||||
text_edit->setEnabled(IsEnabled());
|
||||
text_edit->setUndoRedoEnabled(true);
|
||||
|
||||
// the "2" is because the height needs one extra pixel of padding 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));
|
||||
|
||||
} else {
|
||||
|
||||
text_edit = static_cast<TextEditEx*>(existing);
|
||||
|
||||
}
|
||||
|
||||
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
|
||||
connect(this, SIGNAL(EnabledChanged(bool)), text_edit, SLOT(setEnabled(bool)));
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
|
||||
QString GetStringAt(double timecode);
|
||||
|
||||
virtual QWidget *CreateWidget() override;
|
||||
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
|
||||
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
|
||||
private slots:
|
||||
void UpdateFromWidget(const QString& b);
|
||||
|
||||
Reference in New Issue
Block a user