Commit 7020e58e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

EffectInstanceWidget: clear before setting a new effect instance.

parent 3c584d0b
......@@ -39,11 +39,13 @@ EffectInstanceWidget::EffectInstanceWidget( QWidget *parent ) :
m_ui( new Ui::EffectSettingWidget )
{
m_ui->setupUi( this );
clear();
}
void
EffectInstanceWidget::setEffectInstance( EffectInstance *instance )
{
clear();
m_effect = instance;
m_ui->nameValueLabel->setText( instance->effect()->name() );
m_ui->descValueLabel->setText( instance->effect()->description() );
......@@ -59,6 +61,8 @@ EffectInstanceWidget::setEffectInstance( EffectInstance *instance )
EffectSettingValue *s = it.value();
ISettingsCategoryWidget *widget = widgetFactory( s );
QLabel *label = new QLabel( tr( s->name() ), this );
m_widgets.push_back( label );
m_widgets.push_back( widget->widget() );
widget->widget()->setToolTip( s->description() );
m_ui->settingsLayout->addRow( label , widget->widget() );
m_settings.push_back( widget );
......@@ -68,6 +72,20 @@ EffectInstanceWidget::setEffectInstance( EffectInstance *instance )
this, SLOT( save() ) );
}
void
EffectInstanceWidget::clear()
{
m_ui->nameValueLabel->setText( "" );
m_ui->descValueLabel->setText( "" );
m_ui->typeValueLabel->setText( "" );
m_ui->authorValueLabel->setText( "" );
m_ui->versionValueLabel->setText( "" );
qDeleteAll( m_settings );
m_settings.clear();
qDeleteAll( m_widgets );
m_widgets.clear();
}
QString
EffectInstanceWidget::nameFromType( Effect::Type type )
{
......
......@@ -43,9 +43,11 @@ class EffectInstanceWidget : public QWidget
private:
static QString nameFromType( Effect::Type type );
ISettingsCategoryWidget *widgetFactory( EffectSettingValue *s );
void clear();
private:
EffectInstance *m_effect;
QList<ISettingsCategoryWidget*> m_settings;
QList<QWidget*> m_widgets;
Ui::EffectSettingWidget *m_ui;
public slots:
......
......@@ -36,6 +36,7 @@ class ISettingsCategoryWidget : public QObject
Q_OBJECT
public:
virtual ~ISettingsCategoryWidget(){}
virtual SettingValue *setting() { return m_setting; }
virtual QWidget* widget() = 0;
virtual void save() = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment