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 ) : ...@@ -39,11 +39,13 @@ EffectInstanceWidget::EffectInstanceWidget( QWidget *parent ) :
m_ui( new Ui::EffectSettingWidget ) m_ui( new Ui::EffectSettingWidget )
{ {
m_ui->setupUi( this ); m_ui->setupUi( this );
clear();
} }
void void
EffectInstanceWidget::setEffectInstance( EffectInstance *instance ) EffectInstanceWidget::setEffectInstance( EffectInstance *instance )
{ {
clear();
m_effect = instance; m_effect = instance;
m_ui->nameValueLabel->setText( instance->effect()->name() ); m_ui->nameValueLabel->setText( instance->effect()->name() );
m_ui->descValueLabel->setText( instance->effect()->description() ); m_ui->descValueLabel->setText( instance->effect()->description() );
...@@ -59,6 +61,8 @@ EffectInstanceWidget::setEffectInstance( EffectInstance *instance ) ...@@ -59,6 +61,8 @@ EffectInstanceWidget::setEffectInstance( EffectInstance *instance )
EffectSettingValue *s = it.value(); EffectSettingValue *s = it.value();
ISettingsCategoryWidget *widget = widgetFactory( s ); ISettingsCategoryWidget *widget = widgetFactory( s );
QLabel *label = new QLabel( tr( s->name() ), this ); QLabel *label = new QLabel( tr( s->name() ), this );
m_widgets.push_back( label );
m_widgets.push_back( widget->widget() );
widget->widget()->setToolTip( s->description() ); widget->widget()->setToolTip( s->description() );
m_ui->settingsLayout->addRow( label , widget->widget() ); m_ui->settingsLayout->addRow( label , widget->widget() );
m_settings.push_back( widget ); m_settings.push_back( widget );
...@@ -68,6 +72,20 @@ EffectInstanceWidget::setEffectInstance( EffectInstance *instance ) ...@@ -68,6 +72,20 @@ EffectInstanceWidget::setEffectInstance( EffectInstance *instance )
this, SLOT( save() ) ); 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 QString
EffectInstanceWidget::nameFromType( Effect::Type type ) EffectInstanceWidget::nameFromType( Effect::Type type )
{ {
......
...@@ -43,9 +43,11 @@ class EffectInstanceWidget : public QWidget ...@@ -43,9 +43,11 @@ class EffectInstanceWidget : public QWidget
private: private:
static QString nameFromType( Effect::Type type ); static QString nameFromType( Effect::Type type );
ISettingsCategoryWidget *widgetFactory( EffectSettingValue *s ); ISettingsCategoryWidget *widgetFactory( EffectSettingValue *s );
void clear();
private: private:
EffectInstance *m_effect; EffectInstance *m_effect;
QList<ISettingsCategoryWidget*> m_settings; QList<ISettingsCategoryWidget*> m_settings;
QList<QWidget*> m_widgets;
Ui::EffectSettingWidget *m_ui; Ui::EffectSettingWidget *m_ui;
public slots: public slots:
......
...@@ -36,6 +36,7 @@ class ISettingsCategoryWidget : public QObject ...@@ -36,6 +36,7 @@ class ISettingsCategoryWidget : public QObject
Q_OBJECT Q_OBJECT
public: public:
virtual ~ISettingsCategoryWidget(){}
virtual SettingValue *setting() { return m_setting; } virtual SettingValue *setting() { return m_setting; }
virtual QWidget* widget() = 0; virtual QWidget* widget() = 0;
virtual void save() = 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